π¦
Fastmcp Documentation
Comprehensive documentation and reference guides for developing FastMCP servers
0 installs
Trust: 34 β Low
Devtools
Ask AI about Fastmcp Documentation
Powered by Claude Β· Grounded in docs
I know everything about Fastmcp Documentation. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Loading tools...
Reviews
Documentation
FastMCP Documentation
Streamlined documentation for building and deploying FastMCP servers to FastMCP Cloud
π Quick Start
1. Install FastMCP
pip install fastmcp
2. Create Your Server
from fastmcp import FastMCP
# MUST be at module level for FastMCP Cloud
mcp = FastMCP("my-server")
@mcp.tool()
async def hello(name: str) -> str:
"""Say hello to someone."""
return f"Hello, {name}!"
3. Deploy to FastMCP Cloud
- Push your code to GitHub
- Connect repository at fastmcp.cloud
- Add environment variables
- Deploy with one click
π Documentation
Essential Guides
- docs/GUIDE.md - Complete development guide
- docs/REFERENCE.md - Quick CLI reference
- docs/CLOUD_DEPLOYMENT.md - FastMCP Cloud deployment guide
Feature Documentation
- docs/FEATURES.md - Advanced FastMCP v2 features
- docs/INTEGRATIONS.md - API integration patterns
- docs/PATTERNS.md - Common patterns and solutions
Development Tools
- docs/CLI.md - CLI command reference
- docs/TROUBLESHOOTING.md - Debugging guide
π― Templates
Simple Template
For straightforward servers with basic functionality:
templates/simple/
βββ server.py # Basic server implementation
βββ server_advanced.py # Advanced features example
βββ handlers.py # Client handlers
βββ requirements.txt # Dependencies
Modular Template
Production-ready structure matching our SimPro pattern:
templates/modular/
βββ src/
β βββ server.py # Main entry point
β βββ tools/ # Organized tool modules
β βββ resources/ # Resource definitions
β βββ prompts/ # Prompt templates
β βββ shared/ # Shared utilities
βββ requirements.txt
β‘ FastMCP Cloud Requirements
Critical for Cloud Deployment
- Module-level server object named
mcp,server, orapp - PyPI dependencies only in requirements.txt
- Public GitHub repository (or accessible to FastMCP Cloud)
- Environment variables for configuration
Example Cloud-Ready Server
# server.py
from fastmcp import FastMCP
import os
# MUST be at module level
mcp = FastMCP(
name="production-server"
)
# Use environment variables
API_KEY = os.getenv("API_KEY")
DATABASE_URL = os.getenv("DATABASE_URL")
@mcp.tool()
async def production_tool(data: str) -> dict:
"""Production-ready tool."""
# Your implementation here
return {"status": "success", "data": data}
# Optional: for local testing
if __name__ == "__main__":
import asyncio
asyncio.run(mcp.run())
π§ Common Use Cases
API Integration Server
from fastmcp import FastMCP
import httpx
mcp = FastMCP("api-server")
@mcp.tool()
async def fetch_data(endpoint: str) -> dict:
"""Fetch data from API."""
async with httpx.AsyncClient() as client:
response = await client.get(f"https://api.example.com/{endpoint}")
return response.json()
Data Processing Server
from fastmcp import FastMCP
mcp = FastMCP("data-processor")
@mcp.tool()
async def process_csv(data: str) -> dict:
"""Process CSV data."""
rows = data.split('\n')
return {"rows": len(rows), "processed": True}
AI Integration Server
from fastmcp import FastMCP
from openai import AsyncOpenAI
mcp = FastMCP("ai-server")
client = AsyncOpenAI()
@mcp.tool()
async def generate_text(prompt: str) -> str:
"""Generate text using AI."""
response = await client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": prompt}]
)
return response.choices[0].message.content
ποΈ Project Structure
fastmcp-documentation/
βββ README.md # This file
βββ docs/ # Core documentation
β βββ GUIDE.md # Development guide
β βββ REFERENCE.md # Quick reference
β βββ CLOUD_DEPLOYMENT.md # Cloud deployment
β βββ FEATURES.md # Advanced features
β βββ INTEGRATIONS.md # API integrations
β βββ PATTERNS.md # Common patterns
β βββ CLI.md # CLI reference
β βββ TROUBLESHOOTING.md # Debug guide
βββ templates/ # Project templates
β βββ simple/ # Basic server template
β βββ modular/ # Production template
βββ complex-detail/ # Advanced topics (self-hosting, infrastructure)
π FastMCP v2 Features
- β Resource Templates - Dynamic resources with parameters
- β Elicitation - Interactive user input during execution
- β Progress Tracking - Monitor long-running operations
- β Sampling - LLM integration for servers
- β Client Handlers - Handle client events
- β Tool Transformation - Enhance existing tools
- β Server Composition - Mount sub-servers
π¦ Getting Started Steps
1. Choose a Template
- Simple: For basic servers with few tools
- Modular: For production servers with multiple features
2. Develop Locally
# Install FastMCP
pip install fastmcp
# Test your server
fastmcp dev server.py
3. Deploy to Cloud
- Push to GitHub
- Connect at fastmcp.cloud
- Configure environment variables
- Deploy instantly
π Troubleshooting
Common Issues
"No server object found"
- Ensure your server object is at module level
- Name it
mcp,server, orapp
"Module not found"
- Use only PyPI packages in requirements.txt
- No local packages or git URLs
"Environment variable not set"
- Add variables in FastMCP Cloud dashboard
- Use
os.getenv()with defaults
π οΈ Advanced Topics
For advanced deployment scenarios, see the complex-detail/ folder:
- Self-hosting with Docker/Kubernetes
- Cloud infrastructure (AWS, Azure, GCP)
- CI/CD pipelines
- Monitoring and scaling
π Resources
- FastMCP Cloud - Deploy your servers
- FastMCP GitHub - Source code
- MCP Protocol - Protocol specification
- Context 7 official docs library: context7CompatibleLibraryID: "/jlowin/fastmcp"
π License
This documentation is for internal reference and development guidance.
Last Updated: August 2025 FastMCP Version: 2.12.0+
