fastapi-ai-mcp-boilerplate
Provides a system health tool that queries the Docker environment and reports runtime status such as the Python version and SQLite health.
Powers the conversational AI agent with OpenAI models for generating responses and maintaining context.
Provides persistent conversation memory and allows the system health tool to report SQLite status.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@fastapi-ai-mcp-boilerplatecheck the system health and database status"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐ FastAPI AI-Augmented Architecture Boilerplate
A production-ready, out-of-the-box template for building asynchronous AI microservices using Python 3.12, FastAPI, and the Model Context Protocol (MCP).
โก Core Features
Asynchronous API: Built on FastAPI and Uvicorn for maximum throughput.
Conversational AI Agent: Pre-configured with OpenAI and SQLite for built-in memory and context persistence.
Model Context Protocol (MCP): Exposes a native SSE server for external AI clients (Cursor, Claude Desktop) to autonomously execute backend tools.
Containerized Infrastructure: Fully Dockerized for zero-friction local development and deployment.
Related MCP server: Streamable HTTP MCP Server
๐ Quick Start
1. Configure the Environment
Create a .env file in the root directory and add your AI provider API key:
echo "OPENAI_API_KEY=sk-your-key-here" > .env
2. Spin up the Infrastructure
docker-compose up -d --build
The FastAPI server will be available at http://localhost:8000.
๐งช Testing the Architecture
Once your Docker containers are running, you can immediately verify both the AI memory persistence and the MCP tool execution.
1. Testing the Conversational API
We will test if the AI can remember context using the SQLite database.
Step A: Initiate the Conversation
curl -X POST http://localhost:8000/api/chat \
-H "Content-Type: application/json" \
-d '{"message": "My favorite framework is FastAPI."}'
Note the conversation_id returned in the JSON response.
Step B: Test Context Memory Pass the ID back to the server to verify database persistence:
curl -X POST http://localhost:8000/api/chat \
-H "Content-Type: application/json" \
-d '{
"message": "What did I say my favorite framework was?",
"conversation_id": "PASTE_YOUR_ID_HERE"
}'
2. Testing the MCP Server (System Health Tool)
The most professional way to test an MCP Context Provider without an IDE is using the official open-source MCP Inspector.
Step A: Run the Inspector Run this command in your local terminal (requires Node.js):
npx @modelcontextprotocol/inspector http://localhost:8000/mcp/sse
Step B: Execute the Tool
The inspector will open a debugging dashboard in your browser.
Navigate to the Tools tab.
You will see the
system_healthtool automatically listed via the server's handshake.Click Execute to watch the MCP server query the Docker environment and return the Python version and SQLite health status in real-time.
๐ Connecting to Cursor / Claude Desktop
To utilize this backend as a context provider in your daily development:
Open your AI client's MCP configuration settings.
Add a new MCP server connection.
Select the SSE (Server-Sent Events) transport method.
Set the URL to:
http://localhost:8000/mcp/sse
This server cannot be deployed
Maintenance
Related MCP Connectors
AI Reasoning Cache & Consensus Layer with 11 MCP tools via Streamable HTTP.
Exposes FEDLIN's public security scanners as agent-callable tools over Streamable HTTP.
Public agentic AI doctrine tools plus authenticated architecture, design, and spec validators.
MIND MCP Server โ 31 tools. Persistent AI memory: knowledge graph, LIFE tasks, CRM, 50+ models.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Server-Sent Events implementation using FastAPI framework that integrates Model Context Protocol (MCP), allowing AI models to access external tools and data sources like weather information.51MIT
- -licenseNot gradedqualityNot gradedmaintenanceImplements a Model Context Protocol server that enables streaming communication between Azure OpenAI GPT-4o and tool services, allowing for real-time intelligent tool usage via Server-Sent Events.-
- FlicenseNot gradedqualityDmaintenanceA standalone MCP server that exposes API endpoints as tools for AI assistants, using SSE transport.-
- FlicenseNot gradedqualityDmaintenanceMCP server exposing a pet store API as tools for AI assistants, supporting HTTP operations via SSE transport.-