Mcp Gateway

io.github.authzx由 GitHub 账号 authzx 发布v1.0.1更新于 Oct 24, 2026

AuthzX MCP Gateway — policy-enforcing proxy between AI agents and MCP servers

已验证STDIO仅桌面开发者工具安全与监控

概览

AI 生成的概览

一个策略执行网关,位于 AI 智能体与其他 MCP 服务器之间,在转发前对每次工具调用进行授权检查。

可以做什么
按网关配置文件代理下游 MCP 服务器,让客户端通过网关而非直连使用其工具。拦截每次工具调用并按授权策略检查后再转发,本地模式使用本地代理与 .rego 策略文件,云端模式使用云端 API。将每次调用以结构化 JSON 记录主体、工具名、参数与决策。可通过 stdio 服务单个桌面智能体,或通过 HTTP 以按调用方的令牌与主体服务多个调用方。可在命令行列出下游工具并生成初始策略文件。
适用场景
当助手连接的 MCP 服务器工具可能读取数据库、删除文件或执行 SQL,而你需要每次调用在执行前经过策略检查并留下审计记录时使用。也适合让多个具有不同身份的智能体共用一个受管控的网关。
运行要求
以 npm 包形式在本地通过 stdio 运行,启用后也可通过 HTTP 运行。需要网关配置文件指定要启动的下游服务器和主体身份。本地模式需要安装 Vengtoo Agent 和 .rego 策略文件;云端模式需要云端 URL 和 API 密钥,可通过环境变量提供。HTTP 模式在绑定非回环地址时需要调用方令牌。
安装前请注意
网关信任其自身声明的主体,按调用方的令牌映射必须保留在自身配置中,绝不能改为从客户端提供的请求头推导。未配置调用方认证时绑定非回环接口会被拒绝,除非用环境变量明确允许未认证端点。云端模式会把授权请求和 API 密钥发送给第三方服务。它会启动并代理下游服务器,策略配置不当仍可能放行破坏性调用。

安装

在 SourceWeft 中

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

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Vengtoo MCP Gateway

[License] [Node] [npm]

Authorization gateway for AI agents and MCP tool calls.

Open-source. Drop-in. Works with any MCP client.

Why

AI agents connected to MCP servers can call any tool they have access to: read your database, delete files, execute arbitrary SQL. Vengtoo MCP Gateway puts a policy enforcement point between the agent and those tools, so every call is authorized before it executes.

What it does

  • Sits between MCP clients (Claude Code, Cursor, VS Code, GitHub Copilot) and any MCP server
  • Intercepts every tool call and checks authorization before forwarding
  • Two modes: cloud (Vengtoo Cloud API) and local (Vengtoo Agent + .rego policy file)
  • Full audit trail of every tool invocation: subject, tool name, arguments, and decision are logged as structured JSON:
json
{"ts":"2026-05-25T10:03:11.482Z","level":"info","msg":"mcp_tool_call","subject":"agent:ai-assistant","tool":"database__query","allowed":true,"latency_ms":0.8}

Quick Start

  1. Install and start the Vengtoo Agent. The agent runs locally and evaluates your authorization policy; no cloud account needed.
bash
go install github.com/vengtoo/agent/cmd/agent@latestvengtoo-agent --policy ./policy.rego

Create a policy.rego to define what your agent can do:

rego
package vengtoo.mcp
default allow := false
# Allow read-only toolsallow if { input.resource.name == "database__query" }allow if { input.resource.name == "database__list_tables" }
# Allow writes, but block destructive SQLallow if {    input.resource.name == "database__execute"    not contains(lower(input.resource.attributes.sql), "drop")    not contains(lower(input.resource.attributes.sql), "delete from")}

See demo/policies/ for more examples including Kubernetes namespace protection.

  1. Create a gateway.config.json:
json
{  "vengtoo": {    "agentUrl": "http://127.0.0.1:8181"  },  "subject": "agent:ai-assistant",  "servers": {    "database": {      "command": "node",      "args": ["./my-database-mcp-server.js"]    }  }}
  1. Add to your MCP client (e.g. Claude Code):
bash
claude mcp add --transport stdio vengtoo-gateway -- \  npx vengtoo-mcp-gateway --config /path/to/gateway.config.json

Configuration

Config schema

FieldTypeRequiredDescription
vengtoo.agentUrlstring*URL of local Vengtoo Agent (local mode)
vengtoo.cloudUrlstring*URL of Vengtoo Cloud API (cloud mode)
vengtoo.apiKeystringAPI key from Vengtoo Cloud (or set VENGTOO_API_KEY env var)
vengtoo.timeoutMsnumberAuthorization request timeout (default: 5000)
subjectstringyesIdentity of the agent making tool calls
subjectTypestringSubject type (default: "agent")
resourceTypestringResource type for authorization checks (default: "mcp_tool")
serversobjectyesMap of downstream MCP servers to proxy
transportstringCaller transport: "stdio" (default) or "http", see Transport
httpobjectHTTP transport settings (used when transport is "http")

* Provide either agentUrl (local mode) or cloudUrl (cloud mode).

Each entry in servers has:

FieldTypeRequiredDescription
commandstringyesCommand to spawn the MCP server
argsstring[]Command arguments
envobjectAdditional environment variables

Modes

Cloud mode

Connect to Vengtoo Cloud for managed policies:

json
{  "vengtoo": {    "cloudUrl": "https://api.vengtoo.com/access/v1/evaluation",    "apiKey": "vgt_..."  },  "subject": "agent:prod-assistant",  "servers": {    "database": {      "command": "node",      "args": ["./db-server.js"]    }  }}

Local mode

Run the Vengtoo Agent locally with a .rego policy file for offline, self-contained authorization:

bash
# Start the agent with your policyvengtoo-agent --policy ./policy.rego
json
{  "vengtoo": {    "agentUrl": "http://127.0.0.1:8181"  },  "subject": "agent:dev-assistant",  "servers": {    "database": {      "command": "node",      "args": ["./db-server.js"]    }  }}

Transport

The gateway exposes its (policy-enforced) tools to callers over one of two transports.

stdio (default)

Runs as a local subprocess speaking MCP over stdin/stdout: the right choice for a single desktop agent (Claude Desktop, Cursor, Claude Code). No network surface.

HTTP (remote)

Runs a Streamable HTTP MCP server at a URL, so a remote agent (or many concurrent agents) can share one governed gateway. Enable it with --http (or "transport": "http" in the config):

bash
vengtoo-mcp-gateway --config gateway.config.json --http --port 8808
json
{  "vengtoo": { "cloudUrl": "https://api.vengtoo.com/access/v1/evaluation", "apiKey": "vgt_..." },  "subject": "agent:prod-assistant",  "transport": "http",  "http": {    "port": 8808,    "host": "0.0.0.0",    "path": "/mcp",    "authTokens": ["<caller-token>"],    "allowedHosts": ["gateway.example.com"]  },  "servers": { "database": { "command": "node", "args": ["./db-server.js"] } }}

HTTP config (http.*):

FieldTypeDefaultDescription
portnumber8808TCP port to listen on
hoststring127.0.0.1Interface to bind; 0.0.0.0 accepts remote connections
pathstring/mcpURL path of the MCP endpoint
callersobject[]-Per-caller identity: { "token": "...", "subject": "agent:claude" }; each bearer token authorizes as its own subject
authTokensstring[]-Anonymous bearer tokens; grant access, run as the global subject
allowedHostsstring[]-Enables DNS-rebinding protection; rejects requests with an unlisted Host
allowedOriginsstring[]-Enables DNS-rebinding protection; rejects requests with an unlisted Origin

Per-caller identity. Give each agent its own token and subject, and your policies (and audit trail) see each caller's real identity through one shared gateway:

json
"http": {  "port": 8808,  "callers": [    { "token": "<claude-token>", "subject": "agent:claude" },    { "token": "<cursor-token>", "subject": "agent:cursor" }  ]}

Also settable via VENGTOO_GATEWAY_HTTP_CALLERS="<token>=agent:claude,<token>=agent:cursor". Sessions are bound to the token that opened them: a different caller presenting another caller's session id gets a 401, so identities cannot cross sessions. Tokens listed in authTokens (or callers omitted entirely) run as the config's global subject.

Safety: the gateway refuses to bind a non-loopback interface with no caller auth (callers or authTokens). Either configure tokens, or set VENGTOO_GATEWAY_ALLOW_UNAUTHENTICATED=true to knowingly expose an open endpoint. An unauthenticated GET /healthz liveness probe is always served.

⚠️ Security: Vengtoo trusts whichever subject this gateway asserts. The callers token→subject mapping above (owned by this gateway's own config) is the correct pattern; it is NOT the same as trusting a client-supplied header. Never change this to derive the subject from a header/field a calling client sends; that would let any caller claim to be any subject and inherit its permissions within your tenant. If you front this gateway with another reverse proxy, make sure that proxy cannot be made to forward an arbitrary caller-chosen bearer token or subject.

CLI Flags

FlagDescription
--config <path>Path to gateway config file (default: ./gateway.config.json)
--httpServe over HTTP instead of stdio
--port <n>HTTP listen port (default: 8808; implies --http-compatible config)
--host <h>HTTP bind interface (default: 127.0.0.1)
--path <p>HTTP endpoint path (default: /mcp)
--list-toolsList all tools from configured downstream servers and exit
--generate-policy [path]Generate a starter .rego policy file for the configured tools (default: policy.rego)

Environment overrides: VENGTOO_API_KEY, VENGTOO_AGENT_URL, VENGTOO_SUBJECT, VENGTOO_GATEWAY_TRANSPORT (http), VENGTOO_GATEWAY_PORT / PORT, VENGTOO_GATEWAY_HOST, VENGTOO_GATEWAY_PATH, VENGTOO_GATEWAY_HTTP_TOKENS (comma-separated), VENGTOO_GATEWAY_ALLOW_UNAUTHENTICATED.

MCP Client Setup

The gateway runs as a stdio MCP server. Point your MCP client at it instead of the downstream server directly.

Claude Code

bash
claude mcp add --transport stdio vengtoo-gateway -- \  npx vengtoo-mcp-gateway --config /path/to/gateway.config.json

Cursor

Add to .cursor/mcp.json:

json
{  "mcpServers": {    "vengtoo-gateway": {      "command": "npx",      "args": ["vengtoo-mcp-gateway", "--config", "/path/to/gateway.config.json"]    }  }}

Claude Desktop

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

json
{  "mcpServers": {    "vengtoo-gateway": {      "command": "npx",      "args": ["vengtoo-mcp-gateway", "--config", "/path/to/gateway.config.json"]    }  }}

VS Code / GitHub Copilot

Add to .vscode/mcp.json:

json
{  "servers": {    "vengtoo-gateway": {      "type": "stdio",      "command": "npx",      "args": ["vengtoo-mcp-gateway", "--config", "/path/to/gateway.config.json"]    }  }}

See demo/ for full end-to-end examples with sample policies.

Roadmap

See ROADMAP.md for what's planned: per-caller OAuth, downstream resilience, dynamic tool lists, metrics, remote downstream servers, and more.

Feedback

License

Apache-2.0, see LICENSE.

来源:README.md,提交 8eff947

工具

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

版本历史

1
  1. v1.0.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

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

  • 近 30 天内可连通25 分

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

  • 已声明认证方式10 分

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

  • 已列出工具15 分

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

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