---
title: Govern an MCP
description: Govern an MCP in Unity Catalog with tool selection, policies, network access, privileges, rate limits, and monitoring.
canonical_url: https://docs.databricks.com/gcp/en/ai-gateway/govern-mcp-service
---

# Govern an MCP

Use Unity Catalog and Unity Gateway to share an MCP, choose its tools, and control usage. These controls apply to [registered](https://docs.databricks.com/gcp/en/ai-gateway/register-mcp-service.md) and [Databricks-provided MCPs](https://docs.databricks.com/gcp/en/agents/mcp-tools/built-in-mcp-services.md).

## <a id="control-callers" />Share an MCP

Callers need `EXECUTE` on the MCP, `USE CATALOG` and `USE SCHEMA` on its parents, and assignment to the workspace. Tools can also require access to underlying data or resources. To share `main.default.my_mcp` with `data-team`, use an identity that can manage its permissions:

1. Open **Unity Gateway**, select **MCPs**, and open the MCP's **Permissions** tab.
2. Click **Grant**, select `data-team` and **EXECUTE**, then click **Grant**.
3. In Catalog Explorer, grant the group `USE CATALOG` on the parent catalog and `USE SCHEMA` on the parent schema.

End users don't need `USE CONNECTION`. Reserve it for MCP authors and administrators because it permits direct use of the connection outside the MCP's tool selection and policies. For automation, see [Grant access programmatically](https://docs.databricks.com/gcp/en/ai-gateway/mcp-service-reference.md#grant-access).

To grant access to a Databricks-provided MCP, a metastore admin must first grant themselves `MANAGE` on the `system.ai` schema. These MCPs can inherit a default `EXECUTE` grant on `system.ai`. To restrict them, review those broad grants and follow [Govern models and MCPs with GRANT policies](https://docs.databricks.com/gcp/en/ai-gateway/govern-access-to-models-with-grant-policies.md).

## <a id="select-tools" />Choose available tools

Registered MCPs expose all server tools by default. During [registration](https://docs.databricks.com/gcp/en/ai-gateway/register-mcp-service.md#create-an-mcp-service), under **Tools**:

* Choose **Select manually** to select individual tools.
* Choose **Advanced** to enter exact names or prefixes such as `get_*`.
* Leave **Automatically include tools added to this server in the future** off if new tools must be reviewed first.

Exclusion patterns such as `!delete_*` aren't supported.

Unselected tools don't appear in `tools/list`, and calls to them return `Tool not allowed by MCP service configuration.`

To change tool selection later, [update the MCP configuration](https://docs.databricks.com/gcp/en/ai-gateway/mcp-service-reference.md#update-a-service) with `config.include_tool_selectors`. An empty list exposes all tools.

## <a id="apply-a-service-policy" />Apply policies

> [!NOTE]
> **Beta**
>
> Service policies on MCPs are in [Beta](https://docs.databricks.com/gcp/en/release-notes/release-types.md) and require the **Unity Gateway Service Policies** preview. A workspace admin turns it on from the **Previews** page. See [Manage workspace-level previews](https://docs.databricks.com/gcp/en/admin/workspace-settings/manage-previews.md#workspace).

A policy evaluates a tool call before it runs (`ON CALL`) and can evaluate its result (`ON RESULT`). It can allow, block, or require approval for a call without changing the tool list. You need `MANAGE` on the MCP to attach a policy. For the types of guardrails you can attach and their setup requirements, see [Guardrails for AI services](https://docs.databricks.com/gcp/en/data-governance/unity-catalog/service-policies/index.md).

### <a id="block-sensitive-data" />Block sensitive data in tool calls and results

Use the built-in Sensitive Data Detection policy to block calls that contain sensitive data, such as personally identifiable information (PII):

1. Open **Unity Gateway**, select **MCPs**, and open the MCP.
2. Open **Policies**, click **New policy**, and enter a name, such as `block_sensitive_data`.
3. Under **Guardrail type**, select **Sensitive Data Detection**.
4. Under **Classification tags**, select the categories to block, such as `class.us_ssn` and `class.credit_card`. Select **Deny** as the action.
5. Under **Phase**, select both **Input** and **Output** to inspect tool arguments and tool results.
6. Set the **Rank**, then click **Create policy**.

The policy applies to all account users on the MCP during Beta. For category behavior and more options, see [Detect sensitive data with a policy](https://docs.databricks.com/gcp/en/data-governance/unity-catalog/service-policies/detect-sensitive-data.md).

### <a id="restrict-a-tool" />Restrict a tool for a specific agent

For a registered MCP that exposes `push_files`, this custom function denies that tool when the acting agent has a specific OAuth client ID. Replace `<agent-oauth-client-id>` with the agent's client ID and `main.governance` with a schema where you can create functions:

```sql
CREATE OR REPLACE FUNCTION main.governance.block_agent_push(event VARIANT)
RETURNS VARIANT
LANGUAGE SQL
RETURN
  CASE
    WHEN event:type::string = 'request'
      AND event:context.tool.name::string = 'push_files'
      AND event:context.actor.context.is_on_behalf_of::boolean = true
      AND event:context.actor.context.client_id::string = '<agent-oauth-client-id>'
    THEN to_variant_object(named_struct('result', 'DENY', 'reason', 'This agent cannot call push_files.'))
    ELSE to_variant_object(named_struct('result', 'ALLOW', 'reason', ''))
  END;
```

1. Run the SQL in a SQL editor to create the function.
2. Open the MCP's **Policies** tab and click **New policy**.
3. Enter a name, select **Custom** under **Guardrail type**, then select the function. Set the **Rank** and click **Create policy**.
4. Call `push_files` through that agent to verify the denial. A call through a different agent should remain allowed by this policy.

This example identifies the agent only for on-behalf-of calls that include its OAuth client ID. The tool still appears in `tools/list`. To remove it for every caller, use [tool selection](https://docs.databricks.com/gcp/en/ai-gateway/govern-mcp-service.md#select-tools). See [Policy function reference](https://docs.databricks.com/gcp/en/data-governance/unity-catalog/service-policies/policy-function-reference.md) for the actor fields and [custom policy setup](https://docs.databricks.com/gcp/en/data-governance/unity-catalog/service-policies/create-service-policy.md) for function privileges. For the built-in service policy `system.ai.github_policy`, which blocks GitHub writes, follow [Govern a coding agent's GitHub MCP access](https://docs.databricks.com/gcp/en/ai-gateway/govern-coding-agent-tutorial.md).

### <a id="partner-guardrail" />Enforce a partner guardrail on tool calls

If you already use a third-party guardrail vendor that implements the Databricks external policy API, attach an external service policy to the MCP. Databricks sends the vendor the tool name and arguments on the input phase and the tool result on the output phase, and enforces the vendor's `ALLOW` or `DENY` verdict, or holds the tool call for approval when the vendor returns `ASK`.

1. Open the MCP's **Policies** tab and click **New policy**.
2. Enter a name, and select **External** under **Guardrail type**.
3. Select an existing Unity Catalog HTTP connection to your vendor's endpoint, or create one with the vendor's OAuth machine-to-machine credentials.
4. Under **Phase**, select **Input**, **Output**, or both. Set the **Rank**, then click **Create policy**.

External service policies fail closed: if the vendor's endpoint is unreachable or slow, Databricks denies the call. For connection fields, the content sent to the vendor, and network egress guidance, see [Enforce an external guardrail](https://docs.databricks.com/gcp/en/data-governance/unity-catalog/service-policies/external-policies.md).

## <a id="set-rate-limits" />Limit call volume

To cap an MCP at 60 tool calls per minute across all callers:

1. Open the MCP in **Unity Gateway**, under **MCPs**.
2. On **Overview**, find **Rate limits** and click **Set up** or **Edit**.
3. Enter `60` in the **Service** QPM field and click **Save**.

MCP rate limits apply to `tools/call` requests and use queries per minute (QPM). Calls over the limit return HTTP 429. See [Rate limits](https://docs.databricks.com/gcp/en/ai-gateway/rate-limits.md) for per-user and group limits.

## <a id="monitor-mcp-service-usage" />Monitor usage

* **Usage:** View call volume, errors, and latency in the [usage dashboard](https://docs.databricks.com/gcp/en/ai-gateway/usage-tracking.md#built-in-usage-dashboard), or query `system.ai_gateway.usage` with `service_type = 'MCP_SERVICE'`.
* **Audit:** Review MCP changes and invocations (`mcpCall`) in `system.access.audit`. See [Audit logs](https://docs.databricks.com/gcp/en/admin/system-tables/audit-logs.md).
* **Traces:** Inspect tool requests, responses, and policy decisions in the [unified trace table](https://docs.databricks.com/gcp/en/ai-gateway/unified-trace-table.md) after an admin enables it.

### Example: count calls by tool

```sql
SELECT mcp_metadata.tool_name AS tool_name, COUNT(*) AS calls
FROM system.ai_gateway.usage
WHERE service_type = 'MCP_SERVICE'
  AND service_name = 'system.ai.github'
GROUP BY mcp_metadata.tool_name
ORDER BY calls DESC;
```

For access to system tables, see [Monitor account activity with system tables](https://docs.databricks.com/gcp/en/admin/system-tables/index.md).

## Network and client access

Use network rules to control connectivity and OAuth client settings to manage client access.

### <a id="restrict-external-access" />External destinations

For outbound network rules and private endpoints, follow [MCP servers on the public internet](https://docs.databricks.com/gcp/en/agents/mcp-tools/networking.md#allow-destinations) and [MCP servers in your cloud network](https://docs.databricks.com/gcp/en/agents/mcp-tools/networking.md#private-connectivity).

### <a id="control-clients" />Client access

An account admin can [enable or disable a dedicated OAuth client](https://docs.databricks.com/gcp/en/integrations/enable-disable-oauth.md#enable-custom-app-ui) from **App connections** in account settings. Disabling it affects that OAuth client account-wide. Clients configured through the Unity Gateway CLI use a Databricks CLI login instead of a dedicated OAuth app.

To restrict a specific agent's calls, use the [policy example](https://docs.databricks.com/gcp/en/ai-gateway/govern-mcp-service.md#restrict-a-tool) above. It requires on-behalf-of calls carrying the agent's OAuth client ID. To restrict inbound network access, Databricks recommends [context-based ingress](https://docs.databricks.com/gcp/en/security/network/front-end/context-based-ingress.md). For hosted clients such as ChatGPT and Claude, add them as [partner platforms](https://docs.databricks.com/gcp/en/security/network/front-end/partner-platforms.md) so you don't maintain their IP ranges. If context-based ingress isn't available for your workspace, use [workspace IP access lists](https://docs.databricks.com/gcp/en/security/network/front-end/ip-access-list-workspace.md). See [Client to workspace (inbound)](https://docs.databricks.com/gcp/en/agents/mcp-tools/networking.md#client-to-workspace).

## <a id="manage-service" />Update or delete an MCP

You need ownership or `MANAGE` on the MCP, plus `USE CATALOG` and `USE SCHEMA` on its parents. Open the MCP from the **MCPs** page or Catalog Explorer:

* **Update:** Edit its configuration and save. The MCP name cannot be changed.
* **Delete:** Open the three-dot menu and select **Delete**. Clients using its URL can no longer call it.

For automation, see [Update an MCP](https://docs.databricks.com/gcp/en/ai-gateway/mcp-service-reference.md#update-a-service) or [Delete an MCP](https://docs.databricks.com/gcp/en/ai-gateway/mcp-service-reference.md#delete-a-service).
