Skip to main content

traceguard-mcp

TraceGuard MCP Server —— 让任何支持 MCP 的客户端(Claude Desktop、Cursor、OpenCode、Claude Code) 在执行工具之前先问一句「这个动作允许吗」。

零依赖,本地运行,不联网。

安装

pip install traceguard-mcp
# 想用你自己的策略文件,再装核心:
pip install ai-traceguard

它暴露什么

工具 作用
traceguard_check(tool_name, args) 判断该工具调用是否被允许,返回 allowed / risk / reason
traceguard_report() 审计摘要(调用数 / 拦截数 / 链是否完好)

配置到 MCP 客户端

{
  "mcpServers": {
    "traceguard": {
      "command": "traceguard-mcp"
    }
  }
}

或用 Python 模块方式:

{
  "mcpServers": {
    "traceguard": {
      "command": "python",
      "args": ["-m", "traceguard_mcp.server"]
    }
  }
}

环境变量

变量 说明
TRACEGUARD_MCP_POLICY 策略文件路径(默认 policies/base.yaml,需装 ai-traceguard)
TRACEGUARD_MCP_DB 审计数据库路径(默认 traceguard-mcp.db)

怎么用

在 Agent 的工具分发循环里,执行任何有副作用的工具之前先调 traceguard_check:

res = mcp_call("traceguard_check", {"tool_name": name, "args": args})
if not res["allowed"]:
    return f"⛔ 被拦下:{res['reason']}"   # 把原因回传给模型
# 放行,执行真实工具

把 reason 回传给模型,它会自己改用安全做法,体验远好于直接报错。

实测

initialize  -> traceguard v0.1.0(协议 2024-11-05)
tools/list  -> traceguard_check, traceguard_report
check delete_file  -> {"allowed": false, "risk": "HIGH", "reason": "删除文件操作,策略阻断"}
check read_file    -> {"allowed": true,  "risk": "LOW"}

许可证

MIT

Metadata

Release files for traceguard-mcp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for traceguard-mcp 0.1.0
File Size Uploaded Provenance Actions
traceguard_mcp-0.1.0.tar.gz 4.5 kB Without provenance Details for traceguard_mcp-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for traceguard-mcp 0.1.0
File Interpreter ABI Platform Actions
traceguard_mcp-0.1.0-py3-none-any.whl Python 3 none any Details for traceguard_mcp-0.1.0-py3-none-any.whl

Total release size: 10.1 kB

Release files / traceguard_mcp-0.1.0.tar.gz

Download URL traceguard_mcp-0.1.0.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
026d5a818ee70074a794f1b61aa32e83d52eca04b5d57414ebc540c017ab9531
BLAKE2b-256 checksum
How to use checksums
6669d69edfe46ad5167b25fa77391f9070e6f973b5a3f3668cdb16186d85ead2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Release files / traceguard_mcp-0.1.0-py3-none-any.whl

Download URL traceguard_mcp-0.1.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
141c9568d48bd285645571de956a2ffbedf6d3797889a1094425922f8f6821d8
BLAKE2b-256 checksum
How to use checksums
ffb14e660859fdfec072eb3e2b1dac09e8334290cbc9228138639e0e4b495250
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.2

Security for traceguard-mcp 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page