Skip to Content
TypeScript SDKMCP (Model Context Protocol)

Model Context Protocol (MCP)

The zkstash SDK includes a fully compliant client for the Model Context Protocol (MCP). This allows you to connect zkstash directly to LLMs (like Claude) or agent frameworks (like LangChain) as a tool provider.

How it Works

The MCP server dynamically exposes your registered schemas as tools that the LLM can call.

  1. Schema -> Tool: A schema named user_profile becomes a tool create_user_profile.
  2. Search Tool: A built-in search_memories tool is always available for the LLM to retrieve context.
  3. Automatic Execution: When the LLM calls a tool, the MCP client handles the request, including authentication and payments, and returns the result to the model.

Initialization

Initialize the MCP client pointing to the MCP endpoint.

import * as MCP from "@zkstash/sdk/mcp"; const authPrivateKey = process.env.AUTH_PRIVATE_KEY; const mcpClient = await MCP.fromPrivateKey( authPrivateKey, { agentId: "agent-007", mcpUrl: "https://zkstash.ai/mcp" } );

Usage with LangChain

The most common use case is integrating with LangChain.

import { ChatAnthropic } from "@langchain/anthropic"; import { createReactAgent } from "@langchain/langgraph/prebuilt"; // 1. Get all available tools (Search + All Schemas) const tools = await mcpClient.getTools(); // 2. Create the agent const agent = createReactAgent({ llm: new ChatAnthropic({ model: "claude-haiku-4-5" }), tools: tools }); // 3. Run the agent const result = await agent.invoke({ messages: [{ role: "user", content: "My favorite color is blue." }] });
Last updated on