mcp-guardrails-kit

mcp-guardrails-kit

A prompt-injection-aware MCP server demonstrating guardrails for agentic tool use, including permission tiers, untrusted-content quarantine, and heuristic injection detection, with a fictional ticket-triage assistant.

Category
访问服务器

README

mcp-guardrails-kit

A prompt-injection-aware tool gateway and MCP server, built as a reference implementation for a fictional internal ticket-triage assistant.

This is a portfolio project, not a real product. It exists to demonstrate a concrete, testable pattern for building guardrails around agentic tool use — permission tiers, untrusted-content quarantine, and heuristic injection detection — around a small but real MCP server. The domain (support ticket triage) is generic and interchangeable; the guardrail patterns are the point.

What it demonstrates

  • Tool permission tiers with explicit confirmation. Every tool is registered as either read_only or sensitive. Sensitive tools (draft_reply, escalate_ticket) never execute a side effect until the caller passes confirmed=True — every caller in this codebase routes through the gateway's single invoke() entry point by construction (see docs/adr/0001-tool-permission-tiers.md for the honest caveat: this is a code-review convention, not a language-enforced boundary).
  • Quarantine of untrusted external content. fetch_external_page returns content fetched from a URL linked inside a ticket — a realistic prompt-injection vector. That content is wrapped and clearly delimited as data, never treated as instructions, before it is handed back to any caller or model.
  • Heuristic injection detection with a verdict. Quarantined (and other) text is scanned for injection patterns and returns one of ALLOW / FLAG / BLOCK. A BLOCK verdict replaces the payload with a safe refusal instead of the raw text (never a verbatim excerpt — even the scan's own matched_patterns are redacted to category labels before crossing a tool boundary). This is backed by a red-team test suite of known injection phrasings.
  • Three independent scan gates, not just one. A Supervisor walks a triage → draft → review → escalate pipeline. A ticket's own subject/body — the most directly attacker-controlled input in the system — is scanned right after lookup; the drafted reply is re-scanned before escalation is considered; and the escalation reason a model proposes is scanned again before escalate_ticket is ever called. A BLOCK at any of the three halts the pipeline right there.

Install & run

pip install -e ".[dev]"
pytest
ruff check .

No external services or API keys are required to install, test, or lint. See Scope & non-goals below for what pip install -e ".[live]" adds.

Connecting the MCP server to a real client

After pip install -e . (or pip install mcp-guardrails-kit once published), the mcp-guardrails-kit command is registered as a console entry point (see [project.scripts] in pyproject.toml) and speaks the MCP stdio protocol. Point a real MCP client at it — for example, Claude Desktop or Claude Code — with a config block like:

{
  "mcpServers": {
    "guardrails-kit": {
      "command": "mcp-guardrails-kit"
    }
  }
}

For Claude Desktop, this goes in claude_desktop_config.json; for Claude Code, add it via claude mcp add or the equivalent project-level MCP config. No arguments or environment variables are required for the default (non-live) mode.

Scope & non-goals

  • Heuristic injection detection is defense in depth, not a guarantee. It is a regex/keyword-based scanner, not a model-backed classifier. It will miss novel or sufficiently obfuscated phrasings — see docs/adr/0003-heuristic-injection-detection.md for the explicit tradeoff. The permission-tier and quarantine layers stay in effect even when detection fails; injection detection is one layer among three, not the only one.
  • There is no real ticketing system behind this. search_knowledge_base and lookup_ticket read from small in-memory fixtures. There is no database, no external ticketing API integration, and no persistence.
  • AnthropicModelClient is optional and live-only. It is gated behind the live extra (pip install -e ".[live]") and is never imported or exercised by the test suite or CI — tests and the default install path have zero dependency on any external LLM API or network access.
  • All data is in-memory and resets on restart. Drafts, escalations, and fetched external content are not persisted anywhere; restarting the server clears all state.

More

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选