Serves as the foundation for the MCP server, exposing CRUD endpoints through FastAPI-MCP that allows AI agents to interact with the item database
Optional database backend that can be configured to replace the default SQLite database
Integrates with OpenAI's API for powering the PydanticAI agents that interact with the MCP server
Optional database backend that can be configured to replace the default SQLite database
Suggested for monitoring the MCP server in production environments
Used for data validation and schema definition in the API, enabling structured input/output for the MCP tools
Provides enhanced terminal output for the client scenario runner that tests the MCP server functionality
Provides ORM capabilities for database operations, allowing the MCP server to perform CRUD operations on items in the database
Serves as the default database backend for storing items, with support for swapping to other database systems
FastAPI CRUD MCP
A minimal CRUD API for “items,” built with FastAPI and exposed as MCP tools via FastAPI-MCP. Includes a scenario-driven client harness using PydanticAI and Rich.
🚀 Features
FastAPI: high-performance HTTP API
SQLAlchemy + Pydantic: ORM models + input/output schemas
FastAPI-MCP: auto-expose your endpoints as MCP tools (
/mcp/tools
,/mcp/events
)Rich CLI: beautiful, colored terminal output for scenario runs
Scenario Runner: client harness that drives and validates your API via PydanticAI agents
SQLite backend for demo; easily swap to PostgreSQL, MySQL, etc.
📦 Project Layout
⚙️ Installation & Setup
Clone & enter directory
Create & activate a virtualenv
Install dependencies
Environment variables Copy the example and adjust if needed:
🏃 Running the Server
API docs →
http://localhost:8000/docs
OpenAPI JSON →
http://localhost:8000/openapi.json
🤖 Running the Scenario Client
This harness will:
Load your
.env
settingsSpin up a PydanticAI agent against
MCP_HOST_URL
Execute each scenario (create/list/get/update/delete)
Display rich panels for prompts & outputs
🚨 Notes & Tips
Switch DB: edit
backend/server/db.py
for PostgreSQL or MySQL.Add auth: protect
/mcp
or/api
via FastAPI dependencies.Extend scenarios: drop new entries into
backend/client/scenarios.py
.Production: add Alembic for migrations, and monitor with Prometheus.
🤝 Contributing
Fork 🔱
Create a feature branch:
Commit & push:
Open a PR and we’ll review!
📄 License
This project is MIT-licensed—see the LICENSE file for details.
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
A minimal CRUD API for items that exposes FastAPI endpoints as MCP tools, enabling natural language interaction with a database through PydanticAI agents.
Related MCP Servers
- -securityAlicense-qualityA zero-configuration tool that automatically converts FastAPI endpoints into Model Context Protocol (MCP) tools, enabling AI systems to interact with your API through natural language.Last updated -1MIT License
- -securityFlicense-qualityProvides programmatic access to Pydantic-AI documentation as an MCP server, enabling retrieval of specific documents, listing of topics, and access to changelog information.Last updated -2
- -securityAlicense-qualityA REST API built with FastAPI that exposes endpoints via Model Context Protocol (MCP), allowing clients to interact with CRUD operations through MCP interfaces.Last updated -MIT License
- -securityFlicense-qualityA sample FastAPI project that implements the Model Context Protocol (MCP), allowing AI assistants to connect to a PostgreSQL database and manage notes through natural language interactions.Last updated -