AgentGuard MCP Server
Provides policy-driven runtime authorization and security evaluation for MCP-based agents, including MCP streaming HTTP gateway, mock MCP servers, deterministic agent demos, and audited tool invocation with redacted PostgreSQL audit chains.
README
AgentGuard
AgentGuard is a policy-driven runtime authorization and security evaluation platform for MCP-based agents.
The repository has been scaffolded from AgentGuard_迭代开发计划书.md. Implementation begins with iteration 0: architecture, threat modeling, security boundaries, and the engineering baseline.
The executable iteration plan is documented in docs/week-0-development-plan.md.
Iteration 0 is complete; verification evidence is recorded in docs/week-0-completion-report.md.
The executable iteration-1 plan is documented in docs/week-1-development-plan.md.
Iteration 1 day-1 compatibility and contract evidence is recorded in docs/week-1-day-1-report.md.
Iteration 1 day-2 Mock MCP Server evidence is recorded in docs/week-1-day-2-report.md.
Iteration 1 day-3 Gateway lifecycle and proxy evidence is recorded in docs/week-1-day-3-report.md.
Iteration 1 day-4 audit persistence and deterministic Agent evidence is recorded in docs/week-1-day-4-report.md.
Iteration 1 is complete; final acceptance evidence is recorded in docs/week-1-completion-report.md.
Local development
Requirements: Python 3.12 and Docker Desktop with Docker Compose.
Copy-Item .env.example .env
python -m pip install -e ".[dev]"
docker compose up -d
python -m alembic upgrade head
python scripts/seed_dev_data.py
python scripts/check_infrastructure.py
python -m uvicorn main:app --reload
The Agent-facing MCP Streamable HTTP endpoint is http://127.0.0.1:8000/mcp/. The trailing slash is required by the mounted ASGI route. In baseline mode it exposes only the seven namespaced tools configured in config/mock-servers.yaml.
Run either deterministic LangGraph demo without an LLM key:
python -m agent_demo.cli get_order --order-id ORD-N-1001
python -m agent_demo.cli read_faq
Each successful call returns a trace_id. Inspect its redacted PostgreSQL audit chain with:
python scripts/show_trace.py <trace-id>
Run the complete non-interactive Week 1 acceptance chain with one command:
python -m scripts.week1_smoke
The smoke applies migrations, seeds fixed development references, checks PostgreSQL, Redis and MCP readiness, discovers all seven tools, runs both Agent tasks, and verifies their audit chains.
Week 1 tool catalog
file.delete_file
file.list_directory
file.read_file
notify.draft_message
notify.send_message
order.get_order
order.refund_order
A rejected MCP call returns only a stable public error and trace reference, for example:
{
"error_code": "INVALID_TOOL_ARGUMENTS",
"message": "Tool arguments are invalid.",
"retryable": false,
"trace_id": "<gateway-generated-uuid>"
}
Baseline authorization boundary
baseline_allowlist is a temporary development/test control, not a production authorization system. It has no JWT authentication, identity-aware discovery, RBAC, ABAC, policy evaluation, risk engine, or approval workflow. Production mode rejects baseline startup; audit records explicitly label it, and the baseline execution path must be removed after formal authorization is implemented in Weeks 2–5.
Quality checks:
python -m ruff check .
python -m ruff format --check .
python -m mypy gateway mcp_servers agent_demo main.py scripts
python -m pytest
Stop local services without deleting their data:
docker compose down
.env.example contains development-only placeholders. Production mode rejects the known demo secrets. PostgreSQL and Redis are bound to loopback for host-based development; Mock MCP Servers added in later iterations must remain on an internal Docker network and expose no host ports.
The development ports are 127.0.0.1:55432 for PostgreSQL and 127.0.0.1:56379 for Redis to avoid collisions with common local defaults. They use a dedicated development bridge while container-to-container data traffic stays on data_internal; remove host publishing when the Gateway itself is containerized.
Repository layout
gateway/: MCP proxy, identity, policy, risk, approval, audit, registry, and scanner components.mcp_servers/: mock order, file, notification, and web-content MCP servers.agent_demo/: example agent integration.policies/: policy-as-code definitions.frontend/: approval, audit, and server-admission interfaces.tests/: unit, integration, and security evaluation cases.scripts/: evaluation and operational scripts.docs/: architecture, threat model, security boundaries, onboarding, and reports.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。