Skip to main content
AgentScope integrates with Model Context Protocol (MCP) servers, letting an agent reach any MCP-compatible tool provider. The framework handles protocol negotiation, tool discovery, and result conversion automatically. Two connection modes are supported: MCP tools are namespaced as mcp__{server_name}__{tool_name} to avoid name collisions, and tools annotated with readOnlyHint are recognized as read-only by the permission system (auto-allowed in EXPLORE and ACCEPT_EDITS modes; in DEFAULT they still ASK unless an allow rule matches).

Register MCP Client

Build one or more MCPClient instances and pass them to Toolkit(mcps=[...]). Stateful clients must be connected before the toolkit is constructed.

Filter Exposed Tools

To expose only a subset of an MCP server’s tools, set enable_tools or disable_tools on the client itself:

Update HTTP Headers at Runtime

The headers in mcp_config are fixed at construction. When an auth token rotates mid-session, call set_runtime_headers() on a Streamable HTTP client to replace the headers sent with subsequent requests — no rebuild and no reconnect:
The behaviour has a few boundaries worth knowing:
In a Docker workspace the live MCP client runs inside the gateway process and the host holds a proxy. Calling set_runtime_headers() on the proxy relays the update to the gateway — see MCP Gateway.

Use MCP Tools Outside a Toolkit

If you need to invoke MCP tools outside a Toolkit, call await client.list_tools() to retrieve a list of MCPTool adapters and use them like any other ToolBase instance.