agent-safety-mcp
MukundaKatta/agent-safety-mcp
MCP server that gives any LLM agent a built-in safety layer: arg validation, egress firewall, JSON repair, context fitting, and snapshot tracing. Wraps the @mukundakatta agent-stack libs.
Instalação
npx convez-ai MukundaKatta/agent-safety-mcp1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.
Métricas
README
A tradução para o português deste README ainda está na fila.
agent-safety-mcp
An MCP server that gives any LLM agent a built-in safety layer. Every tool maps to a battle-tested, npm-published primitive from the @mukundakatta agent-stack, so the agent gets validation, egress control, JSON repair, context-window fitting, and snapshot tracing without writing any of that itself.
Why
When you give an LLM real tools, four things go wrong:
- The model emits bad arguments → your tool crashes (or worse, runs with garbage).
- The model fetches whatever URL it wants → data leaks, prompt injection, runaway cost.
- The model returns JSON wrapped in prose → your parser blows up.
- The conversation outgrows the context window → silent truncation, lost system prompt.
Each of those is solved separately by an open-source library. This MCP server wires those libraries into one server any agent (Claude, Gemini, GPT, anything with MCP support) can plug into in 30 seconds.
Tools
| Tool | What it does | Backed by |
|---|---|---|
validate_args | Validate LLM-emitted tool arguments against a shape spec. Returns a structured error + retry hint. | @mukundakatta/agentvet |
check_egress | Decide whether a URL is in the agent's allowlist before fetching. | @mukundakatta/agentguard |
extract_json | Pull JSON out of messy LLM output (handles fences, prose, balanced extraction). | @mukundakatta/agentcast |
fit_messages | Truncate chat history to a token budget. Preserves system messages. | @mukundakatta/agentfit |
count_tokens | Fast token estimate for a string or message array. | @mukundakatta/agentfit |
diff_snapshot | Compare two agent traces. Reports PASSED, OUTPUT_DRIFT, TOOLS_REORDERED, TOOLS_CHANGED, or REGRESSION. | @mukundakatta/agentsnap |
Optional: Splunk HEC sink
Set SPLUNK_HEC_URL and SPLUNK_HEC_TOKEN (and optionally SPLUNK_HEC_INDEX) before starting the server. Every safety tool call is then forwarded to Splunk as a structured event with sourcetype=agent_safety, so SOC and SRE teams can search, alert, and dashboard agent policy decisions in real time. The sink is a no-op when those env vars are unset.
Run it
Local (stdio)
npm install
npm run build
node dist/server.js
Register in a Claude Desktop / Cursor / Cline config:
{
"mcpServers": {
"agent-safety": {
"command": "node",
"args": ["/absolute/path/to/agent-safety-mcp/dist/server.js"]
}
}
}
HTTP (Cloud Run, Fly, anywhere)
npm run build
npm run http # listens on $PORT (default 8080) at /mcp
Deploy to Cloud Run
gcloud run deploy agent-safety-mcp \
--source . \
--region us-central1 \
--allow-unauthenticated \
--port 8080
The deployed server exposes:
POST /mcp— Streamable HTTP MCP endpointGET /healthz— liveness probe
Live demo deploy: https://agent-safety-mcp-444075785245.us-central1.run.app/mcp
Demo
examples/gemini-demo.ts runs a Gemini 2.0 Flash agent on Vertex AI that calls the MCP tools to validate args and check an egress URL.
gcloud auth application-default login
export GOOGLE_CLOUD_PROJECT=your-project
npm run demo:gemini
License
MIT