Examples and patterns for integrating FastMCP Cloud servers with Claude Agent SDK using HTTP transport
Inherits all available tools
Additional assets for this skill
This skill inherits all available tools. When active, it can use any tool Claude has access to.
examples/connection-status.pyexamples/fastmcp-cloud-http.pyexamples/multi-server.pyThis skill provides examples and troubleshooting for FastMCP Cloud integration.
FastMCP Cloud uses HTTP, NOT SSE!
Example: Basic FastMCP Cloud Integration
import os
import asyncio
from dotenv import load_dotenv
from claude_agent_sdk import query
from claude_agent_sdk.types import ClaudeAgentOptions
load_dotenv()
ANTHROPIC_API_KEY = os.getenv("ANTHROPIC_API_KEY")
FASTMCP_CLOUD_API_KEY = os.getenv("FASTMCP_CLOUD_API_KEY")
async def main():
async for message in query(
prompt="List available tools from the MCP server",
options=ClaudeAgentOptions(
model="claude-sonnet-4-20250514",
# ✅ CRITICAL: Use HTTP for FastMCP Cloud
mcp_servers={
"your-server": {
"type": "http", # ← Must be "http" not "sse"
"url": "https://your-server.fastmcp.app/mcp",
"headers": {
"Authorization": f"Bearer {FASTMCP_CLOUD_API_KEY}"
}
}
},
# Allow MCP tools
allowed_tools=["mcp__your-server__*"],
# Pass API keys via env
env={
"ANTHROPIC_API_KEY": ANTHROPIC_API_KEY,
"FASTMCP_CLOUD_API_KEY": FASTMCP_CLOUD_API_KEY
}
)
):
if hasattr(message, 'type') and message.type == 'text':
print(message.text)
if __name__ == "__main__":
asyncio.run(main())
Example: Multiple FastMCP Cloud Servers
mcp_servers={
"cats": {
"type": "http",
"url": "https://catsmcp.fastmcp.app/mcp",
"headers": {"Authorization": f"Bearer {FASTMCP_CLOUD_API_KEY}"}
},
"github": {
"type": "http",
"url": "https://github-mcp.fastmcp.app/mcp",
"headers": {"Authorization": f"Bearer {FASTMCP_CLOUD_API_KEY}"}
}
}
allowed_tools=[
"mcp__cats__*", # All CATS tools
"mcp__github__*", # All GitHub tools
]
Example: Checking MCP Connection Status
async for message in query(...):
if hasattr(message, 'type') and message.type == 'system':
if hasattr(message, 'data') and 'mcp_servers' in message.data:
for server in message.data['mcp_servers']:
status = server.get('status', 'unknown')
name = server.get('name', 'unknown')
print(f"✅ MCP Server '{name}': {status}")
if status == 'failed':
print("❌ Connection failed!")
print(" Check: 1) Using 'type': 'http'")
print(" Check: 2) FASTMCP_CLOUD_API_KEY is valid")
print(" Check: 3) URL is correct")
Wrong transport type:
"type": "sse" # ❌ Doesn't work with FastMCP Cloud
Missing API key:
# ❌ Not passing FASTMCP_CLOUD_API_KEY
env={"ANTHROPIC_API_KEY": ANTHROPIC_API_KEY}
Wrong package:
from anthropic_agent_sdk import query # ❌ Wrong!
# Should be:
from claude_agent_sdk import query # ✅ Correct
'mcp_servers': [{'name': 'cats', 'status': 'failed'}]Causes:
"type": "sse" instead of "type": "http"FASTMCP_CLOUD_API_KEYFix:
"type": "http"env parameterhttps://your-server.fastmcp.app/mcp (with /mcp endpoint)ImportError: No module named 'anthropic_agent_sdk'Cause: Wrong package name
Fix:
pip uninstall anthropic-agent-sdk # Remove wrong package
pip install claude-agent-sdk # Install correct package
See examples/python/fastmcp-cloud-http.py for a full working example.
Required in .env:
ANTHROPIC_API_KEY=sk-ant-api03-...
FASTMCP_CLOUD_API_KEY=fmcp_...
Must be passed via env parameter:
env={
"ANTHROPIC_API_KEY": os.getenv("ANTHROPIC_API_KEY"),
"FASTMCP_CLOUD_API_KEY": os.getenv("FASTMCP_CLOUD_API_KEY")
}
When you run your agent, you'll see system messages like this:
# System message with connection status
SystemMessage(
subtype='init',
data={
'type': 'system',
'session_id': 'c8feee3e-bb62-4dcc-92bc-042b507e614a',
'mcp_servers': [{'name': 'cats', 'status': 'connected'}], # ✅ Connected!
'tools': ['mcp__cats__search_candidates', 'mcp__cats__get_candidate', ...],
'model': 'claude-sonnet-4-20250514',
...
}
)
What this means:
'status': 'connected' ✅ - Your HTTP configuration worked!'tools': [...] - All 163 CATS tools are now availablemcp__cats__search_candidates, etc.If you use wrong transport type, you'll see:
SystemMessage(
data={
'mcp_servers': [{'name': 'cats', 'status': 'failed'}], # ❌ Failed!
'tools': ['Task', 'Bash', 'Read', ...], # Only built-in tools, no MCP tools
...
}
)
What this means:
'status': 'failed' ❌ - Connection didn't workmcp__cats__* tools available"type": "sse" instead of "type": "http"When Claude uses an MCP tool:
# Claude decides to call search_candidates
AssistantMessage(
content=[
ToolUseBlock(
id='toolu_01HhvXi5wyvVa2DWtbP8KvJw',
name='mcp__cats__search_candidates',
input={'search_string': 'heavy duty mechanic'}
)
]
)
# Tool result comes back
UserMessage(
content=[
ToolResultBlock(
tool_use_id='toolu_01HhvXi5wyvVa2DWtbP8KvJw',
content='{"count":2,"total":3540,"_embedded":{"candidates":[...]}}'
)
]
)
# Claude responds with analysis
AssistantMessage(
content=[
TextBlock(
text="I found 3,540 heavy duty mechanic candidates. Here are the first 2..."
)
]
)
================================================================================
CATS Multi-Tool Agent Demo - Claude Agent SDK
================================================================================
🔌 MCP Server Status:
--------------------------------------------------------------------------------
✅ cats: CONNECTED
📦 Available CATS Tools: 163
- search_candidates
- get_candidate
- list_candidate_custom_fields
- list_candidate_attachments
- parse_resume
... and 158 more
💬 Claude:
--------------------------------------------------------------------------------
I'll search for heavy duty mechanics using the CATS database...
💬 Claude:
--------------------------------------------------------------------------------
I found 3,540 heavy duty mechanic candidates in the system. Here are the
first 2 results with their Red Seal certification status:
1. **Sahlan Samsuddin**
- Email: sahlansamsuddin11@gmail.com
- Location: Mimika, Papua
- Red Seal Status: Not found in "Notes on Qualifications" field
- Tags: None
2. **[Next candidate]**
...
See the examples/ directory in this skill:
examples/multi-server.py - Connecting to multiple FastMCP Cloud serversexamples/connection-status.py - Testing and troubleshooting connections@plugins/claude-agent-sdk/examples/python/complete-example-with-output.py - Full example with output@plugins/claude-agent-sdk/examples/python/basic-query.py@plugins/claude-agent-sdk/examples/python/fastmcp-cloud-http.py@plugins/claude-agent-sdk/examples/README.md@plugins/claude-agent-sdk/docs/sdk-documentation.md