QMCP

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.

Category
访问服务器

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.MCPClient for 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 /metrics endpoint
  • CLI Interface - Manage via qmcp command

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, and QMCP_DATABASE_URL for your environment.
  • Standardize X-Correlation-ID values for audit trails across clients.
  • Decide how humans submit HITL responses (UI or API).
  • Wire /metrics into your monitoring stack.

Onboarding path:

  1. uv sync --all-extras
  2. Run the end-to-end tutorial below.
  3. uv run qmcp serve for 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:

  1. Client/Orchestration - Metaflow workflows (MCP client)
  2. MCP Server - FastAPI service (this project)
  3. Execution/Storage - Tools and database

Documentation

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

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选