M
MCP Example
A simple example MCP project.
Created 2/1/2026
Updated 1 day ago
README
Repository documentation and setup instructions
LangGraph + MCP Demo
End-to-end demo that spins up:
- FastAPI service that also bootstraps an MCP server.
- MCP tools backed by Postgres (
get_user_balance,get_last_logins). - LangGraph agent that calls those MCP tools via the Model Context Protocol.
- Docker Compose orchestration for the API + Postgres.
Prerequisites
- Docker + Docker Compose
- (Optional) Python 3.11+ if running locally without containers
- OpenAI API key (or compatible endpoint) for the agent LLM
Quick start (Docker)
cp .env.example .env # set OPENAI_API_KEY
docker compose up --build
Services:
- API: http://localhost:8000
- MCP server (HTTP transport): http://localhost:9000
- Postgres: localhost:5432 (db:
mcp_demo, user:postgres, password:postgres)
API checks
- Health:
curl http://localhost:8000/health - Balance:
curl http://localhost:8000/balance/alice - Logins:
curl 'http://localhost:8000/logins/alice?limit=3' - Agent:
curl -X POST http://localhost:8000/agent -H 'Content-Type: application/json' -d '{"question":"What is Alice\'s balance and last 2 logins?"}'
Local dev without Docker
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # fill OPENAI_API_KEY
python -m app.main # runs FastAPI+MCP; uvicorn launched inside
Project layout
app/main.py– FastAPI app, spins MCP server on startup.app/mcp_server.py– MCP tool definitions (balance + logins).app/agent.py– LangGraph agent that consumes MCP tools.app/db.py/app/services.py– async DB access helpers.db/init.sql– schema + demo seed.docker-compose.yml/Dockerfile– container setup.
Notes
- MCP transport is
streaming-httpon port 9000 for simplicity. - The agent uses
gpt-4o-miniby default; override viaOPENAI_MODEL. - Database seeding happens automatically on startup.
Quick Setup
Installation guide for this server
Install Package (if required)
uvx mcp-example
Cursor configuration (mcp.json)
{
"mcpServers": {
"ehelvacikoylu-mcp-example": {
"command": "uvx",
"args": [
"mcp-example"
]
}
}
}