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
settings - Spin 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
- -securityFlicense-qualityA production-ready MCP server built with FastAPI, providing an enhanced tool registry for creating, managing, and documenting AI tools for Large Language Models (LLMs).Last updated -13Python
- -securityFlicense-qualityA FastMCP server that provides natural language interaction with MS SQL databases, enabling users to query data, list tables, describe structures, and execute database operations through a conversational AI interface.Last updated -Python
- -securityAlicense-qualityA server that integrates the MCP library with OpenAI's API, allowing users to interact with various tools, such as the weather tool, through natural language queries.Last updated -PythonMIT License
- -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 -1PythonMIT License