opensourceprojects.dev

A broadsheet for software that doesn't ask for your email

Transform your FastAPI into powerful MCP tools with fastapi-mcp!
GitHub RepoImpressions30

Project Description

View on GitHub

Turn Your FastAPI into MCP Tools with Zero Hassle

Why FastAPI-MCP?

If you've built a FastAPI service and wished you could expose its endpoints as Model Context Protocol (MCP) tools—without rewriting everything or wrestling with auth—this is for you.

fastapi-mcp lets you seamlessly convert your existing FastAPI routes into MCP-compatible tools, complete with built-in authentication. No boilerplate, no configuration hell—just drop it in and go.


What It Does

fastapi-mcp is a lightweight wrapper that:

  • Automatically exposes your FastAPI endpoints as MCP tools.
  • Handles auth out of the box (OAuth2, API keys, etc.).
  • Requires zero config for basic use cases—just decorate your routes.

Need to integrate with an AI agent framework or expose tools for a language model? This bridges the gap without extra work.


Why It’s Cool

1. Native FastAPI, No Magic

It doesn’t replace FastAPI—it extends it. Your existing middleware, dependencies, and OpenAPI docs still work.

2. Auth Included

No need to bolt on authentication later. MCP tools are secure by default.

3. Zero-Config for Most Cases

from fastapi_mcp import MCP  
mcp = MCP(app)  # That’s it. Your routes are now MCP tools.  

4. Works with AI/Agent Ecosystems

Great for:

  • Exposing tools to LLMs (e.g., ChatGPT plugins).
  • Building composable workflows.

How to Try It

  1. Install:

    pip install fastapi-mcp  
    
  2. Add it to your FastAPI app:

    from fastapi import FastAPI  
    from fastapi_mcp import MCP  
    
    app = FastAPI()  
    mcp = MCP(app)  
    
    @app.get("/hello")  
    def hello():  
        return {"message": "Now an MCP tool!"}  
    
  3. Check the docs for advanced use (custom auth, tool metadata, etc.).


Final Thoughts

fastapi-mcp is one of those rare tools that removes complexity instead of adding it. If you’re already using FastAPI and need MCP compatibility, this is a no-brainer.

Best part? It’s MIT-licensed, so you can rip out the code if needed.

Give it a spin:
→ GitHub
→ PyPI

P.S. Star the repo if you hate writing boilerplate. 🚀

GitHub Repository:

Back to Projects
Project ID: 1939964786495701169Last updated: July 1, 2025 at 10:30 AM