mcp-trust-guard
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mcp-guard
KYA (Know Your Agent) security middleware for MCP servers. Abuse database, trust-based access control, rate limiting, and audit logging.
Zero dependencies. Works with any Node.js HTTP framework. Part of the KYA verification system.
Scan any MCP package for security issues: agentscores.xyz - type a package name, get instant results.
The Problem
MCP servers have no security layer. Any client can call any tool — there's no identity verification, no access control, no rate limiting, no audit trail. As AI agents begin calling MCP tools autonomously, this is a critical gap.
mcp-guard adds KYA verification to any MCP HTTP server — abuse database checks, trust-based access control, and audit logging in three lines of code.
Related MCP server: protect-mcp
Install
npm install mcp-trust-guardQuick Start
import express from 'express';
import { McpGuard } from 'mcp-trust-guard';
const guard = new McpGuard({
rules: [
{ minTrust: 0, tools: ['get_*', 'list_*', 'search_*'] },
{ minTrust: 30, tools: ['create_*', 'update_*'] },
{ minTrust: 60, tools: ['delete_*', 'admin_*'] },
],
rateLimit: { window: 60, max: 30 },
audit: true,
});
const app = express();
app.use(express.json());
app.use('/mcp', guard.middleware());
// ... your MCP server handlerEvery tools/call request is now verified against the caller's trust score. Read-only tools are open. Write tools need a score of 30+. Destructive tools need 60+.
How It Works
┌──────────────┐
Request ──→ Extract Identity ──→ Rate Limit ──→ │ Trust Check │ ──→ Rule Match ──→ Allow/Deny
(header) (per caller) │ (AgentScore) │ (tool pattern)
└──────────────┘Identity — Reads the caller's agent name from the
x-agent-nameheader (configurable)Rate Limit — Sliding window per caller. Rejects with JSON-RPC error if exceeded
Trust Check — Looks up the caller's trust score via AgentScore (5-min cache, fail-closed)
Rule Match — Matches the requested tool against your rules using glob patterns. First match wins
Allow/Deny — If the caller's score meets the rule's minimum, the request passes through. Otherwise, a JSON-RPC error is returned
Features
Trust-Based Access Control
Define tiered access based on trust scores:
const guard = new McpGuard({
rules: [
{ minTrust: 0, tools: ['read_*'] }, // Public — anyone can read
{ minTrust: 20, tools: ['query_*'] }, // Low bar — basic queries
{ minTrust: 40, tools: ['write_*'] }, // Verified agents only
{ minTrust: 70, tools: ['transfer_*'] }, // High trust — financial ops
],
defaultMinTrust: 10, // Tools not matching any rule require score >= 10
});Tool Name Patterns
Rules use glob patterns with * wildcards:
{ minTrust: 30, tools: ['create_*', 'update_*'] } // Matches create_user, update_record
{ minTrust: 60, tools: ['admin_*'] } // Matches admin_delete, admin_config
{ minTrust: 0, tools: ['get_status'] } // Exact match only
{ minTrust: 50, tools: ['*'] } // Catch-allRate Limiting
In-memory sliding window per caller:
const guard = new McpGuard({
rateLimit: {
window: 60, // 60-second window
max: 30, // 30 requests per window per caller
},
});Audit Logging
Console logging:
const guard = new McpGuard({ audit: true });
// [mcp-guard] ALLOW EmberFoundry → get_status (score: 42, band: MODERATE TRUST) score 42 >= 0 required for get_status
// [mcp-guard] DENY untrusted-bot → admin_delete (score: 3, band: UNVERIFIED) score 3 < 60 required for admin_deleteCustom audit handler:
const guard = new McpGuard({
audit: (entry) => {
db.insert('audit_log', entry);
if (!entry.allowed) alerting.notify(`Blocked ${entry.caller} from ${entry.tool}`);
},
});Direct Trust Checks
Use the guard programmatically without middleware:
const guard = new McpGuard();
const decision = await guard.check('EmberFoundry', 'transfer_funds');
// { allowed: false, reason: 'score 14 < 70 required for transfer_funds', caller: 'EmberFoundry', trustScore: 14, trustBand: 'UNVERIFIED' }Custom Trust Providers
Use any trust source — not just AgentScore:
import { McpGuard, TrustProvider, TrustResult } from 'mcp-trust-guard';
const myProvider: TrustProvider = {
async check(name: string): Promise<TrustResult> {
const score = await myDatabase.getAgentScore(name);
return { score, band: score > 50 ? 'TRUSTED' : 'UNTRUSTED', name };
},
};
const guard = new McpGuard({ provider: myProvider });Wrapping Any Handler
Not using Express? Wrap any request handler:
const protectedHandler = guard.wrap(mcpHandler);
http.createServer(protectedHandler).listen(3000);Configuration
Option | Type | Default | Description |
|
| AgentScore | Custom trust score provider |
|
|
| AgentScore API endpoint |
|
|
| Header containing caller identity |
|
|
| Access rules (first match wins) |
|
|
| Min trust when no rule matches |
|
| none | Rate limit config (seconds, count) |
|
|
| Trust cache TTL in ms (5 min) |
|
|
| Enable audit logging |
|
|
| Allow requests without identity |
Identifying Callers
By default, mcp-guard reads the caller's identity from the x-agent-name HTTP header. MCP clients should include this header when making requests:
curl -X POST http://localhost:3000/mcp \
-H "Content-Type: application/json" \
-H "x-agent-name: MyAgent" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_data"}}'You can change the header name:
const guard = new McpGuard({ identityHeader: 'authorization' });Or use query parameters as a fallback — ?agent=MyAgent is checked automatically.
FAQ
What if the trust API is unreachable?
The agent gets a score of 0. Fail-closed by default. If your rules allow minTrust: 0 for some tools, those still work.
Does it work with stdio MCP servers?
No — stdio servers run locally and don't need network-level security. mcp-guard is for HTTP/SSE MCP servers that accept remote connections.
Does it modify the MCP request?
No. It only inspects tools/call requests. All other MCP methods (tools/list, resources/read, etc.) pass through untouched. When a request is allowed, it continues to your handler unchanged.
Can I use my own scoring system?
Yes. Implement the TrustProvider interface (one method: check(name) → { score, band, name }) and pass it in the config.
KYA Abuse Database (v0.2.0+)
Block agents that have been reported for abuse — data exfiltration, prompt injection, unauthorized access, and more. Community-driven, free, no API key.
const guard = new McpGuard({
abuseCheck: true, // Enable abuse database checks
abuseBlockLevel: 'CAUTION', // Block at MONITOR, CAUTION, or BLOCK level
rules: [
{ minTrust: 0, tools: ['get_*'] },
{ minTrust: 30, tools: ['write_*'] },
],
audit: true,
});When an agent with abuse reports tries to call a tool:
[mcp-guard] DENY bad-agent → write_file (score: -1, band: ABUSE_REPORTED)
agent reported in KYA abuse database: prompt_injection (1 reports, severity: high)Report abuse: POST https://agentscores.xyz/api/abuse/report
Check an agent: GET https://agentscores.xyz/api/abuse/check?agent=name
For standalone abuse checking without the full middleware, use kya-abuse-check.
Part of KYA (Know Your Agent)
mcp-trust-guard is the server-side component of KYA — real-time AI agent verification. Six checks: Deployer, Model, Code, Abuse, Permissions, Deployment. No platform registration required.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Independent A-F trust grade for any MCP server, watched for drift. Free, never for sale.
Trust verification for MCP servers. Check scores, scan for security issues, search 4,200+ servers.
MCP server for mandates, delegation, policy-gated execution, credential grants, and audit.
Signed, Merkle-proofed, on-chain-anchored trust records for MCP servers. Verify, do not trust.
Related MCP Servers
- AlicenseBqualityCmaintenanceSecurity gateway that wraps any MCP server with per-tool policies, approval gates, and optional Ed25519-signed decision receipts. Shadow mode logs every tool call without blocking; enforce mode applies block, rate-limit, and minimum-tier rules. Receipts are independently verifiable offline with no accounts needed.511MIT
- AlicenseNot gradedqualityBmaintenanceSecurity gateway for MCP servers. Wraps any MCP server with per-tool policies (Cedar + JSON), Ed25519-signed decision receipts, human approval gates, and trust tiers. Shadow mode by default — logs everything, blocks nothing.1,879 npm10MIT
- FlicenseNot gradedqualityDmaintenanceThe security runtime for MCP servers. Every tool call inspected. Every attack blocked. Every decision logged.1-
- AlicenseAqualityDmaintenanceDrop-in security primitives for MCP servers, addressing isError compliance, audit trails, input validation, output sanitization, and OAuth scoping.7MIT