google / google/adk-go

tool/mcptoolset: support tool name prefixing across multiple servers (parity with adk-python tool_name_prefix)

Open
#1,126 1 comment 0 reactions 2 assignees Claimed by @kdroste-google View on GitHub
enhancement needs review
Dominant language
Go
Stars
8.8k
Forks
1k
Avg merge
3d 18h
Merged PRs (30d)
88

Description

### Problem

`tool/mcptoolset` exposes MCP tools under their raw server-side names, with no way to prefix or rename them. `convertTool` sets both the tool `Name()` and the `genai.FunctionDeclaration.Name` to `t.Name` verbatim, and `Config` offers no prefix/rename option (only `Client`, `Transport`, `ToolFilter`, `RequireConfirmation`, `RequireConfirmationProvider`).

For an agent connected to **multiple MCP servers** this causes two problems:

1. **Hard collision:** two servers exporting the same tool name (e.g. both a filesystem and a GitHub server exposing `read_file`) fail at request-packing time with `duplicate tool: "read_file"` (`toolutils.PackTool`).
2. **Wrapper bypass for renaming layers:** a user-side wrapper that exposes a prefixed `Name()` doesn't help, because each `mcpTool` implements `ProcessRequest` and packs **itself** under its bare name into `LLMRequest.Tools` — at dispatch time the model calls the bare name and the inner tool runs directly, skipping the wrapper. Host applications that key permission/approval policy on namespaced tool names (a common pattern) silently lose that scoping.

### Precedent in adk-python

adk-python already solved this: `BaseToolset.tool_name_prefix` ("The prefix to prepend to the names of the tools returned by the toolset"), applied via `get_tools_with_prefix()` as `{prefix}_{name}` to both the tool name and its declaration, and passed through by `MCPToolset` since https://github.com/google/adk-python/issues/2814 was fixed. adk-go has no equivalent.

### Ecosystem context

Namespacing multi-server MCP tools client-side is the converged practice: Claude Code exposes `mcp____` and scopes permission rules on it; the MCP spec's namespace proposal (SEP-993) uses `__`; LangChain's MCP adapters and the OpenAI Agents SDK both added opt-in server-name prefixing after collision bugs; FastMCP's proxy/mount composition auto-prefixes per server.

### Proposed API

A `Config` option on `mcptoolset`, e.g.:

```go
type Config struct {
// ...
// ToolNamePrefix, when non-empty, is prepended to each tool's exposed
// name and function declaration (the MCP server is still called with
// the original name).
ToolNamePrefix string
}
```

or the Python-parity route of a prefix concept on toolsets generally. The key requirement is that the rename applies to `Name()`, the `FunctionDeclaration`, and the name the tool packs itself under in `ProcessRequest`, while `CallTool` keeps using the original server-side name.

Happy to contribute a PR if the direction is acceptable.

### Environment

`google.golang.org/adk/v2 v2.0.0` (latest release at time of filing), `github.com/modelcontextprotocol/go-sdk v1.6.1`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.