stellar-devkit-mcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/index.js ADDED
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env node
2
+ #!/usr/bin/env node
3
+
4
+ // src/index.ts
5
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
6
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
7
+ import {
8
+ CallToolRequestSchema,
9
+ ListResourcesRequestSchema,
10
+ ListToolsRequestSchema,
11
+ ReadResourceRequestSchema
12
+ } from "@modelcontextprotocol/sdk/types.js";
13
+
14
+ // src/resources/stellar.ts
15
+ var STELLAR_RESOURCES = {
16
+ "stellar://networks": {
17
+ description: "Stellar network config (Horizon, Soroban RPC)",
18
+ content: `# Stellar Networks
19
+
20
+ | Network | Horizon | Soroban RPC |
21
+ |---------|---------|-------------|
22
+ | testnet | https://horizon-testnet.stellar.org | https://soroban-testnet.stellar.org |
23
+ | mainnet | https://horizon.stellar.org | https://soroban-rpc.mainnet.stellar.gateway.fm |
24
+ `
25
+ },
26
+ "stellar://contracts": {
27
+ description: "Protocol contract IDs (SoroSwap aggregator)",
28
+ content: `# Contract Addresses (Soroban)
29
+
30
+ - SoroSwap Aggregator testnet: CCJUD55AG6W5HAI5LRVNKAE5WDP5XGZBUDS5WNTIVDU7O264UZZE7BRD
31
+ - SoroSwap Aggregator mainnet: CAG5LRYQ5JVEUI5TEID72EYOVX44TTUJT5BQR2J6J77FH65PCCFAJDDH
32
+ `
33
+ },
34
+ "stellar://assets": {
35
+ description: "Testnet and mainnet asset identifiers",
36
+ content: `# Token / Asset Addresses
37
+
38
+ Testnet: XLM (wrapped) CDLZFC3..., USDC CBBHRKEP5...; AUSDC classic GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN
39
+ Mainnet: XLM CAS3J7GY..., USDC CCW67TSZV3...
40
+ `
41
+ }
42
+ };
43
+
44
+ // src/index.ts
45
+ var server = new Server(
46
+ { name: "stellar-devkit-mcp", version: "1.0.0" },
47
+ { capabilities: { resources: {}, tools: {} } }
48
+ );
49
+ server.setRequestHandler(ListResourcesRequestSchema, async () => ({
50
+ resources: Object.entries(STELLAR_RESOURCES).map(([uri, info]) => ({
51
+ uri,
52
+ name: uri.replace("stellar://", ""),
53
+ description: info.description,
54
+ mimeType: "text/markdown"
55
+ }))
56
+ }));
57
+ server.setRequestHandler(ReadResourceRequestSchema, async (req) => {
58
+ const r = STELLAR_RESOURCES[req.params.uri];
59
+ if (!r) throw new Error(`Resource not found: ${req.params.uri}`);
60
+ return { contents: [{ uri: req.params.uri, mimeType: "text/markdown", text: r.content }] };
61
+ });
62
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
63
+ tools: [
64
+ {
65
+ name: "get_stellar_contract",
66
+ description: "Get Soroban contract ID for a protocol (e.g. soroswap testnet/mainnet)",
67
+ inputSchema: {
68
+ type: "object",
69
+ properties: { protocol: { type: "string" }, network: { type: "string", enum: ["testnet", "mainnet"] } },
70
+ required: ["protocol"]
71
+ }
72
+ },
73
+ {
74
+ name: "get_sdk_snippet",
75
+ description: "Get code snippet for StellarAgentKit or x402 usage",
76
+ inputSchema: {
77
+ type: "object",
78
+ properties: { operation: { type: "string", enum: ["swap", "quote", "x402-server", "x402-client"] } },
79
+ required: ["operation"]
80
+ }
81
+ }
82
+ ]
83
+ }));
84
+ server.setRequestHandler(CallToolRequestSchema, async (req) => {
85
+ const { name, arguments: args } = req.params;
86
+ if (name === "get_stellar_contract") {
87
+ const protocol = args?.protocol?.toLowerCase() || "";
88
+ const network = (args?.network || "testnet").toLowerCase();
89
+ const ids = protocol === "soroswap" ? { testnet: "CCJUD55AG6W5HAI5LRVNKAE5WDP5XGZBUDS5WNTIVDU7O264UZZE7BRD", mainnet: "CAG5LRYQ5JVEUI5TEID72EYOVX44TTUJT5BQR2J6J77FH65PCCFAJDDH" } : null;
90
+ const text = ids ? `${protocol} ${network}: ${ids[network]}` : `Unknown protocol: ${protocol}`;
91
+ return { content: [{ type: "text", text }] };
92
+ }
93
+ if (name === "get_sdk_snippet") {
94
+ const op = args?.operation?.toLowerCase() || "";
95
+ const snippets = {
96
+ swap: "const agent = new StellarAgentKit(secretKey, 'testnet'); await agent.initialize(); const quote = await agent.dexGetQuote(fromAsset, toAsset, amount); await agent.dexSwap(quote);",
97
+ quote: "await agent.dexGetQuote({ contractId: '...' }, { contractId: '...' }, amount);",
98
+ "x402-server": "app.use('/api/premium', x402({ price: '1', assetCode: 'XLM', network: 'testnet', destination: 'G...' }));",
99
+ "x402-client": "await x402Fetch(url, init, { payWithStellar: async (req) => { /* Freighter payment */ return { transactionHash: txHash }; } });"
100
+ };
101
+ const text = snippets[op] || `Unknown operation: ${op}. Use: ${Object.keys(snippets).join(", ")}`;
102
+ return { content: [{ type: "text", text }] };
103
+ }
104
+ throw new Error(`Unknown tool: ${name}`);
105
+ });
106
+ async function main() {
107
+ const transport = new StdioServerTransport();
108
+ await server.connect(transport);
109
+ console.error("Stellar DevKit MCP running on stdio");
110
+ }
111
+ main().catch((e) => {
112
+ console.error(e);
113
+ process.exit(1);
114
+ });
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "stellar-devkit-mcp",
3
+ "version": "1.0.0",
4
+ "description": "MCP server for Stellar DevKit – docs, contract addresses, code snippets",
5
+ "type": "module",
6
+ "bin": "./dist/index.js",
7
+ "main": "./dist/index.js",
8
+ "scripts": {
9
+ "build": "tsup",
10
+ "typecheck": "tsc --noEmit",
11
+ "prepublishOnly": "npm run build"
12
+ },
13
+ "dependencies": {
14
+ "@modelcontextprotocol/sdk": "^1.0.0"
15
+ },
16
+ "devDependencies": {
17
+ "tsup": "^8.5.0",
18
+ "typescript": "^5.3.0"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/codewmilan/stellar-agent-kit.git"
23
+ },
24
+ "license": "MIT",
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "types": "./dist/index.d.ts"
35
+ }