agent-eval-policy
This MCP server exposes deterministic policy tools for agent seat routing/budget admission, agent-response contract checks, and dossier URL/markdown linting.
Route worker roles (
grunt,scout,mechanic,sniper,auditor) to cost tiers and admit/refuse planned spend against a caller-supplied budget snapshot, including reserve floor, judgment allowance, circuit breaker, and fail-closed accounting validation.Evaluate one agent response against a contract: required anchor line, first JSON block schema compliance, forbidden-claim matching with Unicode folding, and verified source-slice citations.
Canonicalize and deduplicate URLs, and lint a markdown dossier for required structure, source links, uniqueness/canonicality, bare URLs, and TODO/TBD/FIXME/lorem placeholders.
Use the same decision code via MCP JSON-RPC over stdio or
POST /mcp, the browser Web Inspector, native eval harness, and Promptfoo provider; read exposed resources for contracts, fixtures, and scorecard.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@agent-eval-policy Route a sniper to workspace-write with 4.5 of 10 CU used, 10% reserve"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
agent-orchestration-mcp-eval
A zero-dependency Model Context Protocol (MCP) server that exposes three deterministic policy tools: seat routing with budget admission, agent-response contract checks, and dossier URL/markdown linting. The same decision code runs behind the MCP server, a browser Web Inspector, a native eval harness, and a Promptfoo provider, so the evidence a reviewer sees is the evidence the server enforces.
Runtime: Node.js, ES modules, no
dependenciesinpackage.json. Declaredengines.node >=20; verified on Node 22.14.0 only.Web Inspector:
docs/index.html, an interactive playground for all three tools. Plain ES modules, no CDN, no build step. Served atGET /inspector/by the HTTP transport, or hostable as static files.Protocol: JSON-RPC 2.0 over stdio (newline-delimited) and HTTP (
POST /mcp). Implementsinitialize,ping,tools/list,tools/call,resources/list,resources/read. Request IDs must be strings or integers. HTTP refuses unsupportedMCP-Protocol-Versionheaders (400) and JSON-RPC batch bodies (400).License: MIT.
Verified status
Check | Command | Result |
Unit, protocol, stdio, HTTP, simulator and inspector tests |
| 57/57 pass (Node 22.23.4) |
Native deterministic eval |
| 206/206 pass, 0 false accepts, 0 false rejects (Node 22.23.4) |
Sanitization gate |
| 0 hits in the tree (41 files, now including |
Web Inspector in a real browser | Playwright + Chromium against | All three tabs render, every result agrees with live |
Benchmark |
| Results below |
Promptfoo eval on the same fixtures |
| 206/206 pass (Node 22.23.4) |
Not yet verified: connecting a third-party MCP client (Claude Desktop, Cursor) to this server. The configuration below follows each client's documented mcpServers format but has not been exercised.
Related MCP server: APIVouch
Architecture
flowchart LR
Client["MCP client<br/>(Claude Desktop, Cursor, custom)"] -->|"stdio: newline-delimited JSON-RPC"| Stdio["src/server.mjs"]
Client -->|"HTTP: POST /mcp"| Http["src/http.mjs"]
Browser["Browser"] -->|"GET /inspector/"| Http
Http -->|"static allowlist"| Docs["docs/index.html + app.mjs<br/>Web Inspector"]
Docs -->|"imports"| Lib["docs/lib/*.mjs<br/>byte-identical copies of src"]
Docs -.->|"cross-check: POST /mcp"| Http
Stdio --> Core["src/jsonrpc.mjs<br/>JSON-RPC 2.0 + MCP methods"]
Http --> Core
Core --> Registry["src/tools.mjs<br/>registry + input schema validation"]
Core --> Resources["src/resources.mjs<br/>contracts, fixtures, scorecard"]
Registry --> Policy["src/policy.mjs<br/>seat routing, reserve floor, circuit breaker"]
Registry --> Evaluate["src/evaluate.mjs<br/>anchor, schema, claims, citations"]
Registry --> Dossier["src/dossier.mjs<br/>URL canonicalization, dedup, lint"]
Sim["src/simulate.mjs<br/>seeded 100-step mission"] --> Policy
Native["evals/run-evals.mjs<br/>npm run eval"] --> Registry
PF["promptfooconfig.yaml"] --> Provider["evals/promptfoo-provider.mjs"] --> Registry
Fixtures[("evals/cases.json<br/>shared fixtures")] --> Native
Fixtures --> PFDesign rules:
Pure core.
policy.mjs,evaluate.mjsanddossier.mjsdo no I/O and no clock reads. Same input, same output.Fail closed. Unknown roles, modes, tiers and malformed accounting values are refused. Accounting values must be finite numbers, checked against the schema before any arithmetic. A negative
usedCUcannot widen capacity.Schema subset enforced. Tool input schemas and response contracts use a small JSON Schema subset. Any keyword outside that subset throws at registration instead of being ignored.
Transport-free decisions. The MCP server, Web Inspector, native harness and Promptfoo provider all call
callTool(), so there is one code path to test. The inspector importsdocs/lib/, whichnpm run sync-docscopies fromsrc/. A test fails if the copies differ by a single byte.
Tools
Full schemas: resources/read on agent-eval://contracts/tools.
route_agent_seat
Routes a worker role to a cost tier, then admits its planned spend against a budget snapshot.
Field | Type | Notes |
| enum |
|
| enum |
|
| number ≥ 0 | CU already spent in the window. |
| number > 0 | Window capacity in CU. |
| number 0–100 | Share of capacity held back. agent share = capacity × (100 − reservePct) / 100. |
| number ≥ 0 | Judgment-tier spend needs an allowance. Default 0 refuses judgment seats. |
| integer | The circuit breaker opens at |
cu and tier come from the route, never from the caller. Unknown budget keys are refused. Every accounting value must be finite and at most MAX_CU = 1e9, so capacityCU: Number.MAX_VALUE cannot overflow the share to Infinity.
evaluate_agent_response
Checks one response against a contract. Each check reports pass, fail, or skipped (not configured).
Check | Contract field | Rule |
Anchor |
| First non-empty line must be exactly |
Schema |
| The first |
Forbidden claims |
| Literal phrases, matched after folding both texts: NFKD, lowercase, combining marks and invisible format characters (zero-width, soft hyphen, BOM, bidi controls) removed, whitespace collapsed. Any hit fails. |
Coordinate slices |
| Each |
The schema contract field is checked at registration: unsupported keywords and malformed keyword values (required: "abc", type: "strnig", minimum: "5", enum: []) throw instead of being misread.
dedup_and_lint_dossier
Accepts urls, markdown, or both. ok is false on any duplicate, invalid URL, or lint violation.
URL canonicalization: WHATWG URL parsing (IDN hosts become punycode, fullwidth hosts fold to ASCII, dot segments resolve), lowercase scheme and host, default ports removed, fragment removed,
utm_*,fbclid,gclid,mc_cid,mc_eid,ref,ref_srcremoved, query keys sorted, percent-encoding hex uppercased in the path, trailing slash removed from non-root paths. Hosts are not rewritten (nowww.stripping).Dossier lint: H1 title first;
## Summary,## Findings,## Sourcesin that order; at least one source link; every link canonical and unique within Sources; no bare URLs outside link syntax; noTODO,TBD,FIXMEor lorem placeholders.
Web Inspector
An interactive playground for the three tools. It runs entirely in the page from docs/lib/, which is a byte-for-byte copy of the browser-safe modules in src/.
npm run inspector # then open http://127.0.0.1:3333/inspector/Served this way, every result is also requested from the live POST /mcp endpoint and compared, and each panel shows /mcp agrees or /mcp MISMATCH. The docs/ folder also works as a static site (GitHub Pages, or any static file server), where it runs without the cross-check. Browsers do not load ES modules from file://, so opening index.html straight from disk does not work.
Tab | What it does |
Seat router & budget | Sliders for |
Contract & citations | Live editors for the response and the contract JSON, running |
Dossier linter |
|
Mission numbers: with the default mix (weights 50 grunt, 25 scout, 8 mechanic, 7 sniper, 10 auditor) the expected reduction is 75%. Seed 42 plans 50 grunt, 29 scout, 4 mechanic, 9 sniper and 8 auditor steps, which cost 82.8 CU against 360 CU naive, a 77% reduction. Individual seeds range from about 70% to 78%. test/simulate.test.mjs checks seed 42 and the mean over seeds 1–200. These are relative planning weights, not provider prices (see Limits).
Security: the HTTP route serves a fixed allowlist of files from a lookup table and never joins request paths onto the filesystem. Responses carry Content-Security-Policy: default-src 'none'; script-src 'self'; style-src 'self'; connect-src 'self'; …, nosniff and no-referrer. The page writes user text with textContent only. The localhost-only origin guard applies to /inspector as it does to /mcp.
Quickstart
git clone <this-repo> agent-orchestration-mcp-eval
cd agent-orchestration-mcp-eval
npm test # unit, protocol, stdio and HTTP tests, then the native eval, then the sanitization gate
npm run eval # native eval only; writes evals/results/scorecard.{md,json}
npm start # MCP over stdio
npm run start:http # MCP over HTTP on 127.0.0.1:3333 (override with PORT), Web Inspector at /inspector/
npm run bench # throughput and p50/p99 latency for the three tools
npm run sync-docs # recopy src/ modules into docs/lib after changing themPromptfoo:
npx promptfoo@0.120.19 eval -c promptfooconfig.yamlThe version is pinned because the latest Promptfoo release requires Node 22.22 or newer. The config needs no API keys: the provider is a local deterministic function over the same evals/cases.json.
Evaluation results
Measured by npm run eval on fixtures version 3 (evals/results/scorecard.md). These fixtures are authored in this repo to pin known behaviour. They are a regression suite, not an external benchmark, and 100% here says the code matches the fixtures, not that it generalises.
Category | Pass | Should-accept | Should-reject | False accepts | False rejects |
Seat routing | 10/10 | 5 | 5 | 0 | 0 |
Budget admission (reserve, judgment, breaker, accounting bypasses) | 19/19 | 5 | 14 | 0 | 0 |
Input schema compliance | 4/4 | 0 | 4 | 0 | 0 |
Evidence acceptance | 4/4 | 4 | 0 | 0 | 0 |
Hallucination rejection | 13/13 | 0 | 13 | 0 | 0 |
Dossier dedup and lint | 14/14 | 3 | 11 | 0 | 0 |
Numeric injection (NaN, Infinity, -0, overflow, float boundaries) | 32/32 | 7 | 25 | 0 | 0 |
Prototype pollution and malformed schema keywords | 24/24 | 2 | 22 | 0 | 0 |
Unicode edge cases (normalization, invisible characters, IDN) | 34/34 | 8 | 26 | 0 | 0 |
Slice coordinate boundaries | 28/28 | 11 | 17 | 0 | 0 |
URL canonicalization and link lint | 24/24 | 4 | 20 | 0 | 0 |
Total | 206/206 | 49 | 157 | 0 | 0 |
JSON cannot carry NaN, Infinity or -0, so fixtures write them as {"$number": "NaN"} (also "Infinity", "-Infinity", "-0"). reviveNumbers() in evals/shared.mjs turns them back into numbers before the call, for both the native runner and the Promptfoo provider. A JSON-RPC client cannot send these values either, since JSON has no way to write them. The fixtures test the code's own guards. Prototype-pollution fixtures carry real own __proto__ keys, as JSON.parse produces them.
What the adversarial suite found
Running the 142 fixtures added in version 3 against the version-2 code gave 180/206, with 18 false accepts. Each was fixed in this release:
Finding | Before | Fix |
| Admitted, with | Accounting values are capped at |
Forbidden claim written in fullwidth letters, split by a zero-width space or soft hyphen, wrapped across lines, with an NBSP, ligature, accent or Turkish | Not matched (8 cases) |
|
Citation with Arabic-Indic or fullwidth digits, an | Silently not treated as a citation (6 cases) | Lines that start with |
Coordinates past | Rejected, but only incidentally (as past the end of the source) | Rejected explicitly as out of range, before any arithmetic |
Schema keyword values | Accepted. | Rejected at registration |
| Not deduplicated, and not flagged as non-canonical in a dossier | Percent-encoding hex is uppercased |
Benchmark
Measured with npm run bench (20,000 timed calls per row after 2,000 warm-up calls, inputs rotating through accept and reject fixtures) on Node v22.23.4, linux x64, Intel(R) Xeon(R) Processor @ 2.10GHz (4 vCPU). Single-threaded, in-process, no transport I/O. Numbers vary by machine; rerun locally before relying on them.
Tool | Path | Inputs | Throughput (ops/sec) | p50 latency (µs) | p99 latency (µs) |
| callTool | 5 | 171,680 | 4.04 | 32.7 |
| tools/call | 5 | 110,933 | 7.60 | 50.3 |
| callTool | 2 | 20,313 | 40.2 | 193 |
| tools/call | 2 | 20,850 | 37.8 | 205 |
| callTool | 3 | 18,215 | 43.3 | 197 |
| tools/call | 3 | 18,094 | 45.6 | 182 |
callTool is the in-process path (input-schema validation and the policy handler). tools/call adds JSON-RPC dispatch through handleMessage() and serialization of the reply, which is what the stdio and HTTP transports do before I/O. Every call is timed on its own with process.hrtime.bigint(). Regenerate this section with node scripts/benchmark.mjs --write-readme.
MCP client configuration
Replace <ABSOLUTE_PATH_TO_REPO> with the absolute path to this repository.
Claude Desktop (%APPDATA%\Claude\claude_desktop_config.json on Windows):
{
"mcpServers": {
"agent-eval-policy": {
"command": "node",
"args": ["<ABSOLUTE_PATH_TO_REPO>/src/server.mjs"]
}
}
}Cursor (.cursor/mcp.json in a project, or ~/.cursor/mcp.json globally):
{
"mcpServers": {
"agent-eval-policy": {
"command": "node",
"args": ["<ABSOLUTE_PATH_TO_REPO>/src/server.mjs"]
}
}
}Limits
Compute-unit weights (0.09 / 0.9 / 1.8 / 3.6) are relative planning weights. This server does not read provider quota or billing.
Admission is a function of the caller's snapshot. The server keeps no ledger, so concurrent callers must reconcile usage themselves.
The HTTP transport has no authentication. It binds to
127.0.0.1and rejects non-localhost browser origins, but it is not meant to be exposed beyond the local machine.No server-initiated requests, no SSE streaming, no session management. Requests are answered in arrival order over stdio.
Batches are accepted over stdio but refused over HTTP. Batching was removed in MCP 2025-06-18, and the HTTP transport does not implement it.
The sanitization gate's private-term list is a file outside the repo, passed with
SANITIZE_PRIVATE_TERMS. Without it the gate runs only the generic rules (emails, phone numbers, keys, local user paths).The mission simulator's 70%+ reduction comes from the relative CU weights and an assumed step mix. It shows how the routing policy behaves, not a measured saving on any provider's bill.
Benchmark numbers come from one container and change with the hardware and Node version.
Resources read files from
evals/.agent-eval://scorecard/latestreturns nothing untilnpm run evalhas run.
Available Tools
3 toolsdedup_and_lint_dossierA
Canonicalize and deduplicate URLs, and/or lint a markdown dossier against the dossier schema. ok is false on any duplicate, invalid URL, or lint violation.
Inputs: urls, markdown.
evaluate_agent_responseB
Check one agent response against a contract: anchor line, JSON payload schema, forbidden claims, and verified source-slice citations.
Inputs: contract (required), response (required).
route_agent_seatB
Route a worker role to a cost tier and admit its planned spend against the budget snapshot. Fails closed on unknown roles, modes, or malformed accounting values.
Inputs: role (required), budget (required), mode.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool targets a distinct phase: seat/budget routing, single-response contract checking, and URL/dossier hygiene. The only wrinkle is dedup_and_lint_dossier bundling two operations with 'and/or' semantics, which could make an agent unsure whether it must supply both inputs.
All three follow a clean verb_noun (or verb_noun_noun) snake_case pattern: route_agent_seat, evaluate_agent_response, dedup_and_lint_dossier. Predictable and readable throughout.
Three tools is thin but matches a narrow policy/eval-enforcement role where each tool is a distinct gate. Nothing feels redundant or padded.
Covers routing/admission, response validation, and dossier hygiene, but there is no way to inspect or refresh the budget snapshot, enumerate valid roles/contracts, or manage schema definitions—agents hitting an 'unknown role' or 'fails closed' path have no recovery tool.
Maintenance
Related MCP Connectors
Pre-execution governance for AI agents. Deterministic PASS/FAIL/REVIEW verdicts, replayable proof.
Agent routing, safety preflight, execution receipts, best execution and verified outcomes.
AI agent infrastructure: dedup, cost prediction, validation, governance, failure intelligence.
Pre-deploy governance for AI agents: posture scores, policies, budget cap checks, trust manifests.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to run evidence QC gates mid-workflow—checking claims, sources, prose, and vault hygiene deterministically before research ships.MIT
- AlicenseNot gradedqualityBmaintenanceEnables agents to route goals across multiple independent APIs, enforce constraints, reject invalid evidence, and return verified outcomes with tamper-evident receipts.MIT
- AlicenseAqualityBmaintenanceEnables autonomous AI agents to proactively poll event queues, evaluate document compliance, retrieve grounded knowledge via semantic RAG, enforce human-in-the-loop approval gates, and track multi-model cost budgets.10MIT
- AlicenseCqualityBmaintenancePersistent multi-agent work graph and document-state machine for contracts, specs, slices, evidence, verification, handoffs, and cost-aware AI execution.7Apache 2.0