Agent Wealth HubFree public resources
中文 EN العربية

Back to catalog / Agent tools

Provide an in-process read-only MCP tool

Wrap a narrow Python function as an SDK MCP server and allow only its named tool.

Goal

Let the agent call a controlled application function without launching a separate MCP process.

Steps

  1. Define a function with @tool(name, description, input_schema), validate input, and bind it to a read-only data source. [mcp]
  2. Create the server with create_sdk_mcp_server(name=..., version=..., tools=[...]) and register it in ClaudeAgentOptions(mcp_servers={...}). [mcp]
  3. Add only the mcp__<server>__<tool> name to allowed_tools, test with synthetic data, and inspect ToolUseBlock/ToolResultBlock. [mcp]

How to verify

The agent can call only the intended tool; invalid arguments are rejected and errors set `is_error`.

Troubleshooting

If the tool is missing, check the server key, tool name, and full allowed_tools name; return content text blocks for results.

Permissions

Prerequisites

Permissions

Limitations

The SDK MCP server runs in-process; your function backend enforces data permissions, not the tool description.

Pinned upstream source

https://github.com/anthropics/claude-agent-sdk-python/blob/b6e9d12fe1cc98dde988ab7b7713c1feeee50c6c/examples/mcp_calculator.py

Repository
anthropics/claude-agent-sdk-python
File path
examples/mcp_calculator.py
Pinned commit
b6e9d12fe1cc98dde988ab7b7713c1feeee50c6c
Source checked
2026-10-14 · Reviewed against the pinned upstream source

Repository metrics

These values describe the upstream repository, not popularity or likes for an individual skill or playbook.

Stars
Not collected
Forks
Not collected
Observed at
Not collected

No metrics snapshot is available yet.

License: MIT

Main topic

When to use a Skill or MCP

Related resources