@tokz/mcp
v0.1.1
Published
Schema-preserving Tokz compression for MCP tool results and stdio servers.
Downloads
355
Readme
@tokz/mcp
Compress MCP tool-result text while preserving the MCP envelope, error state, metadata, call identity, and non-text blocks.
import { Tokz } from "@tokz/sdk";
import { withTokzMcp } from "@tokz/mcp";
const tokz = new Tokz({ apiKey: process.env.TOKZ_API_KEY! });
withTokzMcp(mcpClient, tokz, {
firewall: true,
protectedContext: [{ id: "system", text: systemPrompt }],
budget: { mode: "auto", risk: "conservative" },
security: { trust: "untrusted", preserveInstructions: true },
});MCP sees tool results, not the provider's complete prompt. protectedContext and
controlContext must be supplied by the host; otherwise firewall mode isolates
tool-result blocks from each other but cannot protect an unseen system prompt.
structuredContent is unchanged by default. To transform it, opt in and provide
a validator; the original is retained unless the compressed JSON passes.
Wrap an existing stdio server without changing its implementation:
TOKZ_API_KEY=tokz_live_... tokz-mcp-proxy -- npx your-mcp-serverMIT
