Skip to content

Add include_tools / exclude_tools to McpServerConfig (parity with Gemini CLI includeTools) #28

@ide-developer

Description

@ide-developer

Summary

Gemini CLI supports per-MCP-server tool allowlists via includeTools / excludeTools in settings JSON. The Python SDK (google-antigravity 0.1.0) has no equivalent on McpStdioServer, McpSseServer, or McpStreamableHttpServerMcpBridge.get_mcp_tools() registers every tool returned by the server with no client-side filtering.

For automation use cases (e.g. GitHub Actions PR review), we need to restrict the MCP toolset exposed to the model in the SDK, not only at runtime via policies.

Motivation

The SDK docs in hooks/policy.py recommend config-level tool restriction (CapabilitiesConfig.enabled_tools / disabled_tools) over policy.deny() because disabled tools are removed from model context and save tokens. Policies leave denied tools visible; the model may still attempt them.

CapabilitiesConfig.enabled_tools only applies to builtin harness tools (BuiltinTools enum), not MCP tool names.

Current workarounds:

  1. Server-side allowlist — e.g. GitHub remote MCP X-MCP-Tools header. Works but couples SDK config to server-specific headers; not portable across MCP servers.
  2. policies=[deny_all(), allow("tool_name"), ...] — runtime enforcement only; MCP tools remain in context.
  3. Manual McpBridge + filter + pass via LocalAgentConfig.tools — bypasses mcp_servers; awkward lifecycle.

Requested API

Parity with Gemini CLI MCP server config:

McpStreamableHttpServer(
    url="https://api.githubcopilot.com/mcp/x/pull_requests",
    headers={"Authorization": f"Bearer {token}"},
    include_tools=[
        "pull_request_read",
        "pull_request_review_write",
    ],
    # exclude_tools=[...],  # optional; exclude takes precedence
)

Same fields on McpStdioServer and McpSseServer.

Behavior:

  • After MCP tools/list, McpBridge only registers tools matching include_tools (if set).
  • exclude_tools removes tools even if listed in include_tools (match Gemini CLI semantics).
  • When neither is set, current behavior (all server tools) unchanged.

Optional: document that server-side filtering (e.g. X-MCP-Tools) and SDK include_tools can be combined; SDK filter is the portable contract.

Use case

Headless PR review agent in CI:

  • Zero builtin tools: CapabilitiesConfig(enabled_tools=[])
  • MCP-only GitHub tools: strict allowlist of 2–4 review tools
  • Deny-by-default policies as defense in depth

Today we must rely on GitHub MCP server headers for context-level MCP filtering; SDK-native include_tools would match Gemini CLI / agy plugin configs and simplify secure automation.

Environment

  • google-antigravity==0.1.0
  • Python 3.14 (also tested via local spike)

References

  • Gemini CLI: includeTools / excludeTools on mcpServers.*
  • SDK: google/antigravity/mcp/bridge.py — no filtering in get_mcp_tools()
  • SDK: google/antigravity/types.pyMcpStreamableHttpServer fields limited to transport config

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions