Overview
Deploy Python MCP servers using FastMCP with automatic containerization and infrastructure managed by Smithery.Prerequisites
- Python MCP server using FastMCP that exports a server creation function
- Python 3.12+ installed locally
- A Python package manager: uv (recommended), poetry, or pip
FastMCP Compatibility
When using FastMCP, ensure you have compatible versions:mcp>=1.6.0
ORfastmcp>=2.0.0
New to MCP servers? See the Getting Started guide to learn how to build Python MCP servers from scratch using FastMCP.
Project Structure
Your Python project should look like this:Setup
1. Configure smithery.yaml
Create asmithery.yaml
file in your repository root (usually where the pyproject.toml
is):
2. Configure pyproject.toml
Yourpyproject.toml
must include the Smithery server configuration:
3. Ensure Proper Server Structure
Your Python MCP server must have a function decorated with@smithery.server()
that returns a FastMCP server object.
Accessing Session ConfigurationSession-specific configuration is accessed through the Each user session gets its own configuration instance, enabling per-user customization of your server’s behavior.No config needed? Just omit the
Context
parameter in your tools:config_schema
parameter: @smithery.server()
- Function must be decorated with
@smithery.server()
- Function must return a FastMCP server instance
- The function path must be specified in
[tool.smithery]
section ofpyproject.toml
Local Development
After installing dependencies (uv sync
or poetry install
), test your server locally using the Smithery CLI:
- Test your MCP server tools in real-time
- See tool responses and debug issues
- Experiment with different inputs
Deploy
- Push your code (including
smithery.yaml
) to GitHub - Connect your GitHub to Smithery (or claim your server if already listed)
- Navigate to the Deployments tab on your server page
- Click Deploy to build and host your server
Good to Know
What happens under the hood?
What happens under the hood?
When you deploy, Smithery will:
- Clone your repository
- Parse your
smithery.yaml
to detect Python runtime - Install dependencies using uv
- Load your server function specified in
[tool.smithery]
configuration - Package your server into a containerized HTTP service
- Deploy the container to our hosting infrastructure
- Send MCP
initialize
andlist_tools
messages to discover your server’s capabilities - Make it available at
https://server.smithery.ai/your-server/mcp
- Handle load balancing, scaling, and monitoring
Troubleshooting
Why does my deployment fail?
Why does my deployment fail?
Common deployment failures and solutions:
- Missing server configuration: Ensure your
pyproject.toml
has the[tool.smithery]
section with correct server path - Dependencies not found: All dependencies must be listed in the
dependencies
array - Import errors: Verify your server module can be imported and the function exists
- Server doesn’t run locally: Before deploying, verify your server works locally:
If this fails, fix any Python errors or missing dependencies first
- Missing smithery decorator: Ensure your server function is decorated with
@smithery.server()