Deploy Python MCP Servers

DeployContext supports Python MCP servers out of the box. Build with FastAPI, uvicorn, and the official MCP Python SDK—we handle the rest.

Prerequisites

  • A GitHub repository with your Python MCP server
  • A requirements.txt or pyproject.toml file
  • The mcp package in your dependencies
  • A DeployContext account

Runtime Detection

DeployContext automatically detects Python projects by looking for:

FileRuntime
requirements.txtPython
pyproject.tomlPython
package.jsonNode.js

Required Dependencies

Your requirements.txt should include:

mcp>=1.0.0
fastapi>=0.115.0
uvicorn[standard]>=0.32.0
sse-starlette>=2.1.0

Server Structure

Your Python MCP server needs these endpoints:

  • GET /health — Health check endpoint
  • GET /sse — SSE endpoint for MCP communication
  • POST /message — Message endpoint for receiving MCP requests

→ See the complete example repository

Deployment Steps

  1. Push your code to GitHub

    Ensure your repository is public or accessible to DeployContext.

  2. Go to the Dashboard

    Navigate to Deploy New MCP.

  3. Enter your repository URL

    We'll automatically detect Python and validate the MCP SDK.

  4. Configure and Deploy

    Set your MCP name, description, and click Deploy.

Entry Point Detection

DeployContext looks for your Python entry point in this order:

  1. server.py
  2. main.py
  3. app.py
  4. src/server.py
  5. src/main.py

Environment Variables

These environment variables are available at runtime:

  • PORT — The port your server should listen on (default: 8081)
  • MESSAGE_ENDPOINT — The message endpoint URL for SSE

Transport Modes

Python MCPs can use different transport modes:

  • Native HTTP/SSE: Python MCPs with FastAPI/SSE endpoints (like the example repo)
  • stdio Bridge: Python stdio MCPs are automatically bridged to HTTP/SSE (coming soon)
  • SSE Flag: Some Python MCPs support --transport sse flag

DeployContext automatically detects your transport mode and handles it appropriately. For native HTTP/SSE MCPs (recommended), you control the server directly. For stdio MCPs, the bridge handles the conversion automatically.

Troubleshooting

  • Runtime not detected as Python

    Ensure you have a requirements.txt or pyproject.toml in your repository root.

  • MCP SDK not found

    Add mcp>=1.0.0 to your dependencies.

  • Server not starting

    Make sure your server listens on 0.0.0.0 and uses the PORT environment variable.

  • SSE connection failing

    Ensure your /sse endpoint sends the endpoint event with the session ID.

  • Build fails with pyproject.toml

    If using hatchling, ensure your pyproject.toml has proper package configuration. DeployContext prefers pyproject.toml over requirements.txt when both exist.

Example Repository

See a complete working Python MCP server with text utilities:

View on GitHub →