Skip to main content

gmcp - Transform FastAPI to MCP

gmcp automatically converts any FastAPI server into an MCP (Model Context Protocol) server, exposing all API endpoints as tools that Claude can use.

Features

  • 🚀 Zero Configuration: Just provide a FastAPI server URL
  • 🔄 Auto-Discovery: Automatically discovers all endpoints via OpenAPI schema
  • 🛠️ Full Support: Handles GET, POST, PUT, PATCH, DELETE methods
  • 📝 Schema Aware: Preserves parameter types, descriptions, and validation
  • 🔐 Authentication: Supports Bearer tokens, API keys, Basic auth, and custom headers
  • 🔒 Secure: Environment variable support for sensitive credentials
  • ⚡ Fast: Efficient async HTTP client built on httpx

Installation

# Install library
pip install gmcp
# Install in development mode
git clone https://github.com/gaurav98095/gmcp.git
cd gmcp
pip install -e .

Usage

Basic Usage

Testing (list available tools):

# Test that gmcp can discover tools
gmcp --list-tools http://localhost:5000

Running as MCP server:

gmcp automatically detects when it's run from an interactive terminal and will show helpful instructions instead of starting the server. To use it as an MCP server, configure it in Claude Code (see below).

If you need to force MCP server mode (e.g., for testing with another MCP client):

gmcp --force http://localhost:5000

Configure in Claude Code

Add to ~/.claude/mcp_settings.json:

Basic (no auth):

{
  "mcpServers": {
    "my-fastapi-server": {
      "command": "gmcp",
      "args": ["http://localhost:5000"]
    }
  }
}

With Authentication:

{
  "mcpServers": {
    "my-api": {
      "command": "gmcp",
      "args": [
        "http://api.example.com",
        "--auth-type", "bearer",
        "--auth-token", "$API_TOKEN"
      ],
      "env": {
        "API_TOKEN": "your-token-here"
      }
    }
  }
}

See AUTH.md for complete authentication documentation.

Example

If your FastAPI server has these endpoints:

@app.get("/users/{user_id}")
async def get_user(user_id: int):
    return {"id": user_id, "name": "John"}

@app.post("/users")
async def create_user(name: str, email: str):
    return {"id": 123, "name": name, "email": email}

gmcp will automatically create MCP tools:

  • get_users_user_id - Get a user by ID
  • create_users - Create a new user

Claude can then call these tools directly!

How It Works

  1. Fetch Schema: gmcp fetches the OpenAPI schema from /openapi.json
  2. Parse Endpoints: Converts each endpoint into an MCP tool definition
  3. Proxy Requests: When tools are called, gmcp makes HTTP requests to FastAPI
  4. Return Results: Responses are formatted and returned to Claude

Requirements

  • Python 3.10+
  • A running FastAPI server with OpenAPI enabled (default)

Development

Project Structure

gmcp/
├── src/
│   └── gmcp/
│       ├── __init__.py
│       └── server.py      # Main MCP server implementation
├── examples/
│   ├── sample_api.py      # Example FastAPI server
│   └── test_gmcp.sh       # Test script
├── pyproject.toml
└── README.md

Testing

See examples/ directory for a sample FastAPI server and test script.

Documentation

  • QUICKSTART.md - Get started in 5 minutes
  • AUTH.md - Authentication guide (Bearer, API keys, Basic auth)
  • USAGE.md - Detailed usage guide and troubleshooting

License

MIT

Metadata

Release files for gmcp 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gmcp 0.2.2
File Size Uploaded Provenance
gmcp-0.2.2.tar.gz 13.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for gmcp 0.2.2
File Interpreter ABI Platform
gmcp-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 21.3 kB

Release files / gmcp-0.2.2.tar.gz

Download URL gmcp-0.2.2.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2dfb351df7439041f77e532e6f3ffefa022930009e3b8785eddf05b596ee5312
BLAKE2b-256 checksum
How to use checksums
b2700cbf59c77dbbd7fbfd2448ab0ebb23b11fa5712500d4864c6bf0bad34e76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 31, 2026.

Transparency log

Release files / gmcp-0.2.2-py3-none-any.whl

Download URL gmcp-0.2.2-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4eef43fbe32611db93ac961bf2b4b79248480b27fa89fdcabf52a2de618ac6fd
BLAKE2b-256 checksum
How to use checksums
1558c4f9b4b12b5e384bba5db65cbbf974fe94359b29abcba79c474310e0a440
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 31, 2026.

Transparency log

Security for gmcp 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gmcp-0.2.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page