Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add agents/netmindai-open/narranexus/mcps.pygit clone --depth 1 https://github.com/NetMindAI-Open/NarraNexusWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.01074 |
| Opus 5 | $0.00000 | $0.00537 |
| Sonnet 5 | $0.00000 | $0.00215 |
| Haiku 4.5 | $0.00000 | $0.00107 |
Grade A, and why
mcps.py scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 59 lines — stays where its author put it; the contents beside it link to each section on GitHub.
agents/mcps.py — MCP URL 管理与连接验证路由
2026-07-16 — 掩码只保留空格分隔的 auth scheme 前缀(review #111 🟢)
原 v[:6] 前缀对 X-API-Key: sk-live-… 这类无 scheme 值会露出真实密钥前缀。
现在仅当值形如 <Alpha> <rest>(Bearer/Basic…)保留 scheme,其余只留末 4 位。
2026-07-15 — headers 透传 + 掩码回显 + 修复 update 的 TypeError
- Create/Update 请求体接受
headers(dict);Update 语义=字段出现即整组覆盖 (model_fields_set判别),字段缺席不动。 - 读接口一律经
_masked_headers()掩码(v[:6]…v[-4:],短值全****)—— 明文 token 绝不出现在 GET 响应里。 - validate 端点把存储的 headers 传给
validate_mcp_sse_connection。 - 顺手修复既有 bug:原 PUT 路由用
name=/url=kwargs 调repo.update_mcp(mcp_id, updates: Dict),必然 TypeError——现在先组 updates dict 再调用(前端 enable/disable toggle 此前实际是坏的)。
为什么存在
Agent 可以通过 MCP(Model Context Protocol)协议连接外部工具服务器。每个 agent_id + user_id 组合可以配置多个 MCP URL,这些 URL 在 WebSocket 端点里被加载并传递给 AgentRuntime。这个路由提供 MCP 配置的完整 CRUD,以及 SSE 连接有效性验证。
上下游关系
- 被谁用:
backend/routes/agents/core.py聚合;前端 MCP 配置面板 - 依赖谁:
MCPRepository— MCP 记录的增删改查xyz_agent_context.repository.mcp_repository.validate_mcp_sse_connection— 实际的网络连通性测试
- 被间接用到:
backend/routes/websocket.py在每次 agent run 前通过MCPRepository加载已启用的 MCP URL
设计决策
URL 格式校验在路由层做
创建和更新时会检查 URL 必须以 http:// 或 https:// 开头。这是最简单的 URL 格式验证,没有用 Pydantic 的 HttpUrl 类型,因为 HttpUrl 在 Pydantic v2 里会对 URL 做规范化处理(去掉末尾斜杠等),可能影响 MCP 服务器的实际连接。
批量验证并行执行
validate-all 接口使用 asyncio.gather 并行验证所有 MCP 连接,而不是串行。这对有多个 MCP 的场景效率更高,但如果某个 MCP 验证超时时间较长,会阻塞所有结果返回。validate_mcp_sse_connection 内部应该有超时控制(在核心包里实现)。
所有权校验
更新、删除、验证操作都会先拿到 MCP 记录,检查 agent_id 和 user_id 是否匹配,再执行操作。这防止用户通过猜 mcp_id 操作别人的 MCP 配置。
Gotcha / 边界情况
- 创建后立即重查:
create_mcp在 insert 后调用repo.get_mcps_by_agent_user拿所有 MCP 再用id == record_id找到刚创建的那条。如果record_id和 MCP 列表对不上(比如 Repository 实现里add_mcp返回的是自增主键而不是mcp_id),created_mcp可能是 None,响应里mcp字段为空但success=True。 validate_mcp_sse_connection的错误处理:它返回(connected, error)元组,成功时error为 None,失败时connected为 False。验证结果会更新数据库里的connection_status字段,但不会影响is_enabled状态——连接失败的 MCP 仍然保持 enabled,只是状态标记为 "failed"。
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 59 lines · 0 tokens per session scan A fae3cd9783f0
mcps.py is an agent published in the GitHub repository NetMindAI-Open/NarraNexus (84 stars, last pushed 9d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,074 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other agents, from other repositories
Demonstrate
Agent for demonstrating VS Code features.
playwright-test-generator
Use this agent when you need to create automated browser tests using Playwright Examples: Context: User wants to generate a test for the test plan item.
.NET-Notebook-Migration-Agent
Expert .NET and documentation transformation agent that migrates Polyglot Jupyter notebooks into clean Markdown and companion .NET sample code.
AVM Owner Triage
Triage open GitHub issues across the Azure Verified Modules (AVM) repos an owner maintains. Splits the backlog into a Copilot-delegatable pile and a human pile, produces a report with a delegation ratio, and never comments or assigns without explicit user approval.
Ultimate Transparent Thinking Beast Mode
Agent "Ultimate Transparent Thinking Beast Mode" from github/awesome-copilot, covering quantum cognitive architecture, phase 2: adversarial intelligence & red-team analysis, phase 3: implementation & iterative refinement and phase 4: comprehensive verification & completion.
WinForms Expert
Support development of .NET (OOP) WinForms Designer compatible Apps.