MCP Context Lens
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 Context Lens
English | 简体中文
Zero-runtime-dependency TypeScript/ESM MCP Context Tax Auditor, Lossless Schema Compressor, and Tool Manifest Drift & Prompt-Injection Guardrail — with interactive offline HTML dashboards, SARIF 2.1.0 CI gates, a 4-tool stdio MCP server, and an Agent Skill.
Zero-CDN Interactive Playground: Open
docs/index.htmldirectly in any browser to inspect a bloated 6-server MCP config, test toggling individual servers/tools in a live Context Budget Simulator, run lossless schema compression, and diff a live Rug-Pull prompt-injection update — 100% locally in your browser.
Why MCP Context Lens?
Connecting 4–8 MCP servers to an agent routinely consumes 20%–50% of the context window before the user sends a single message (Context Tax), while unreviewed server updates can silently inject prompt overrides, harvest ~/.ssh/.env credentials, embed invisible Unicode smuggling characters, or widen permissions (Rug-Pull / Manifest Drift).
Related MCP server: TAN TokenDiet
Core Capabilities
Multi-Client & Manifest Ingestion (
src/ingest/):Auto-detects or explicitly parses Claude Code (
.mcp.json), Cursor (.cursor/mcp.json), Antigravity / Gemini (mcp_config.json), VS Code (.vscode/mcp.jsonwith JSONC comments & trailing commas), Codex (config.toml[mcp_servers.*]), and MCPtools/listsnapshots ({ tools }, JSON-RPC{ result: { tools } },{ servers: { name: { tools } } }).Prototype-Pollution Immune & Secret-Redacted: Strips UTF-8 BOM, blocks
__proto__/constructor/prototype, and never echoes rawenv,headers,args, or URL credential literals into reports.Clearly distinguishes
exactper-tool measurements (tools/listpresent) fromestimatedconfig-only server baselines.
12 Deterministic Rules (
src/rules/):Context Tax (
TAX001–TAX006): Bloated descriptions (TAX001), verbose/redundant/over-nested schemas (TAX002), duplicate & near-duplicate tools across servers (TAX003), oversized enums/unions (TAX004), missing parameter descriptions/constraints (TAX005), and single-server context budget dominance (TAX006).Security & Injection (
SEC001–SEC006): Hidden<IMPORTANT>/[INST]override tags (SEC001), covert~/.ssh/.env/process.env/webhook exfiltration directives (SEC002), invisible Unicode stealth — bidi overrides, Unicode TagsU+E0000..E007F, zero-width chars, control bytes (SEC003), cross-tool shadowing/hijacking (SEC004), dangerous schema parameters (SEC005), and annotation contradictions + plaintext config risks (SEC006).
Deterministic Lossless Schema Compressor (
src/engine/compress.ts):Strips
$schema,$id,$comment,examples, redundantadditionalProperties, duplicatetitles, markdown noise, and description boilerplate while programmatically verifying 100% preservation of tool names, property names,requiredarrays,type,enum, and numeric/string/array bounds.
Semantic Manifest Drift & Rug-Pull Diff (
src/engine/diff.ts):Compares
beforeandaftermanifests for added/removed tools, dangerous parameter additions (command,shell,webhook,url,debug_context,conversation_history), dropped constraints, escalated annotations (readOnlyHintdropped,destructiveHintadded), newly introduced security findings, and net token delta.
Zero-CDN Interactive HTML, SARIF 2.1.0, CLI & MCP Server:
Self-contained HTML dashboards (
renderAuditHtml,renderCompressHtml,renderDiffHtml) with inline SVG charts and an interactive client-side Tool/Server Toggle Budget Simulator.SARIF 2.1.0 (
renderAuditSarif,renderDiffSarif) with sanitized relative URIs and deterministic FNV-1a fingerprints.Stdio JSON-RPC 2.0 MCP server (
mcp-context-lens mcp) exposingmcl_audit,mcl_compress,mcl_diff, andmcl_render_html.
Strict DAG Architecture
Enforced automatically by scripts/check-boundaries.mjs:
src/domain/(types.ts,tokenizer.ts) — leaf types, context window presets (128k,200k,256k,1m), CJK/ASCII hybrid BPE estimatorsrc/ingest/→domain/src/rules/→domain/src/engine/(audit.ts,compress.ts,diff.ts) →domain/,ingest/,rules/src/report/(text.ts,json.ts,sarif.ts,html.ts) →domain/src/mcp/(server.ts) →domain/,engine/,report/src/cli.ts,src/index.ts→ all layers above
Quick Start
pnpm install --offline --ignore-scripts
npm run checkCLI Commands
# Audit an MCP config or manifest
node dist/src/cli.js audit examples/01-bloated-6server-config.json --window 200k --html report.html
# Gate CI with a token budget and severity threshold
node dist/src/cli.js audit examples/03-clean-minimal-manifest.json --budget 5000 --fail-on high --sarif out.sarif
# Losslessly compress bloated tool definitions
node dist/src/cli.js compress examples/01-bloated-6server-config.json --out compressed.json --html compress.html
# Detect rug-pull prompt injections and permission escalations across updates
node dist/src/cli.js diff examples/02-rugpull-before.json examples/02-rugpull-after.json --fail-on high --html diff.html
# Generate standalone HTML dashboard or launch stdio MCP server
node dist/src/cli.js playground --out dashboard.html
node dist/src/cli.js mcpVerification & Quality Gates
npm run check # TypeScript strict check, DAG boundaries, privacy/BOM scan, unit & integration tests
node scripts/run-mutation.mjs # TypeScript AST mutation testing (>= 90% kill rate)
node scripts/run-fuzz.mjs # 5,000-case adversarial fuzzer (JSON/JSONC/TOML/XSS/__proto__/ReDoS/Unicode)
node scripts/build-playground.mjs # Build zero-CDN docs/index.html
node scripts/verify-playground.mjs # Static + headless Chrome DOM/layout/overflow verification
npm run build:agensi # Build Agensi whitelist-compliant package + isolated 3-host sandbox testLicense & Commercial Licensing
License Notice: This project is licensed under the PolyForm Noncommercial License 1.0.0 (full terms in
LICENSE).
Free for personal study, academic research, testing, charitable/educational organizations, and noncommercial use.
Commercial use (including commercial product integration, hosted SaaS, paid marketplace redistribution, or commercial consulting delivery) requires prior written permission from the author (
hongrenw111-debug).Commercial licensing inquiries:
hongrenw111@gmail.com
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
MCP Spec Compliance MCP — audits any MCP server.json against the official Model Context Protocol
LLM cost optimization gateway, repo token-waste auditor & model arbitrage MCP server.
Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.
Primary-source MCP server with epistemic compiler, Audit.lean & offline veriscope-verify CLI.
Related MCP Servers
- AlicenseAqualityBmaintenanceA stdio MCP server that audits other MCP servers by linting their tool schemas and calling tools with malformed inputs to produce a 0–100 conformance score and Markdown report.6MIT
- AlicenseBqualityBmaintenanceEnables auditing, benchmarking, and safely compacting MCP tool schemas and AI agent context files to cut LLM token burn, verifying JSON Schema structural invariants so compaction stays lossless. It also flags prompt-cache busters like dynamic timestamps and non-deterministic ordering, and gates CI on token-budget regressions.4MIT
- AlicenseAqualityBmaintenanceEnables auditing and minifying MCP tool schemas, parsing JSON-RPC frames, replaying tool calls, and inspecting captured MCP traffic with token-weight analysis over stdio.6MIT
- AlicenseAqualityBmaintenanceZero-dependency MCP server for deterministic LLM token budgeting, prompt diet compression, context-window auditing, and JSON/code minification.4MIT