@rankigi/mcp
v1.0.0
Published
RANKIGI instrumentation for MCP servers and clients. Cryptographically sealed tool call records.
Readme
@rankigi/mcp
Cryptographically sealed records for every MCP tool call.
What it does
Every MCP tools/call request becomes a RANKIGI tool_call event. Every matching response becomes a tool_result event linked by the JSON-RPC id. Both are SHA-256 hashed, hash-chained to the previous event in the agent's ledger, and anchored to the Sigstore public transparency log. Neither event blocks execution. If RANKIGI is unreachable, your agent continues.
Server-side (recommended)
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { wrapMcpServer } from "@rankigi/mcp/server";
const server = new McpServer({ name: "my-server", version: "1.0.0" });
await server.connect(new StdioServerTransport());
wrapMcpServer(server, {
apiKey: process.env.RANKIGI_API_KEY!,
agentId: process.env.RANKIGI_AGENT_ID!,
mcpServer: "my-server",
});Client-side
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
import { wrapMcpTransport } from "@rankigi/mcp/client";
const transport = wrapMcpTransport(
new StdioClientTransport({ command: "node", args: ["server.js"] }),
{
apiKey: process.env.RANKIGI_API_KEY!,
agentId: process.env.RANKIGI_AGENT_ID!,
mcpServer: "my-server",
},
);
const client = new Client({ name: "my-client", version: "1.0.0" });
await client.connect(transport);Event shape
tool_call event payload:
{
"action": "tool_call",
"payload": {
"tool": "search_web",
"input_hash": "9af1c8...",
"input_size": 142,
"mcp_request_id": 7,
"mcp_server": "my-server",
"mcp_protocol_version": "2.0"
}
}tool_result event payload:
{
"action": "tool_result",
"payload": {
"tool": "search_web",
"output_hash": "2c1e44...",
"output_size": 8421,
"mcp_request_id": 7,
"mcp_server": "my-server",
"duration_ms": 482,
"is_error": false
}
}Two events, not one
tool_call and tool_result are emitted as separate chain events, linked by mcp_request_id. The temporal separation preserves the start-to-finish latency of each tool invocation as on-chain evidence and keeps the hash chain continuous during long tool runs. A single combined event would erase that latency record and would force the chain to stall for the duration of the tool call, which violates RANKIGI's non-blocking guarantee.
Installation
npm install @rankigi/mcp @rankigi/sdk @modelcontextprotocol/sdkEnvironment variables
RANKIGI_API_KEY: ingest API key from your RANKIGI dashboardRANKIGI_AGENT_ID: agent UUID from your RANKIGI dashboard
Notes
- Raw tool arguments and results are never transmitted. Only SHA-256 hashes and size in bytes leave the process.
- All RANKIGI calls are fire-and-forget with a 5 second timeout. They cannot throw into your tool handler.
- Optional
onErrorcallback receives any transport-layer failures for logging.
