Inspiration

Model Context Protocol (MCP) has rapidly become the open standard for connecting AI agents to external tools, databases, and APIs. However, in practice, raw MCP tool outputs create two severe problems for production LLMs:

  1. Massive Token Waste: Standard database queries, Git diffs, and API responses dump hundreds of lines of raw JSON schema boilerplate, null fields, and repeated framing. This burns context windows and drives up latency and API costs.
  2. Security and Secret Leaks: Raw tool outputs frequently contain authorization headers, bearer tokens, connection strings, and personal identifiable information (PII) that get passed directly into the reasoning model uninspected.

I built this project to act as an autonomous multi-agent gateway that intercepts, scrubs, compresses, and cryptographically signs MCP tool outputs before any reasoning model acts on them.

What it does

Our application provides a real-time multi-agent optimization and verification layer for MCP servers:

  • Zero-Trust Sentinel: Scans raw tool stdout in real time to redact API keys, session tokens, and connection strings before downstream processing.
  • AST Payload Distillation: Synthesizes and prunes structural JSON bloat, removing redundant schemas and null fields to achieve 60% to 80% token reduction without losing key data.
  • Domain Context Enrichment: Generates relational topology, blast-radius estimations, and invariant checks tailored to the active tool.
  • MCP Radar and Discovery Registry: A live catalog of verified and trending MCP servers (PostgreSQL, GitHub, Kubernetes, Linear, Supabase) with one-click pipeline simulation.
  • Multi-Agent Consensus Swarm: Executes a 6-stage pipeline (Sentinel, Distiller, Specialist, Scout, Critic, and Lead Reasoner) powered by Gemini 3.7 Flash.
  • Cryptographic Attestation and Audit Telemetry: Generates SHA-256 HMAC signatures and structured audit logs that can be exported in JSON or Markdown format.

How I built it

We designed the architecture as a full-stack, containerized application deployed to Google Cloud:

  • AI and Reasoning: Built using the official @google/genai SDK with gemini-3.7-flash. We orchestrate specialized agent roles with structured outputs and strict latency guarantees.
  • Backend Runtime: An Express and Node.js TypeScript server handling live MCP proxying, token counting algorithms, AST schema pruning, and cryptographic attestation generation.
  • Frontend Experience: React 18, Vite, Tailwind CSS, Lucide icons, and Motion for responsive execution traces and comparative views.
  • Cloud Infrastructure: Packaged using a multi-stage Dockerfile and hosted natively on Google Cloud Run for containerized, scalable deployment.

Challenges I ran into

  • Multi-Agent Latency: Coordinating five parallel agent evaluations alongside the main reasoning call can introduce network latency. I resolved this by building parallel execution pipelines with sub-5-second timeout guards and deterministic fallback synthesis.
  • Context Preservation during Compression: Ensuring that JSON AST pruning did not drop essential metadata required careful schema traversal rules rather than simple string truncation.
  • Accurate Token Metrics: Measuring true token counts and delta percentages in real time required matching the tokenizer behavior of modern Gemini models.

Accomplishments that I'm proud of

  • Built a working end-to-end multi-agent pipeline where users can visually trace every stage of execution from raw output to signed consensus.
  • Consistently achieved 65% to 78% token reduction on real-world MCP payloads (such as Git diffs and relational SQL results).
  • Implemented zero-trust secret masking and SHA-256 HMAC verification to make MCP tool usage safe for enterprise environments.
  • Deployed a fully functional, containerized build to Google Cloud Run with complete Docker support.

What I learned

  • Decorating and pre-processing tool inputs before feeding them to an LLM improves response accuracy while cutting API costs significantly.
  • Multi-agent architectures are far more effective when each agent has a single, verifiable responsibility (such as security auditing or token compression) rather than trying to handle everything in one large prompt.
  • Open standards like MCP become much more practical for enterprise adoption when paired with inline security controls and audit telemetry.

What's next for MCP Decorator

  • Add direct stdio and SSE socket connectors to allow live proxying for local desktop AI tools like Claude Desktop and Cursor.
  • Integrate Vertex AI Model Armor policies for automated enterprise compliance checks.
  • Expand the MCP Registry with community submissions and automated performance benchmarking.

Built With

Share this project:

Updates