hydris-diagnostic-mcp
hydris-mcp-integration
Hydris Pulse Bridge 跟踪,工作项 1:诊断 MCP 服务器骨架
将位于 Lite 单体仓库内的 lite/diagnostic_mcp/ 目录下。它
实现了 BRIDGE-2(每次调用的工厂授权)、BRIDGE-5
(每次调用的审计日志记录)和 NFR-4(安全性),并在结构上
强制实施 BRIDGE-1(只读工具集)。
参见 docs/scope.md 了解此处构建和未构建的内容,
以及 docs/decisions.md 了解此骨架所采取的
开放项决策(撤销延迟、审计接收器故障行为、非泄露错误形状、
工具集版本方案),等待 Nematullah 的批准。
架构
两个身份,保持分离(
diagnostic_mcp/auth/): 一个服务主体 JWT(只读作用域,独立验证)和一个 每次调用的用户上下文 JWT。服务令牌永远不会扩大访问权限。每次调用一个管道(
diagnostic_mcp/registry/pipeline.py): 验证两个身份,校验参数,检查用户的实时 工厂授权(无缓存),分发,审计日志记录结果 - 成功、 拒绝或错误 - 每次都是。注册时只读门控(
diagnostic_mcp/registry/tool_registry.py): 一个没有classification="read_only"或没有必需factory_id参数的工具在注册时被拒绝,而不是在调用时。FastMCP 用于模式通告,一个覆盖用于分发 (
diagnostic_mcp/server.py):tools/list像往常一样来自 FastMCP;tools/call在底层服务器被拦截一次,因此每个工具现在或将来 - 都通过同一个管道,无需每个工具的样板代码。
一个演示工具,
get_plant_overview(diagnostic_mcp/tools/plant_overview.py),由 Lite 的只读服务层的 内存存根支持,使用源文档中命名的确切固定数据(u-ops-alpha被授予fx-mbr-01;u-ops-beta被授予fx-beta-01)。
Related MCP server: system-monitor
快速开始
python -m venv .venv
.venv/Scripts/pip install -e ".[dev]" # .venv/bin/pip on macOS/Linux
cp .env.example .env # then edit the two secrets运行服务器:
set -a; source .env; set +a # or export the vars another way
python -m diagnostic_mcp.server默认情况下,它在 streamable-http 上监听 http://127.0.0.1:8765/mcp。
端到端验证
pytest -v # includes a real streamable-HTTP client/server round trip
ruff check .
mypy diagnostic_mcp tests
python scripts/check_no_write_imports.py要使用官方 MCP 客户端手动调用正在运行的服务器,请根据服务器运行的相同密钥生成一个 服务令牌和一个用户上下文令牌:
from diagnostic_mcp.auth.service_principal import issue_service_token
from diagnostic_mcp.auth.user_context import issue_user_context_token
service_token = issue_service_token("<LITE_MCP_SERVICE_TOKEN_SECRET>")
user_token = issue_user_context_token("<LITE_MCP_USER_CONTEXT_SECRET>", "u-ops-alpha", "org-alpha")
print(f"Authorization: Bearer {service_token}")
print(f"X-Pulse-User-Context: {user_token}")然后使用 factory_id=fx-mbr-01(已授权 - 成功)或 factory_id=fx-beta-01(未授权 - 拒绝,并且两次尝试都会记录到 audit.jsonl)调用 get_plant_overview。
工作项 1 完成定义
项目 | 状态 |
MCP 服务器在进程中注册,可通过 streamable-HTTP 访问 | 已完成 |
工具注册表具有只读分类,在启动时拒绝不符合要求的注册 | 已完成 |
服务主体颁发只读作用域,针对 15 个工具的最小集合编写作用域清单 | 已完成 - |
解析每次调用的用户上下文头,解析授权,在使用服务令牌之前拒绝调用 | 已完成 |
非泄露授权错误形状已商定并实现 | 已完成 - 参见 |
选择并记录了撤销延迟 | 已完成 - 参见 |
审计接收器写入所有六个必填字段,包括成功、失败和拒绝 | 已完成 |
传播并记录 Pulse 会话 ID,以实现 TC-BRIDGE-5.3 对等性 | 已完成 - |
与 Nematullah 商定并实现了审计接收器故障行为 | 已提议,等待批准 - 参见 O2 |
Lite 仓库中启用了无写入 CI 检查 | 仅占位 - 参见 |
从托管存储解析密钥,监听器上强制使用 TLS | 密钥:已完成(环境变量接口)。TLS:基础设施问题,参见 |
Related MCP Connectors
Read-only MCP server for AIStatusDashboard status, incidents, metrics, and fallback recommendations.
Guarded MCP server for agent-readable business truth, provenance, readiness, and discovery.
Read-only MCP access to a documented IT fleet: state, changes, posture. 15 tools.
MCP gateway with runtime security policy, tool-call-level control, and audit of agent actions.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server that provides secure, read-only access to the TrakSYS manufacturing analytics platform through entity-based tools and guided investigation prompts. It enables users to interact with manufacturing databases and perform data analysis via natural language.MIT
- AlicenseAqualityDmaintenanceA secure, read-only MCP server for AI-powered system monitoring. It provides real-time OS metrics, config discovery, and safe log tailing to enable autonomous infrastructure audits without shell access risks.41ISC
- AlicenseNot gradedqualityDmaintenanceA hardened MCP server exposing read-only orders tools to AI agents, with rigorous input validation and parameterized queries to prevent injection attacks.MIT
- FlicenseNot gradedqualityCmaintenanceA read-only MCP server that exposes a materials distributor database with four tools for querying tables, describing schemas, sampling rows, and running SELECT queries, secured by three independent layers to prevent any write operations.-