mcp-trustlayer
An MCP server that lets an agent verify its own extracted data against a policy, returning per-field dispositions (post, review, or escaped) to catch confidently wrong answers.
README
<div align="center">
mcp-trustlayer
An MCP server that lets an agent ask whether it is allowed to act on its own output.
</div>
An agent that has just extracted values from a document is the worst possible judge of whether those values are correct. It has no distance from its own output. This server moves that judgment outside the model: the agent proposes, a policy you control disposes.
agent ── "I extracted these 12 fields, may I write them?" ──▶ mcp-trustlayer
│
◀── "9 post. 3 to a human. Here is why for each." ────────────┘
Why this exists
Most extraction pipelines gate on one signal, a confidence score, and inherit a failure they never see. Confidence catches the model being unsure. It cannot catch the model being sure and wrong, because nothing in a confidently wrong answer looks hesitant.
The worked example below carries a fee field at 0.94 confidence whose value is the plan-review line item rather than the total. No threshold you could reasonably set catches it. An independent verification pass does.
Tools
evaluate_fields
Returns a disposition per field, one of post, review, or escaped.
{
"fields": [
{ "name": "permit_number", "value": "BLD-2024-041877", "confidence": 0.99, "verification": "verified" },
{ "name": "permit_fee", "value": "$1,240.00", "confidence": 0.94, "verification": "mismatch" },
{ "name": "contractor", "value": "Meridian", "confidence": 0.38, "verification": "not_found" }
],
"high_stakes": ["permit_number"],
"verified": true
}
1 posted, 2 held for review, 0 escaped
[POST] permit_number = 'BLD-2024-041877' (0.99/0.95) verified
[HOLD] permit_fee = '$1,240.00' (0.94/0.85) verification mismatch
[HOLD] contractor = 'Meridian' (0.38/0.85) confidence 0.38 below bar 0.85
Pass "verified": false to model what happens with no verification pass. The fee field flips to escaped, meaning it was written to the record while unsupported by its source. That number is what the second pass is worth.
calibrate_threshold
Sweeps the bar and reports review load against escaped errors, with and without verification, so the threshold gets chosen deliberately rather than inherited.
bar verify-on: hold/escaped verify-off: hold/escaped
0.85 3 / 0 2 / 1
0.90 5 / 0 4 / 1
0.95 7 / 0 7 / 0
Install
No dependencies. Python 3.10+.
git clone https://github.com/neelbarm/mcp-trustlayer
cd mcp-trustlayer
python -m mcp_trustlayer.server
Claude Desktop
{
"mcpServers": {
"trustlayer": {
"command": "python",
"args": ["-m", "mcp_trustlayer.server"],
"cwd": "/path/to/mcp-trustlayer"
}
}
}
Speaking to it directly
MCP is JSON-RPC 2.0 over stdio, so you can drive it with a pipe.
printf '%s\n' \
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' \
'{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' \
| python -m mcp_trustlayer.server
Design notes
The protocol is implemented directly, not via an SDK. protocol.py is about 90 lines and handles initialize, tools/list, and tools/call over newline-delimited JSON-RPC. Keeping it dependency-free makes the wire format legible, which matters more in a reference implementation than convenience does.
Notifications get no response. notifications/initialized carries no id and must not be replied to. This is the most common place a hand-rolled MCP server breaks, so there is a test for it.
Tool errors return content, not crashes. A raised exception comes back as isError: true with the message in the content block, so the model can see what went wrong and adjust rather than losing the connection.
Descriptions are written for the model, not for a human reading docs. Each tool description says when to call it, because that text is the only instruction the model gets.
Tests
python -m pytest tests -q # 10 passed
The suite includes an end-to-end case that spawns the server as a subprocess and speaks real JSON-RPC over stdio, rather than only calling the handler in-process.
Related
- trustlayer — the same decision logic as a Python library
- plancheck — the idea applied end to end to permit intake, with a live demo
MIT. Built by Neel Barmecha.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。