pdxlab/trustmodel-mcp-server

GitHub: pdxlab/trustmodel-mcp-server

通过 Model Context Protocol 为 AI Agent 提供信任评估、红队测试和治理能力的 MCP 服务器。

Stars: 0 | Forks: 0

# TrustModel MCP 服务器 一个 [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) server,允许任何 AI agent 调用 [TrustModel](https://trustmodel.ai) 进行信任评估、安全/偏见分析以及端到端的 agentic trace 评估。 兼容 Claude Code、Cursor、Windsurf、Claude Desktop 以及任何其他兼容 MCP 的客户端。 [![npm](https://img.shields.io/npm/v/@trustmodel/mcp-server?color=3b5bfd&label=npm)](https://www.npmjs.com/package/@trustmodel/mcp-server) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE) [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-blue?logo=visualstudiocode)](https://insiders.vscode.dev/redirect/mcp/install?name=trustmodel&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40trustmodel%2Fmcp-server%22%5D%7D) [![Add to Cursor](https://img.shields.io/badge/Cursor-Add_MCP-000)](https://cursor.com/install-mcp?name=trustmodel&config=eyJjb21tYW5kIjoibnB4IC15IEB0cnVzdG1vZGVsL21jcC1zZXJ2ZXIifQ%3D%3D) ## 一键安装 - **VS Code / Cursor** — 点击上方的徽章(它们会直接配置 `npx -y @trustmodel/mcp-server`)。 - **Claude Desktop** — 从 [Releases](https://github.com/karlmehta/trustmodel-mcp/releases) 下载 `trustmodel.mcpb` 并将其拖入 Settings → Extensions(无需编辑 JSON)。使用 `./scripts/build-mcpb.sh` 在本地构建。 - **聚合器** — 也列在 [Smithery](https://smithery.ai/server/@trustmodel/mcp-server) 和 [Glama](https://glama.ai/mcp/servers) 上(本仓库中的 `smithery.yaml` / `glama.json`)。 ## 快速开始 ### 1. 获取 API key 在 [app.trustmodel.ai](https://app.trustmodel.ai) 注册并在 **Settings → API Keys** 下创建一个 API key。key 的格式为 `tm-{env}-{keyid}_{secret}`(例如 `tm-prod-abc12345_0123456789abcdef…`)。 ### 2. 配置你的 MCP 客户端 #### Claude Code ``` claude mcp add trustmodel \ --env TRUSTMODEL_API_KEY=tm-prod-xxxx_yyyy \ -- npx -y @trustmodel/mcp-server ``` #### Cursor / Windsurf 添加到你的 MCP 配置文件(`.cursor/mcp.json` 或等效文件)中: ``` { "mcpServers": { "trustmodel": { "command": "npx", "args": ["-y", "@trustmodel/mcp-server"], "env": { "TRUSTMODEL_API_KEY": "tm-prod-xxxx_yyyy" } } } } ``` #### Claude 桌面版 添加到 `~/Library/Application Support/Claude/claude_desktop_config.json` 中: ``` { "mcpServers": { "trustmodel": { "command": "npx", "args": ["-y", "@trustmodel/mcp-server"], "env": { "TRUSTMODEL_API_KEY": "tm-prod-xxxx_yyyy" } } } } ``` ## 环境变量 | 变量 | 必需 | 默认值 | 描述 | |---|---|---|---| | `TRUSTMODEL_API_KEY` | 否* | — | 你的 TrustModel API key (`tm-{env}-{keyid}_{secret}`)。*本地工具(`trustmodel_evaluate_local`, `trustmodel_govern`)不需要;校准的云端工具必需。 | | `TRUSTMODEL_TRACE_DIR` | 否 | `~/.trustmodel-mcp/traces/` | 流式 trace session 以 append-only JSONL 形式持久化的位置。Session 通过读取时重新水合(rehydrate-on-read)在服务器重启后依然存活。 | | `TRUSTMODEL_PROFILE` | 否 | `default` | 工具配置(profile)。`default` 仅公开常用工具;`security` / `advanced` / `all` 公开所有工具。参见 **工具配置**。 | | `TRUSTMODEL_ADVANCED_TOOLS` | 否 | `false` | 设置为 `true` 即可忽略 `TRUSTMODEL_PROFILE` 公开所有工具。 | | `TRUSTMODEL_AGT_DISCOVERY_ENABLED` | 否 | `false` | 启用接触文件系统的 Shadow Discovery 工具(`trustmodel_shadow_discovery_*`)。未设置时,这些工具会返回一个跳过报告。(仅在开启高级 profile 时相关。) | ## 工具配置 为了保持在 5-8 个工具的最佳实践预算内(更多的工具会降低 agent 的工具选择能力),服务器公开了一个小巧的 **default** 集合,并使高级工具可选择加入。 **Default profile(6 个工具)** — 常用工具: `trustmodel_evaluate_local` · `trustmodel_score` · `trustmodel_trace_start` · `trustmodel_trace_step` · `trustmodel_trace_finalize` · `trustmodel_govern` **Advanced** — 设置 `TRUSTMODEL_PROFILE=security`(或 `advanced` / `all`,或者 `TRUSTMODEL_ADVANCED_TOOLS=true`)以额外公开:`trustmodel_evaluate`(云端批处理)、`trustmodel_credits`、`trustmodel_upload_trace`、`trustmodel_evaluate_agent`、`trustmodel_score_agent`、`trustmodel_mcp_scan_server`、`trustmodel_shadow_discovery_*`、`trustmodel_redteam_*` 以及 `trustmodel_shadowai_*` — **总共 20 个工具**。 ``` claude mcp add trustmodel --env TRUSTMODEL_PROFILE=security -- npx -y @trustmodel/mcp-server ``` ## 工具 服务器跨越六个领域公开了 **18 个工具**。使用此表来选择正确的工具;完整的输入/输出文档如下。 | 工具 | 组 | 何时使用 | |---|---|---| | `trustmodel_evaluate` | Eval | 对模型(安全、偏见、准确性等)发起批处理信任评估;返回一个 `id` 用于轮询。 | | `trustmodel_score` | Eval | 为使用 `trustmodel_evaluate` 创建的评估获取状态/得分。 | | `trustmodel_credits` | Eval | 检查剩余的 API 额度余额。 | | `trustmodel_trace_start` | Agentic Trace | 在 agent 开始工作之前开启一个流式 trace session。 | | `trustmodel_trace_step` | Agentic Trace | 在 agent 运行时记录单个推理步骤、工具调用、工具结果或响应。 | | `trustmodel_trace_finalize` | Agentic Trace | 关闭 session、上传 trace,并自动创建 agent 评估运行。 | | `trustmodel_upload_trace` | Agentic Trace | 一次性操作:当你没有流式传输时,PUT 一个预先组装好的 trace JSON。 | | `trustmodel_evaluate_agent` | Agentic Trace | 针对已经上传的 trace `file_path` 创建 agentic 评估运行。 | | `trustmodel_score_agent` | Agentic Trace | 为 agentic 评估运行获取得分/评级。 | | `trustmodel_mcp_scan_server` | Security | 对第三方 MCP 服务器的工具列表进行安全扫描,以检测具有风险/可被滥用的工具。 | | `trustmodel_shadow_discovery_scan_paths` | Shadow Discovery | 扫描本地文件系统路径以发现未注册/shadow 的 AI 使用情况。 | | `trustmodel_shadow_discovery_fingerprint_keys` | Shadow Discovery | 检测并对磁盘上发现的 OpenAI/Anthropic API key 进行指纹识别。 | | `trustmodel_redteam_evaluate` | Red Team | 针对模型/endpoint 发起对抗性红队评估。 | | `trustmodel_redteam_results` | Red Team | 获取红队评估的结果。 | | `trustmodel_redteam_list_probes` | Red Team | 列出可用的红队探针/攻击类别。 | | `trustmodel_shadowai_scan` | Shadow AI | 启动 Shadow AI 扫描,以发现整个环境中未注册的 AI 使用情况。 | | `trustmodel_shadowai_results` | Shadow AI | 获取 Shadow AI 扫描的结果。 | | `trustmodel_shadowai_events` | Shadow AI | 流式传输 Shadow AI 扫描的检测事件。 | ### 经典评估 #### `trustmodel_evaluate` 针对指定的 AI 模型创建批处理评估运行。后端会运行一套全面的测试套件(安全、偏见、准确性、幻觉、推理等),并返回一个 `id`,你可以使用 `trustmodel_score` 来轮询。 **输入:** - `model_identifier` (字符串,必需) — 例如 `"gpt-4o"`、`"claude-sonnet-4-5"`。通过 `GET /sdk/v1/models/` 发现。 - `vendor_identifier` (字符串,必需) — 例如 `"openai"`、`"anthropic"`、`"google"`。 - `api_key` (字符串,可选) — 用于 BYOK 的供应商 API key。省略以使用 TrustModel 的平台 key。**不要**在这里传入 TrustModel API key — 它应该放在 `TRUSTMODEL_API_KEY` 环境变量中。 - `categories` (string[],可选) — 要评估的类别名称。仅在 `evaluation_type` 为 `"Custom"` 或 `"Score Only"` 时生效。 - `evaluation_type` (字符串,可选,默认为 `"Custom"`) — `"Custom"`、`"Score Only"`、`"Comprehensive"`、`"Limited"`、`"Quick Scan"` 其中之一。 - `application_type` (字符串,可选,默认为 `"generic"`) — `chatbot`、`knowledge-agent`、`creation-tool`、`document-repository`、`analysis-tool`、`automation-agent`、`generic`。 - `user_personas` (string[],可选,默认为 `["external-customer"]`) — `external-customer`、`internal-employee`、`technical-user`、`domain-expert`、`vulnerable-groups`、`generic` 中的任意项。 - `application_description` (字符串,可选)。 - `domain_expert_description` (字符串,可选) — 当 `user_personas` 包含 `"domain-expert"` 时。`"cross-domain"` (默认)、`"medical"`、`"commercial_banking"` 其中之一。 - `model_config_name` (字符串,可选) — 此运行的显示名称。 - `template_id` (UUID,可选)、`template_name` (字符串,可选) — 复用或重命名现有的评估模板。 #### `trustmodel_score` 获取通过 `trustmodel_evaluate` 创建的评估的详细信息(状态、完成百分比、得分)。 **输入:** - `evaluation_id` (整数或数字字符串,必需) — 由 `trustmodel_evaluate` 返回的 `id`。 #### `trustmodel_credits` 检查剩余的 API 额度余额。无需输入。 ### Agentic trace 评估 TrustModel 通过消费 AI agent 的执行 trace(思考、工具调用、工具结果、响应)并在 4 个类别中对它们进行评分来评估它们:`tool_use_accuracy`、`reasoning_quality`、`goal_completion`、`safety_compliance`。 有两种提交 trace 的方法 — **流式传输**(对于实时 agent 为首选)和 **一次性提交**(当你有一个预组装好的 trace 时)。 #### 流式捕获(首选) 开启一个 session,在 agent 工作时记录步骤,并在结束时 finalize。Finalize 会将其上传到云存储并自动创建评估运行。 ##### `trustmodel_trace_start` 开启一个新的 trace session。 **输入:** - `goal` (字符串,必需) — agent 试图实现的目标。 - `name` (字符串,必需) — 评估运行的显示名称。 - `agent_framework` (字符串,必需) — 例如 `"langchain"`、`"crewai"`、`"claude-code"`、`"custom"`。 - `agent_model` (字符串,可选) — 例如 `"gpt-4o"`、`"claude-sonnet-4-5"`。 - `user_query` (字符串,可选) — 原始用户 prompt(如果与 `goal` 不同)。 - `expected_outcome` (字符串,可选)。 - `metadata` (对象,可选) — 自由格式的传递 metadata。 **返回:** `{ trace_id, started_at }`。 ##### `trustmodel_trace_step` 将单个步骤附加到当前活动的 session 中。每个推理步骤、工具调用、工具结果或面向用户的响应调用一次。 **输入:** - `trace_id` (字符串,必需) — 来自 `trustmodel_trace_start`。 - `step_type` (枚举,必需) — `thought`、`think`、`tool_call`、`tool_result`、`observation`、`decision`、`error`、`human_input`、`response`、`final_answer` 其中之一。 - `content` (字符串,必需) — 用于该步骤的可读文本。允许空字符串。 - `tool_name` (字符串,可选)、`tool_args` (对象,可选) — 与 `tool_call` 一起使用。 - `tool_result` (字符串或对象,可选)、`tool_call_success` (布尔值,可选) — 与 `tool_result` 一起使用。 - `model_used` (字符串,可选)、`input_tokens` / `output_tokens` (整数,可选)、`duration_ms` (整数,可选)、`timestamp` (ISO 8601,可选)。 **返回:** `{ trace_id, step_number, steps_recorded }`。`step_number` 为自动分配。 ##### `trustmodel_trace_finalize` 关闭 session、上传 trace,并自动创建评估运行。 **输入:** - `trace_id` (字符串,必需)。 - `final_response` (字符串,)、`actual_outcome` (字符串,可选)、`goal_achieved` (布尔值,可选)、`success` (布尔值,可选)、`total_duration_ms` (整数,可选 — 如果省略,则根据步骤持续时间计算)。 - `goal` / `name` / `agent_framework` / `agent_model` / `expected_outcome` (均为可选) — 如果 agent 在 runtime 中获取了更多信息,则覆盖开始时的 metadata。 **返回(正常路径):** `{ trace_id, file_path, expires_in, step_count, evaluation_run_id, evaluation_status, evaluation_message }`。 **返回(上传成功但评估失败):** `{ trace_id, file_path, expires_in, step_count, evaluation_error }`。你可以通过 `trustmodel_evaluate_agent({ file_path, goal, name, agent_framework })` 重试评估而无需重新上传。 #### 一次性提交(预组装 trace) ##### `trustmodel_upload_trace` 将一个已经构建好的 trace JSON 对象 PUT 到云存储。返回一个 `file_path`,随后你可以将其传递给 `trustmodel_evaluate_agent`。 **输入:** - `trace` (对象,必需) — 完整的 `AgentTrace` JSON。 **返回:** `{ file_path, expires_in }`。 ##### `trustmodel_evaluate_agent` 针对之前上传的 trace 创建 agentic 评估运行。 **输入:** - `file_path` (字符串,必需) — 来自 `trustmodel_upload_trace` 或 `trustmodel_trace_finalize`。 - `goal` / `name` / `agent_framework` (字符串,必需)。 - `agent_model` / `expected_outcome` / `actual_outcome` (字符串,可选)。 - `goal_achieved` (布尔值,可选)。 - `frameworks` (字符串数组,可选) — 用于评估 trace 的合规性 framework 别名(例如 `["owasp-asi", "nist-ai-rmf"]`)。省略以跳过合规性评估。 **返回:** `{ evaluation_run_id, status, message }`。 ##### `trustmodel_score_agent` 获取 agentic 评估运行的详细信息(得分、评级、摘要)。 **输入:** - `evaluation_run_id` (整数或数字字符串,必需)。 当该运行在创建时使用了 `frameworks` 时,结果文本会附加每个 framework 的合规性摘要(别名、状态、合规性百分比以及报告 URL(如果有))。 ### 安全 #### `trustmodel_mcp_scan_server` 对第三方 MCP 服务器的工具列表运行 AGT 的 MCP 安全扫描器,以检测工具投毒、域名抢注、隐藏指令和跑路(rug-pull)模式。采用静态分析 — 无 LLM、无网络、确定性。旨在作为 agent 启用第三方 MCP 服务器之前的预注册检查。 **输入:** - `tools` (数组,必需) — 第三方服务器的工具定义(`name`、`description`、可选的 input schema)。 **返回:** 一份 `ScanReport`,包含总体状态(`ok` / `warning` / `blocked`)、检测到的最高严重程度以及每个工具的发现。 ### Shadow 发现 #### `trustmodel_shadow_discovery_scan_paths` 遍历本地文件系统路径,并检测配置文件(`agentmesh.yaml`、`crewai.yaml`、`mcp.json`、`claude_desktop_config.json` 等)、Dockerfile/compose 以及可选的源码中的 agent。它会根据调用者提供的注册表核对检测结果,并将未注册的返回为 **shadow agent**,同时附带 AGT 风险评分 + 修复建议。仅限静态分析。 **输入:** - `paths` (string[],必需) — 要扫描的本地路径。 - `registry` (数组,可选) — 用于核对的已知 agent(`did`、`name`、`owner` 等)。 #### `trustmodel_shadow_discovery_fingerprint_keys` 通过调用每个供应商的只读 models endpoint 来对一批供应商 API key(OpenAI / Anthropic)进行指纹识别 — 不会运行任何推理。可访问的 key 会被标记为高风险(可能存在凭证泄露);被撤销的 key 属于信息提示。Key 的具体内容永远不会被记录或返回 — 仅返回 `provider:****last4` 指纹。 **输入:** - `keys` (string[],必需) — 要探测的 API key。 ### Red Team #### `trustmodel_redteam_evaluate` 针对兼容 OpenAI 的目标运行对抗性红队评估。探针涵盖了与 OWASP LLM Top 10 (2025) 对齐的 8 个攻击类别 — prompt 注入、越狱、PII 提取、偏见诱导、幻觉触发等。 **输入:** - `model_name` (字符串,必需) — 例如 `"openai/gpt-oss-20b:free"`。 - `api_key` (字符串,必需)、`api_base_url` (字符串,必需) — 例如 `"https://openrouter.ai/api/v1"`。 - `categories` (string[],可选)、`severities` (string[],可选)、`metadata` (对象,可选)。 **返回:** 评估 `id` — 使用 `trustmodel_redteam_results` 进行轮询。 #### `trustmodel_redteam_results` 获取红队评估的状态、进度、总体得分、类别细分和严重程度分布。运行时显示部分进度,完成后提供完整摘要。 **输入:** - `evaluation_id` (整数或数字字符串,必需)。 #### `trustmodel_redteam_list_probes` 浏览红队探针库(仅 metadata — 不公开 payload)。按类别、严重程度或标签进行筛选。 **输入:** - `category` (字符串,可选)、`severity` (字符串,可选)、`tag` (字符串,可选)。 ### Shadow AI #### `trustmodel_shadowai_scan` 针对 GitHub orgs/repos 以及(可选)GCP projects 启动 Shadow AI Discovery 扫描。通过嗅探源代码中的 LLM SDK 使用情况(15 个库)并列出 Vertex AI endpoint、带有 AI 环境变量的 Cloud Run 服务以及 BigQuery ML 模型来检测未注册的 AI。 **输入:** - `github_orgs` (string[],可选)、`github_repos` (`owner/name` 的 string[],可选)、`gcp_projects` (string[],可选)、`metadata` (对象,可选)。 **返回:** 扫描 `id` — 使用 `trustmodel_shadowai_results` 进行轮询,使用 `trustmodel_shadowai_events` 对发现进行分页。 #### `trustmodel_shadowai_results` 获取 Shadow AI 扫描的状态、扫描过滤器、总事件数,以及按系统类型 / 按来源划分的发现聚合。 **输入:** - `scan_id` (整数或数字字符串,必需)。 #### `trustmodel_shadowai_events` 对单个发现事件进行分页 — 每一个都是一个被发现的 AI 系统,包含 `system_type`、`discovered_via`、证据以及稳定的 `system_id` 指纹。按 `system_type` 或 `source` 筛选。 **输入:** - `scan_id` (整数或数字字符串,必需),加上可选的 `system_type` / `source` 筛选器和分页。 ## 示例 — 流式 agent 捕获 ``` trustmodel_trace_start({ goal: "Book a flight from NYC to SF", name: "Flight booking agent", agent_framework: "claude-code", agent_model: "claude-sonnet-4-5" }) → { trace_id: "trace-abc123def456", started_at: "..." } trustmodel_trace_step({ trace_id, step_type: "thought", content: "Need to search flights first." }) → { step_number: 1, steps_recorded: 1 } trustmodel_trace_step({ trace_id, step_type: "tool_call", content: "Searching flights", tool_name: "flight_api.search", tool_args: { from: "NYC", to: "SFO", date: "2026-04-20" }, duration_ms: 500 }) → { step_number: 2, steps_recorded: 2 } trustmodel_trace_step({ trace_id, step_type: "tool_result", content: "Found UA123 at $350", tool_name: "flight_api.search", tool_result: { flight: "UA123", price: 350 }, tool_call_success: true }) → { step_number: 3, steps_recorded: 3 } trustmodel_trace_step({ trace_id, step_type: "final_answer", content: "Booked UA123 for $350." }) → { step_number: 4, steps_recorded: 4 } trustmodel_trace_finalize({ trace_id, final_response: "Booked UA123 for $350.", goal_achieved: true }) → { file_path: "agent-traces//_.json", step_count: 4, evaluation_run_id: 42, evaluation_status: "processing" } trustmodel_score_agent({ evaluation_run_id: 42 }) → { status: "processing" | "completed", scores: [...], grade, overall_score, ... } ``` ## 示例 — 真实的 agentic 流程 下面是一个真实场景:你要求 Claude Code 执行一项任务,同时用 TrustModel trace 捕获对其进行自我埋点。最后,TrustModel 会在工具使用准确性、推理质量、目标完成度和安全合规性方面对 agent 进行评分 — 在你将 agent 发布到生产环境之前为你提供一份信任报告。 ### 场景:研究 agent 将此 prompt 粘贴到 Claude Code(或任何连接了 TrustModel 的 MCP 客户端)中: ``` Research the pros and cons of using WebSockets vs Server-Sent Events for real-time notifications in a web app, while recording a TrustModel trace. Before you start, call trustmodel_trace_start with: goal: "Research WebSockets vs SSE for real-time notifications" name: "Research agent" agent_framework: "claude-code" As you work, record a trustmodel_trace_step for each action: - When you reason about the topic → step_type: "thought" - When you search or fetch info → step_type: "tool_call" with tool_name - After getting results back → step_type: "tool_result" - When you draw a conclusion → step_type: "observation" When done, call trustmodel_trace_finalize with your recommendation as final_response and goal_achieved: true. Print the evaluation_run_id so I can check the trust report. ``` ### 发生了什么 agent 在研究主题的同时会自我追踪每一个推理步骤、搜索和结论。一个典型的 session 如下所示: ``` trustmodel_trace_start({ goal: "Research WebSockets vs SSE...", name: "Research agent", ... }) → { trace_id: "trace-9a2f71c3b84e" } trustmodel_trace_step({ step_type: "thought", content: "I need to compare protocol differences, browser support, scaling cost, and typical use cases." }) → { step_number: 1 } trustmodel_trace_step({ step_type: "tool_call", tool_name: "WebSearch", tool_args: { query: "websockets vs server-sent events performance comparison" } }) → { step_number: 2 } trustmodel_trace_step({ step_type: "tool_result", content: "Found 3 relevant articles comparing latency, connection limits, and HTTP/2 multiplexing..." }) → { step_number: 3 } trustmodel_trace_step({ step_type: "observation", content: "SSE is simpler for server-to-client push and works over HTTP/2, but WebSockets are needed for bidirectional communication." }) → { step_number: 4 } ... (more research, comparisons, trade-off analysis) ... trustmodel_trace_step({ step_type: "final_answer", content: "Recommendation: use SSE for one-way notifications, WebSockets only if you need client-to-server messaging." }) → { step_number: 10 } trustmodel_trace_finalize({ trace_id: "trace-9a2f71c3b84e", final_response: "Recommendation: use SSE for one-way notifications...", goal_achieved: true }) → { file_path: "agent-traces//.json", evaluation_run_id: 42, evaluation_status: "processing" } ``` ### 评估结果 在 1-2 分钟后轮询 `trustmodel_score_agent({ evaluation_run_id: 42 })`。TrustModel 返回: ``` { "status": "completed", "overall_score": 7.6, "grade": "C", "scores": [ { "category": "tool_use_accuracy", "score": 100.0 }, { "category": "reasoning_quality", "score": 60.0 }, { "category": "goal_completion", "score": 70.0 }, { "category": "safety_compliance", "score": 80.0 } ], "summary": { "trust_dimensions": { "safety": 9.0, "fairness": 7.0, "privacy": 10.0, "transparency": 6.0, "robustness": 10.0, "accountability": 10.0 } } } ``` 还会生成一份包含详细发现的 PDF/HTML 报告,并可从 TrustModel dashboard 访问。 ### 为什么这很重要 每一个制定决策的 AI agent — 无论是审查代码、处理理赔还是筛选候选人 — 在投入生产环境之前都需要一个信任基线。这个流程为你提供了该基线,并且**完全无需更改你 agent 的核心逻辑**:只需用 `trace_start` 包裹它,在它工作时记录步骤,并在完成时执行 `trace_finalize`。剩下的交由 TrustModel 处理。 ## Trace 持久化 活动的 trace session 会以 append-only JSONL 的形式写入 `$TRUSTMODEL_TRACE_DIR/.jsonl`(默认为 `~/.trustmodel-mcp/traces/`)。磁盘是真实数据源;内存中的映射是一个可懒加载重新水合的缓存 — 因此 session 可以在 MCP 服务器重启后依然存活。在成功执行 `trustmodel_trace_finalize` 后,本地文件将被删除(trace 已经在云存储中了)。 空闲超过 30 分钟的 session 将被自动清理。每个服务器最多允许 100 个并发 session。 ## 仪表板 报告、评估历史和详细的 PDF/HTML 发现在 TrustModel dashboard 的 **[app.trustmodel.ai](https://app.trustmodel.ai)** 中提供。 ## 故障排除 | 症状 | 修复方法 | |---|---| | 服务器立即退出 / `TRUSTMODEL_API_KEY` 错误 | 在你客户端的 `env` 块中设置有效的 key (`tm-{env}-{keyid}_{secret}`)。在 [app.trustmodel.ai](https://app.trustmodel.ai) → **Settings → API Keys** 获取一个。 | | `trustmodel_shadow_discovery_*` 返回跳过报告 | 在服务器上设置 `TRUSTMODEL_AGT_DISCOVERY_ENABLED=true`。这些工具会接触本地文件系统,且默认处于关闭状态。 | | `npx` 找不到包 | 确保 Node 版本 ≥ 20.19 并运行 `npx -y @trustmodel/mcp-server` 以获取最新版本。 | | 客户端未列出工具 | 编辑配置后重启 MCP 客户端;确认 `command`/`args` 与上面的示例匹配。 | ## TrustModel 开源 此 MCP server 是 TrustModel OSS 工具包的一部分: - **CLI + SDK** — PyPI 上的 [`trustmodel`](https://github.com/karlmehta/trustmodel):本地信任评分、治理以及云端客户端。`pip install trustmodel`。 - **MCP server(此仓库)** — npm 上的 `@trustmodel/mcp-server`:将 TrustModel 公开给任何 MCP 客户端。 ## 许可证 MIT
标签:AI安全, Chat Copilot, GNU通用公共许可证, LLM治理, MCP服务器, MITM代理, Model Context Protocol, Node.js, 大模型评估, 时序数据库, 暗色界面, 自动化攻击