MCP Write Gate

io.github.goran-revops由 GitHub 账号 goran-revops 发布v0.2.0更新于 Oct 24, 2026

Sits in front of any MCP server. Reads pass, writes are checked against your lists.

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

概览

AI 生成的概览

置于任何 MCP 服务器之前的写入闸门,让 AI 代理自由读取,但每次写入都先按你的名单检查后才放行或拒绝。

可以做什么
代理连上闸门而非真实服务器,看到相同的工具名称与输入,调用时由闸门决定放行或拒绝。读取直接通过;写入会比对名单,涉及客户、进行中交易或禁止联系对象时拒绝并告知原因。可设置写入默认放行或等待人工批准,并限制对同一对象的联系频率。只读模式下所有写入一律拒绝,读取须经服务器标记或人工确认才放行。真实 API 密钥留在闸门文件夹,并从返回内容中移除;每次调用都写入可检测篡改的日志。
适用场景
当你让 AI 代理通过 MCP 连接真实的业务系统(如电子邮件、CRM、Slack),并希望有一道代理无法绕过的写入规则时使用。也适合想以只读模式搭配完整权限 API 密钥、让代理只能查看不能修改的场景。
运行要求
需 Python 3.10 以上,以 pip 或 uvx 安装并在本机运行。需创建闸门文件夹,内含规则文件、名单文件与存放真实服务器 API 密钥的 keys.env。远程服务器以 URL 加入,使用 OAuth 的服务器需人工登录一次。
安装前请注意
闸门会保管真实服务器的完整权限 API 密钥,代理若可读取闸门文件夹或以同一系统用户运行代码,就能取得密钥直接调用 API,建议以独立容器隔离。它只检查调用的对象与动作,不检查消息内容,也看不到加密内容或纯记录 ID 中的目标。它只控制代理发往服务器的调用,后方只应放置信任的服务器。

安装

在 SourceWeft 中

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

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

其他 MCP 客户端

参照 仓库 中的启动说明。

README

mcp-write-gate

mcp-write-gate sits between an AI agent and the tools it uses through MCP, such as email, a CRM, Smartlead, or Slack. The agent can read freely, but every write is checked before it goes out, and anything aimed at a customer, an open deal, or anyone else on your lists is refused before it reaches the tool.

I built it for GTM and ops teams who connect an agent like Claude Code to their real systems and want a rule the agent cannot argue its way around. The most common setup is read-only mode: you connect Smartlead, HubSpot, or Salesforce with a full-scope API key, and the agent can look at everything but change nothing.

+---------------+               +------------------+                  +-------------------+|   AI agent    |   tool call   |  mcp-write-gate  |  allowed calls   |  Real MCP server  || (Claude Code, | ------------> |                  | ---------------> | (HubSpot, Gmail,  ||  Cursor, ...) | <------------ |                  | <--------------- |  Smartlead, ...)  |+---------------+  the result,  +--------+---------+     results      +-------------------+                   or why it             |                   was refused           v                          +-----------------------------+                          |  read          ->  forward  |                          |  write, safe   ->  forward  |                          |  write, listed ->  refuse   |                          |  write, unsure ->  hold     |                          |  read-only     ->  refuse   |                          |  every call    ->  log      |                          +-----------------------------+

How it works

The agent connects to mcp-write-gate instead of the real server and sees the same tools, with the same names and inputs. When it calls one, the gate decides what happens. A read goes straight through. A write is checked against your lists, and if it touches a customer, an open deal, or anyone marked do not contact, it is refused and the agent is told why. Nothing reaches the tool. A write to someone who is on no list goes through by default, or waits for a person to approve it if you prefer. You can also cap how often one person is contacted, for example one email per week, and on a read-only server every write is refused no matter what the key allows.

The agent never holds the real API key. The key stays in the gate's own folder, and the gate strips it from anything the server sends back. Every call, allowed or refused, goes into a log that shows if anyone edits it later.

Quick start

You need Python 3.10 or newer.

bash
pip install mcp-write-gatemcp-write-gate initmcp-write-gate add mail -- npx -y your-mail-mcp-server

init creates the gate folder in your user folder, away from your projects. It holds gate.json with the rules and the servers, a starter list in lists/off-limits.csv, keys.env for the real servers' API keys, and the log.

add starts the real server once, reads its tools, and guesses which ones read and which ones write. It prints each guess along with a block for your agent's MCP config. Look over the guesses, then paste that block where the real server's entry used to be. In Claude Code it is one command:

bash
claude mcp add mail -- mcp-write-gate serve mail --config "<gate folder>/gate.json"

Remote servers are added by URL, with their keys kept in keys.env and referred to as ${NAME}. A server that uses OAuth needs one sign-in by a person, and after that the gate refreshes the tokens itself:

bash
mcp-write-gate add crm --url https://mcp.example.com/mcp --header 'Authorization: Bearer ${CRM_TOKEN}'mcp-write-gate add crm --url https://mcp.example.com/mcp --oauthmcp-write-gate login crm

Before you rely on a rule, you can test it without sending anything:

bash
mcp-write-gate check mail send_email --args '{"to": ["[email protected]"]}'

Read-only mode

bash
mcp-write-gate add smartlead --preset read-only --url 'https://mcp.smartlead.ai/sse?user_api_key=${SMARTLEAD_KEY}'mcp-write-gate reads smartleadmcp-write-gate confirm smartlead get_campaigns get_campaign_stats

In read-only mode every write is refused, and no list, mode, or approval can change that. A read passes only when it is vouched for, either because the server marks the tool as read-only and its name reads like a read, or because a person confirmed it with mcp-write-gate confirm. mcp-write-gate reads lists every read and who vouched for it.

The gate does not take the server's word for everything. A tool called delete_campaign that the server labels read-only is still treated as a write. If the server changes a tool after you confirmed it, the tool is refused until you confirm it again. A read that tries to change something through its arguments, such as an HTTP DELETE, a SQL statement that writes, or a GraphQL mutation, is refused as well.

That makes it safe to put a full-scope key behind the gate, as long as four things hold:

  1. The gate is the agent's only way to reach that tool.
  2. The agent cannot read the gate folder or run code as the gate's user, because then it could find the key and call the API directly. docs/security.md describes three ways to prevent that, the strongest being a separate container.
  3. You checked each read before confirming it. Generic tools like call_api or run_query need extra care, because a vendor API that deletes on a GET looks like a read.
  4. The key still has the narrowest scopes the vendor offers. The gate is a second lock, so keep the first one too.

Lists

Lists are plain CSV, TXT, or JSON files in the lists/ folder, so you can export them from your CRM or keep them by hand. Every file is read, and a change takes effect on the next call.

csv
target,status,noteexample.com,customer,paying account[email protected],open_deal,in a live deal[email protected],allow,partner contact inside a customer#sales-internal,blocked,chat channel the agent must not post in*/contracts/*,blocked,signed contracts stay untouched

A domain covers all its subdomains, and an email row also covers the same mailbox written with a +tag or with Gmail's dots. When two rows match, the more specific one wins, which is how [email protected],allow can sit inside a customer's domain. A status the gate does not recognize counts as a refusal, so a typo cannot open the gate. If the truth lives in your CRM instead of a file, the gate can run a lookup command for anything that is on no list, as described in docs/configuration.md.

Tested with real servers

ServerWhat was tested
SmartleadAll 170 tools sorted into reads and writes. Replying to a lead, starting a campaign, and forwarding an email were refused and never sent, confirmed reads passed through, and the API key never reached the agent.
HubSpotReads passed through to HubSpot. Creating records and logging engagements were refused and never sent.
GmailAll 23 tools sorted. Drafts, labels, spam, and trash are treated as writes.
SalesforceAll 74 tools sorted. Deploys, permission changes, and Apex tests are writes, and queries are reads.
NotionAll 24 tools sorted. Creating, editing, moving, and deleting pages are writes, and retrieving is a read.
MCP filesystem and everything serversFile paths as targets, resources, prompts, completions, and long-running calls.

I also ran it with Claude Code as the agent. Without the gate, Claude sent the email it was asked to send. With the gate in read-only mode, the email was never sent, and the log showed the refusal.

What it does not protect against

The gate checks who and what a call touches, not what a message says, so a customer's name in the body of an email to someone else is not caught. It cannot see targets hidden in encrypted payloads, custom binary formats, or a bare record id like contact 123. For ids you can add a lookup command, and for the rest you can set that tool to refuse anyone who is not on a list. It cannot stop an agent that runs code as the same OS user as the gate, which is why the Dockerfile runs the gate in its own container. And it only controls what the agent sends to a server, so put only servers you trust behind it.

Learn more

docs/configuration.md covers every setting in gate.json: targets, presets, rate limits, the lookup command, held calls and the approval page, serving over HTTP, and the full command list. docs/security.md explains how to keep the gate out of the agent's reach, where the secrets live, how the log shows tampering, and what the attack tests cover.

Running the tests

bash
pip install -e ".[dev]"pytest

The tests start a real MCP server behind the gate and talk to it with the official MCP client, over stdio and over HTTP.

License

MIT

来源:README.md,提交 ded1dc1

工具

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

版本历史

1
  1. v0.2.0最新Sep 26, 2026

评分

已满足适用检查项的 50%

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

  • 近 30 天内可连通25 分

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

  • 已声明认证方式10 分

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

  • 已列出工具15 分

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

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