QMCP
A FastAPI-based Model Context Protocol server that enables tool discovery, invocation history, and human-in-the-loop interaction workflows. It features a Python client and CLI for managing automated tasks that require manual approval and persistence.
README
QMCP - Model Context Protocol Server
A spec-aligned Model Context Protocol (MCP) server built with FastAPI.
Features
- ✅ Tool Discovery - List available tools via
/v1/tools - ✅ Tool Invocation - Execute tools via
/v1/tools/{name} - ✅ Invocation History - Audit trail via
/v1/invocations - ✅ Human-in-the-Loop - Request human input via
/v1/human/* - ✅ Persistence - SQLite with SQLModel/aiosqlite
- ✅ Python Client -
qmcp.client.MCPClientfor workflows - ✅ Metaflow Examples - Ready-to-use flow templates
- ✅ Agent Framework - SQLModel schemas + mixins for agent types/topologies
- ✅ Structured Logging - JSON logs with structlog
- ✅ Request Tracing - Correlation IDs across requests
- ✅ Metrics - Prometheus-compatible
/metricsendpoint - ✅ CLI Interface - Manage via
qmcpcommand
Quick Start
# Install dependencies
uv sync
# Start the server
uv run qmcp serve
# Or with development reload
uv run qmcp serve --reload
See quickstart.md for a copy-paste walkthrough.
Adoption and Onboarding
Adoption checklist:
- Decide how the server is hosted (local, container, or VM) and who can reach it.
- Set
QMCP_HOST,QMCP_PORT, andQMCP_DATABASE_URLfor your environment. - Standardize
X-Correlation-IDvalues for audit trails across clients. - Decide how humans submit HITL responses (UI or API).
- Wire
/metricsinto your monitoring stack.
Onboarding path:
uv sync --all-extras- Run the end-to-end tutorial below.
uv run qmcp servefor local exploration.
End-to-End Tutorial (HITL approval workflow)
This tutorial mirrors the end-to-end test
tests/test_hitl.py::TestHITLWorkflow::test_complete_approval_workflow.
Copy and paste:
uv sync --all-extras
uv run pytest tests/test_hitl.py::TestHITLWorkflow::test_complete_approval_workflow -v
Client Library
from qmcp.client import MCPClient
with MCPClient(base_url="http://localhost:3333") as client:
# List tools
tools = client.list_tools()
# Invoke a tool
result = client.invoke_tool("echo", {"message": "Hello!"})
print(result.result)
# Human-in-the-loop
request = client.create_human_request(
request_id="approval-001",
request_type="approval",
prompt="Approve deployment?",
options=["approve", "reject"]
)
response = client.wait_for_response("approval-001", timeout=3600)
See docs/client.md for full API documentation.
CLI Commands
# Start the server
qmcp serve [--host HOST] [--port PORT] [--reload]
# List registered tools
qmcp tools list
# Show configuration
qmcp info
# Run tests with auto setup/teardown
qmcp test [-v] [--coverage] [TEST_PATH]
API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check |
/v1/tools |
GET | List available tools |
/v1/tools/{name} |
POST | Invoke a tool |
/v1/invocations |
GET | List invocation history |
/v1/invocations/{id} |
GET | Get single invocation |
/v1/human/requests |
POST | Create human request |
/v1/human/requests |
GET | List human requests |
/v1/human/requests/{id} |
GET | Get request with response |
/v1/human/responses |
POST | Submit human response |
/metrics |
GET | Prometheus metrics |
/metrics/json |
GET | Metrics as JSON |
Built-in Tools
- echo - Echo input back (for testing)
- planner - Create execution plans
- executor - Execute approved plans
- reviewer - Review and assess results
Development
# Install dev dependencies
uv sync --all-extras
# Run tests (with auto cleanup)
uv run qmcp test -v
# Run tests with coverage
uv run qmcp test --coverage
# Run linter
uv run ruff check .
Architecture
See docs/architecture.md for the full architectural overview.
The system follows a three-plane architecture:
- Client/Orchestration - Metaflow workflows (MCP client)
- MCP Server - FastAPI service (this project)
- Execution/Storage - Tools and database
Documentation
- Quickstart - Copy-paste setup and validation
- Overview - What and why
- Architecture - How and constraints
- Tools - Tool capabilities
- Client Library - Python client API
- Human-in-the-Loop - HITL guide
- Agent Framework - Agent schemas and mixins
- Deployment - Production deployment guide
- Contributing - Development guidelines
- Roadmap - Development phases
Example Flows
See examples/flows/ for Metaflow integration examples:
- simple_plan.py - Basic tool invocation
- approved_deploy.py - HITL approval workflow
- local_agent_chain.py - Local LLM plan -> review -> refine with SQLModel artifacts
- local_qc_gauntlet.py - Local LLM QC checklist/task/gate builder
- local_release_notes.py - Local LLM release notes and doc update suggestions
For local LLM flows, install extras with uv sync --extra flows.
Start uv run qmcp serve when --use-mcp True to enable MCP calls.
On Windows, prefer running flows in a Linux container to avoid platform-specific
Metaflow dependencies.
Docker runner (recommended on Windows):
docker compose -f docker-compose.flows.yml build
docker compose -f docker-compose.flows.yml run --rm flow-runner \
examples/flows/local_agent_chain.py run --use-mcp True --goal "..."
Set MCP_URL and LLM_BASE_URL (or pass --mcp-url / --llm-base-url) when
running in Docker, e.g. http://host.docker.internal:3333.
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.