Trentina

io.github.crunchtools由 GitHub 账号 crunchtools 发布v0.5.0更新于 Nov 10, 2026

Secure MCP gateway and quarantine for AI agent traffic — three-layer prompt injection defense

概览

AI 生成的概览

本地 MCP 网关,位于 AI 代理与其后端之间,对流量做提示注入防护并执行运维方策略。

可以做什么
  • 按配置文件将代理调用路由到多个 MCP 后端,支持工具白名单、黑名单与工具固定
  • 在入口处用多层检查、本地分类器与无工具的隔离 LLM 筛查不可信内容,并提供字面与语义的请求和响应守卫
  • 通过内置内容工具抓取、读取、列目录与搜索网页内容,带出站守卫与文件限制
  • 压缩工具描述与 schema、精简响应以降低 token 消耗
  • 为网页客户端提供 OAuth 或静态 bearer 认证,并把 LLM 供应商密钥留在网关内
  • 记录调用审计日志,并允许运维代理提出授权请求由人工批准
适用场景
当助手要连接不可信的 MCP 服务器、网页内容或消息渠道,而你需要在其前面加一层注入防护、工具过滤与审计时使用。也适合需要为不同代理配置独立后端与凭据的场景。
运行要求
以容器镜像(podman)运行,需挂载 profiles YAML,并设置网关、配置路径及各配置文件 bearer 令牌等环境变量。L3 防护需要一个 LLM 供应商的 API 密钥(Gemini、OpenRouter、OpenAI、Anthropic 或 Ollama)。客户端通过 streamable HTTP 并携带 Authorization bearer 头连接。
安装前请注意
它会接触凭据:各配置文件的 bearer 令牌、LLM 供应商 API 密钥以及后端的 OAuth 授权,需妥善保护配置与环境变量。根据你允许的后端与授权,它可代代理写入、发送和推送,并会把出站请求与 git 推送重新发往列出的目标。对运维代理提出的授权应谨慎批准。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Trentina,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

[trentina: a medieval merchant ship anchored offshore while an inspector in a rowboat checks each crate of code before it reaches the harbor gate]

Trentina

Trentina sits between your AI agents and everything they touch: MCP servers, the web, Matrix, LLM providers and alerts. It stops prompt injection at every ingress — or at a trusted boundary you declare — shrinks what reaches the context window, and enforces a policy the agent cannot talk its way past. It is named after the 1377 trentino of Ragusa, where ships anchored offshore for thirty days before anyone came ashore: commerce keeps flowing, and nothing dangerous gets in.

[Demo: a request crosses Trentina's auth, policy, defense and minify stages; then, in a terminal, a 135-tool list is served as 6 tools, a recipe page with an injection in its comments is refused and then answered through redact, and a send to an outside address is refused while a draft goes through]

Why Trentina

  1. Security. Untrusted content crosses three independent layers at every ingress to the trust boundary, which can be federated with other instances: L1 deterministic checks, L2 a local classifier, L3 a quarantined LLM with no tools. Semantic request guards judge what goes out against a rule you write in English. What is and is not defended is in Coverage. Defense Pipeline · Benchmark · OWASP mapping

  2. Token savings. Hidden tools, short names, compacted schemas, compressed descriptions and minified responses: 52% fewer response bytes on production traffic. Compression · Tool Filtering

  3. Determinism. Literal request guards, literal response guards and allowlists are evaluated by the gateway, so an agent that ignores its instructions is stopped before the backend sees the call. Literal Request Guards · Literal Response Guards

  4. Authentication. Trentina is the OAuth authorization server for web clients such as claude.ai: dynamic client registration, a provisioned client, external issuers or a static bearer, chosen per profile. Authentication

  5. Architectural flexibility. A personal assistant, a coding agent and a swarm each get their own profile, with their own backends, defense mode and credentials — and an operator agent configures all of it through tools, with no shell; the five grants only a person should agree to, it proposes and you approve. Profiles · Operator · Approvals

Quick Start

bash
# The container image is the distribution: the L2 model, the parsers and# their process isolation ship in it. There is no PyPI package.podman run -d -p 127.0.0.1:8019:8019 \    -v ./profiles.yaml:/config/profiles.yaml:ro,Z \    -e TRENTINA_GATEWAY_ENABLED=true \    -e TRENTINA_PROFILES_PATH=/config/profiles.yaml \    -e TRENTINA_PROFILE_MYAGENT_TOKEN=your-token \    -e OPENROUTER_API_KEY=your-key -e TRENTINA_MODEL_PROVIDER=openrouter \    quay.io/crunchtools/trentina \    --transport streamable-http --host 0.0.0.0 --port 8019

L3 needs a key for one LLM provider. Any of Gemini, OpenRouter, OpenAI, Anthropic or Ollama works. A minimal profiles.yaml:

yaml
profiles:  myagent:    auth:      bearer_token_env: TRENTINA_PROFILE_MYAGENT_TOKEN    backends:      web:        url: "internal://web"         # Trentina's own content tools        tools_allow: ["*"]      gmail:        url: "http://gws-personal:8000/mcp"        tools_allow:                  # it may read and draft; you send          - search_gmail_messages          - get_gmail_message_content          - draft_gmail_message    defense:      enforcement: block

Then point Claude Code at it:

json
{  "mcpServers": {    "trentina": {      "type": "streamable-http",      "url": "http://localhost:8019/gateway/myagent/mcp",      "headers": { "Authorization": "Bearer your-token" }    }  }}

Documentation

DocumentDescription
MCP GatewayOne endpoint per profile: routing, tool names, circuit breakers
Per-Agent ProfilesProfile schema, modes, minifying, roles, multi-agent setup
Operator ProfileThe agent that installs and runs the gateway
ConfigurationEvery environment variable
AuthenticationStatic bearer, OAuth proxy with DCR or a provisioned client, delegated issuers
Backend OAuthEach profile signs in to OAuth-only backends with its own grant
Defense PipelineL1/L2/L3, modes, coverage and known gaps
BenchmarkDetection rates per layer and per L3 provider
CorporaEvery attack and benign set the defense is measured on
Prompt PacksThe judge's prompts tuned per model
Content Toolsfetch, read, dir, content, search, with an egress guard and file confinement
BlocklistA refused source stays refused
Tool FilteringAllowlists, denylists, glob patterns
Tool PinningA new or changed tool is held until approved
Tool DiscoveryFind/call or per-session loading for clients without tool search
Description CompressionDescription compression and schema compaction
Token RoutingResponse minifying (implemented); delegation (proposed)
Semantic Request GuardsA judge reads calls to listed tools against a policy in plain English
Semantic Response GuardsA judge reads listed tools' responses against a policy before delivery
Literal Request GuardsPer-tool argument validation
Literal Response GuardsPer-tool result validation
Audit LogCall recording, stats, monitoring
LLM Key ProxyingProvider keys kept inside the gateway
Matrix BridgeE2EE termination and two-way judging
Channel BridgesMore than one upstream per agent (RCS, ...) and the bridge wire contract
Matrix Reverse ProxyMatrix for agents on an isolated network
Client EgressA CONNECT tunnel to listed hosts for the agent's own client
Git TransportClone, fetch and push to listed repositories and branches
Stdio BackendsFront a stdio-only MCP server the host runs behind a socket
Stability tiersWhich features may change shape in a minor release, and how you are told
ApprovalsThe six grants an operator proposes and a person agrees to
FederationShare a profile with a second gateway: its tools mounted over a trusted link, scanned once
HTTP(S) EgressAn agent's outbound request judged and re-originated to a named destination
Deployment HardeningContainer flags, secrets, egress, the startup check
ProxiesEvery perimeter route as config under proxies:, the forward type, and route plugins
PluginsWrite, test, install and name your own transform plugins
Cockpit PluginLive defense pipeline dashboard
Internal: Gateway DesignOriginal design document, for contributors

Development

bash
pre-commit install          # wires the commit and push checks

CONTRIBUTING.md is the page for a person: the three commands, what each costs, and what an exit code means. The host needs only git, podman, pre-commit and gh — every check runs from python-sdlc, the same image CI runs. The demo is recorded by demo.yml; its fixtures are in docs/demo/.

License

AGPL-3.0-or-later

来源:README.md,提交 8aa0b36

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.5.0最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分