Careeroza
Connecting MCP Tools to Claude
MCP Tools in Your Own App
The Anthropic Python SDK has beta helpers that convert MCP tools into tools for the tool runner (pip install "anthropic[mcp]"). Your chatbot then gets every tool the server offers, with no extra code per tool.
import asyncio
from anthropic import AsyncAnthropic
from anthropic.lib.tools.mcp import async_mcp_tool
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
client = AsyncAnthropic()
async def main():
params = StdioServerParameters(command="python", args=["shopease_mcp.py"])
async with stdio_client(params) as (read, write):
async with ClientSession(read, write) as mcp_client:
await mcp_client.initialize()
tools_result = await mcp_client.list_tools()
runner = client.beta.messages.tool_runner(
model="claude-opus-5-5",
max_tokens=4000,
messages=[{"role": "user", "content": "Is my order SE1077 delivered yet?"}],
tools=[async_mcp_tool(t, mcp_client) for t in tools_result.tools],
)
async for message in runner:
for block in message.content:
if block.type == "text":
print(block.text)
asyncio.run(main())Run it
python chat_with_mcp.pyExample output
Not yet - your Prestige Pressure Cooker 3L (SE1077) is out for delivery and should reach you today.
Security
- Only install MCP servers you trust. A server runs code on your machine and its tool descriptions go into the model's context (a malicious server can hide instructions there: "tool poisoning").
- Give each server the least privilege it needs: a read-only database user, scoped API tokens.
- Keep secrets in environment variables of the server, never in tool descriptions.
- Ask for user confirmation before tools that change data.