Dev Khant
10/13/2025, 5:15 PMpython
from anthropic import Anthropic
# Initialize Anthropic client
client = Anthropic(api_key="")
# Use the MCP server URL you generated
mcp_server_url = ""
# Use MCP with Anthropic (beta feature)
response = client.beta.messages.create(
model="claude-sonnet-4-5",
system="You are a helpful assistant with access to various tools through MCP. Use these tools to help the user. Do not ask for confirmation before using the tools.",
max_tokens=1000,
messages=[{
"role": "user",
"content": "What all repos do I have in github and channels in slack?"
}],
mcp_servers=[{
"type": "url",
"url": mcp_server_url,
"name": "testing-init-flow"
}],
betas=["mcp-client-2025-04-04"] # Enable MCP beta
)
print(response.content)
Error:
BadRequestError: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'Connection error while communicating with MCP server: Connection closed by server'}, 'request_id': 'req_xx'}
I have been following the doc: https://docs.composio.dev/docs/mcp-quickstart.
Any guidance will be helpful, thanks in Advance!Akram Boussanni
10/13/2025, 5:21 PMDev Khant
10/13/2025, 5:25 PMDev Khant
10/13/2025, 5:26 PMDev Khant
10/13/2025, 5:28 PMAkram Boussanni
10/13/2025, 5:29 PMDev Khant
10/15/2025, 1:46 AM