A Model Context Protocol (MCP) server that exposes Polkadot Agent Kit capabilities as tools for AI agents and LLM applications. This server enables natural language interaction with the Polkadot ecosystem through MCP-compatible clients like Claude Desktop, Cline, and other MCP tools.
git clone <your-repo-url>
cd polkadot-agent-kit/examples/mcp-serverpnpm install --ignore-workspacepnpm run buildThe MCP server requires the following environment variable:
PRIVATE_KEY(required): Your Polkadot private key for signing transactions
To use this server with Claude Desktop or other MCP clients, add it to your MCP configuration file.
Edit your Claude Desktop configuration file (typically located at ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"polkadot-agent-kit": {
"command": "node",
"args": [
"/absolute/path/to/polkadot-agent-kit/examples/mcp-server/dist/index.js"
],
"env": {
"PRIVATE_KEY": "your_private_key_here"
}
}
}
}Important:
- Replace
/absolute/path/to/with the actual absolute path to your project - Replace
your_private_key_herewith your actual private key - Restart Claude Desktop after making changes
{
"mcpServers": {
"polkadot-agent-kit": {
"command": "node",
"args": [
"/Users/username/polkadot-agent-kit/examples/mcp-server/dist/index.js"
],
"env": {
"PRIVATE_KEY": "0x1234567890abcdef..."
}
}
}
}The MCP server communicates via stdio (standard input/output) and is designed to be launched by MCP clients. You typically don't start it manually, but for testing:
pnpm run startOr in development mode:
pnpm run devOnce configured, tools will be available automatically in your MCP client. You can interact with them through natural language queries.
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import {
CallToolRequestSchema,
ListToolsRequestSchema,
} from "@modelcontextprotocol/sdk/types.js";
import { PolkadotAgentKit, getMcpTools } from "@polkadot-agent-kit/sdk";
async function initializeServer() {
// Create MCP server
const server = new Server(
{
name: "polkadot-agent-kit",
version: "1.0.0",
},
{
capabilities: {
tools: {},
},
}
);
// Initialize the agent kit
const polkadotAgentKit = new PolkadotAgentKit({
privateKey: process.env.PRIVATE_KEY!,
});
await polkadotAgentKit.initializeApi();
// Get MCP tools
const { tools, toolHandler } = await getMcpTools(polkadotAgentKit);
// Handle tool listing
server.setRequestHandler(ListToolsRequestSchema, async () => {
return { tools };
});
// Handle tool calls
server.setRequestHandler(CallToolRequestSchema, async (request) => {
return await toolHandler(request.params.name, request.params.arguments);
});
return server;
}Apache-2.0
Contributions are welcome! Please feel free to submit a Pull Request.
For more details, see the source code in the examples/mcp-server file.