Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default tseslint.config(
},
languageOptions: {
parserOptions: {
project: ["./packages/*/tsconfig*.json"],
project: ["./packages/*/tsconfig*.json", "./examples/*/tsconfig.json"],
tsconfigRootDir: import.meta.dirname,
},
},
Expand Down Expand Up @@ -97,22 +97,5 @@ export default tseslint.config(

},
},
{
files: ["packages/mcp/**"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-return": "off",
"no-console": "off",
"@typescript-eslint/no-unsafe-argument":"off",
"@typescript-eslint/require-await":"off",
"@typescript-eslint/no-unused-vars":"off",
"@typescript-eslint/no-misused-promises":"off",
"@typescript-eslint/unbound-method":"off"

},
}
);

8 changes: 8 additions & 0 deletions examples/mcp-server/.prettierrrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"arrowParens": "avoid",
"bracketSpacing": true,
"semi": false,
"printWidth": 100,
"tabWidth": 2,
"trailingComma": "none"
}
14 changes: 14 additions & 0 deletions examples/mcp-server/claude_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"mcpServers": {
"agentkit": {
"command": "node",
"args": [
"/Users/YOUR-USERNAME/polkadot-agent-kit/examples/mcp-server/dist/index.js"
],
"env": {
"PRIVATE_KEY": "YOUR PRIVATE_KEY"

}
}
}
}
86 changes: 86 additions & 0 deletions examples/mcp-server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
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";


function validateEnvironment(): void {
const requiredVars = ["PRIVATE_KEY"];
const missingVars = requiredVars.filter(varName => !process.env[varName]);

if (missingVars.length > 0) {
const errorMessage = `Missing required environment variables: ${missingVars.join(', ')}`;
throw new Error(errorMessage);
}
}



async function initializeServer() {
try {
// 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;
} catch (error) {
console.error("Failed to initialize server:", error);
throw error;
}
}

/**
* Main function to run the Polkadot MCP server
*/
async function main() {
try {
validateEnvironment();
const server = await initializeServer();
const transport = new StdioServerTransport();
await server.connect(transport);
console.error("Polkadot Agent Kit MCP Server running on stdio");
} catch (error) {
console.error("Fatal error:", error);
process.exit(1);
}
}

if (require.main === module) {
main().catch(error => {
console.error("Fatal error in main():", error);
process.exit(1);
});
}
22 changes: 22 additions & 0 deletions examples/mcp-server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Polkadot Agent Kit MCP Server",
"description": "Example Model Context Protocol Server for Polkadot Agent Kit",
"version": "1.0.0",
"private": true,
"author": "Polkadot Agent Kit",
"license": "Apache-2.0",
"scripts": {
"build": "tsc",
"start": "node dist/index.js",
"dev": "pnpm build && pnpm start"
},
"dependencies": {
"@polkadot-agent-kit/sdk": "workspace:*",
"@modelcontextprotocol/sdk": "^1.6.1",
"zod": "^3.22.4"
},
"devDependencies": {
"nodemon": "^3.1.0",
"ts-node": "^10.9.2"
}
}
12 changes: 12 additions & 0 deletions examples/mcp-server/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "ES2015",
"module": "ESNext",
"moduleResolution": "Node",
"esModuleInterop": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"strict": true
}
}

13 changes: 7 additions & 6 deletions packages/mcp/tsconfig.json → examples/mcp-server/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "Node",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"noImplicitAny": true,
"resolveJsonModule": true,
"strictNullChecks": true,
"skipLibCheck": true
},
"include": ["src"]
}
"skipLibCheck": true,
"outDir": "./dist",
"rootDir": ".",
}
}
4 changes: 1 addition & 3 deletions examples/telegram-bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
"dev": "jiti ./src/index.ts",
"build": "tsc",
"start": "node ./dist/index.js",
"clean": "rm -rf dist",
"lint": "eslint --fix --quiet src/**/*.ts",
"format": "prettier --loglevel silent --write src/**/*.ts"
"clean": "rm -rf dist"
},
"dependencies": {
"dotenv": "^16.5.0",
Expand Down
133 changes: 0 additions & 133 deletions packages/mcp/CHANGELOG.md

This file was deleted.

Loading