@kasarlabs/cairo-coder-mcp 0.1.0 → 0.2.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Kasar Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  <div align="center">
2
2
  <img src="./cairo-grey.png" alt="Cairo Coder MCP Logo" width="300"/>
3
3
 
4
- [![npm version](https://img.shields.io/npm/v/@kasarlabs/cairo-coder-api.svg)](https://www.npmjs.com/package/@kasarlabs/cairo-coder-api)
5
- [![npm downloads](https://img.shields.io/npm/dm/@kasarlabs/cairo-coder-api.svg)](https://www.npmjs.com/package/@kasarlabs/cairo-coder-api)
4
+ [![npm version](https://img.shields.io/npm/v/@kasarlabs/cairo-coder-mcp.svg)](https://www.npmjs.com/package/@kasarlabs/cairo-coder-mcp)
5
+ [![npm downloads](https://img.shields.io/npm/dm/@kasarlabs/cairo-coder-mcp.svg)](https://www.npmjs.com/package/@kasarlabs/cairo-coder-mcp)
6
6
  [![GitHub stars](https://img.shields.io/github/stars/kasarlabs/cairo-coder-mcp.svg)](https://github.com/kasarlabs/cairo-coder-mcp/stargazers)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
8
  </div>
@@ -16,25 +16,29 @@ A Model Context Protocol (MCP) server for Cairo and Starknet development assista
16
16
  Use this MCP server directly with npx:
17
17
 
18
18
  ```bash
19
- npx -y @kasarlabs/cairo-coder-api
19
+ npx -y @kasarlabs/cairo-coder-mcp
20
20
  ```
21
21
 
22
22
  ## Configuration
23
23
 
24
- ### Environment Variables
24
+ The server supports two modes of operation:
25
25
 
26
- - `CAIRO_CODER_API_KEY`: Your Cairo Coder API key (required)
26
+ ### Mode 1: Public Cairo Coder API (Default)
27
+
28
+ Use the official Cairo Coder API with your API key.
29
+
30
+ **Environment Variables:**
27
31
 
28
- ### Claude Desktop Setup
32
+ - `CAIRO_CODER_API_KEY`: Your Cairo Coder API key (required)
29
33
 
30
- Add this configuration to your `claude_desktop_config.json`:
34
+ **MCP Client Setup:**
31
35
 
32
36
  ```json
33
37
  {
34
38
  "mcpServers": {
35
39
  "cairo-coder": {
36
40
  "command": "npx",
37
- "args": ["-y", "@kasarlabs/cairo-coder-api"],
41
+ "args": ["-y", "@kasarlabs/cairo-coder-mcp"],
38
42
  "env": {
39
43
  "CAIRO_CODER_API_KEY": "your-api-key-here"
40
44
  }
@@ -43,6 +47,32 @@ Add this configuration to your `claude_desktop_config.json`:
43
47
  }
44
48
  ```
45
49
 
50
+ ### Mode 2: Local/Custom Endpoint
51
+
52
+ Use a local or custom Cairo Coder API endpoint (no API key required).
53
+
54
+ **Environment Variables:**
55
+
56
+ - `CAIRO_CODER_API_ENDPOINT`: Your local endpoint URL (e.g., "http://localhost:8000")
57
+
58
+ **MCP Client Setup:**
59
+
60
+ ```json
61
+ {
62
+ "mcpServers": {
63
+ "cairo-coder": {
64
+ "command": "npx",
65
+ "args": ["-y", "@kasarlabs/cairo-coder-mcp"],
66
+ "env": {
67
+ "CAIRO_CODER_API_ENDPOINT": "http://localhost:8000"
68
+ }
69
+ }
70
+ }
71
+ }
72
+ ```
73
+
74
+ > **Note:** When using `CAIRO_CODER_API_ENDPOINT`, the server automatically switches to local mode and no API key is required or used.
75
+
46
76
  ## Available Tools
47
77
 
48
78
  ### assist_with_cairo
@@ -94,7 +124,7 @@ Get help with Cairo and Starknet development tasks.
94
124
 
95
125
  ```bash
96
126
  git clone <repository-url>
97
- cd cairo-coder-api
127
+ cd cairo-coder-mcp
98
128
  npm install
99
129
  ```
100
130
 
@@ -114,7 +144,7 @@ MIT
114
144
 
115
145
  For issues and questions:
116
146
 
117
- - GitHub Issues: [Create an issue](https://github.com/kasarlabs/cairo-coder-api/issues)
147
+ - GitHub Issues: [Create an issue](https://github.com/kasarlabs/cairo-coder-mcp/issues)
118
148
  - MCP Documentation: [Model Context Protocol](https://modelcontextprotocol.io/)
119
149
 
120
150
  ## Contributing
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import "dotenv/config";
2
+ import 'dotenv/config';
3
3
  /**
4
4
  * MCP Server implementation for Cairo Coder API integration
5
5
  * Provides AI-powered assistance for Cairo and Starknet development
@@ -16,20 +16,21 @@ declare class CairoCoderMCPServer {
16
16
  constructor();
17
17
  /**
18
18
  * Sets up the tool handlers for the MCP server
19
- * Configures the assist_with_cairo tool for Cairo/Starknet development assistance
19
+ * Configures both assist_with_cairo and starknet_general_knowledge tools
20
20
  */
21
21
  private setupToolHandlers;
22
22
  /**
23
- * Handles Cairo assistance requests by calling the Cairo Coder API
23
+ * Handles Cairo code assistance requests by calling the Cairo Coder API
24
24
  * @param args - The arguments containing query, optional code snippets, and conversation history
25
25
  * @returns The response from the Cairo Coder API or an error message
26
26
  */
27
27
  private handleCairoAssistance;
28
28
  /**
29
- * Sets up error handling for the server
30
- * Configures error logging and graceful shutdown on SIGINT
29
+ * Handles general Starknet knowledge requests by calling the Cairo Coder API
30
+ * @param args - The arguments containing query and optional conversation history
31
+ * @returns The response from the Cairo Coder API or an error message
31
32
  */
32
- private setupErrorHandling;
33
+ private handleGeneralKnowledge;
33
34
  /**
34
35
  * Starts the MCP server with stdio transport
35
36
  * @throws {Error} If the server fails to start
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,eAAe,CAAC;AAsCvB;;;GAGG;AACH,cAAM,mBAAmB;IACvB,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,WAAW,CAAU;IAE7B;;;OAGG;;IAoCH;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IA4CzB;;;;OAIG;YACW,qBAAqB;IAoFnC;;;;OAIG;YACW,sBAAsB;IAgFpC;;;OAGG;IACG,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAW3B;AAgBD,eAAe,mBAAmB,CAAC"}
package/build/index.js ADDED
@@ -0,0 +1,252 @@
1
+ #!/usr/bin/env node
2
+ import 'dotenv/config';
3
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
5
+ import packageJson from '../package.json' with { type: 'json' };
6
+ import { assistWithCairoSchema, starknetGeneralKnowledgeSchema, } from './schemas.js';
7
+ /**
8
+ * MCP Server implementation for Cairo Coder API integration
9
+ * Provides AI-powered assistance for Cairo and Starknet development
10
+ */
11
+ class CairoCoderMCPServer {
12
+ server;
13
+ apiKey;
14
+ apiUrl;
15
+ isLocalMode;
16
+ /**
17
+ * Initializes the Cairo Coder MCP Server
18
+ * @throws {Error} If CAIRO_CODER_API_KEY environment variable is not set when using public API
19
+ */
20
+ constructor() {
21
+ this.server = new McpServer({
22
+ name: 'cairo-coder-mcp',
23
+ version: packageJson.version,
24
+ });
25
+ // Check if local endpoint is specified
26
+ const localEndpoint = process.env.CAIRO_CODER_API_ENDPOINT;
27
+ if (localEndpoint) {
28
+ // Local mode: use custom endpoint, no API key required
29
+ this.isLocalMode = true;
30
+ this.apiUrl = `${localEndpoint}/v1/chat/completions`;
31
+ this.apiKey = '';
32
+ console.error(`Cairo Coder MCP server configured for local mode: ${this.apiUrl}`);
33
+ }
34
+ else {
35
+ // Public API mode: use official endpoint, API key required
36
+ this.isLocalMode = false;
37
+ this.apiUrl = 'https://api.cairo-coder.com/v1/chat/completions';
38
+ this.apiKey = process.env.CAIRO_CODER_API_KEY || '';
39
+ if (!this.apiKey) {
40
+ console.error('Error: CAIRO_CODER_API_KEY environment variable is required when using public API');
41
+ process.exit(1);
42
+ }
43
+ console.error('Cairo Coder MCP server configured for public API mode');
44
+ }
45
+ this.setupToolHandlers();
46
+ }
47
+ /**
48
+ * Sets up the tool handlers for the MCP server
49
+ * Configures both assist_with_cairo and starknet_general_knowledge tools
50
+ */
51
+ setupToolHandlers() {
52
+ // Tool 1: Cairo code assistance
53
+ this.server.tool('assist_with_cairo', `Provides technical assistance with writing, refactoring, debugging, and understanding Cairo smart contracts and programs.
54
+
55
+ Call this tool when the user needs to:
56
+ - **Write or generate Cairo code** from scratch
57
+ - **Refactor or optimize** existing Cairo code
58
+ - **Debug compilation errors** or runtime issues
59
+ - **Implement specific Cairo features** (traits, storage, events, etc.)
60
+ - **Understand Cairo syntax** and best practices
61
+ - **Complete TODO sections** in Cairo smart contracts
62
+
63
+ This tool has access to Cairo documentation, code examples, corelib references, and technical guides.
64
+
65
+ **Do NOT use this tool for general Starknet ecosystem questions or news.** Use starknet_general_knowledge instead.`, assistWithCairoSchema.shape, async (args) => {
66
+ return await this.handleCairoAssistance(args);
67
+ });
68
+ // Tool 2: Starknet general knowledge
69
+ this.server.tool('starknet_general_knowledge', `Provides general knowledge about the Starknet ecosystem, protocol concepts, recent updates, and news.
70
+
71
+ Call this tool when the user needs to:
72
+ - **Understand Starknet concepts** (account abstraction, sequencers, STARK proofs, etc.)
73
+ - **Discover ecosystem projects** and integrations
74
+ - **Get information from the Starknet blog**
75
+ - **Understand high-level architecture** and design decisions
76
+
77
+ This tool has access to Starknet blog posts, conceptual documentation, and ecosystem information.
78
+
79
+ **Do NOT use this tool for writing Cairo code.** Use assist_with_cairo instead.`, starknetGeneralKnowledgeSchema.shape, async (args) => {
80
+ return await this.handleGeneralKnowledge(args);
81
+ });
82
+ }
83
+ /**
84
+ * Handles Cairo code assistance requests by calling the Cairo Coder API
85
+ * @param args - The arguments containing query, optional code snippets, and conversation history
86
+ * @returns The response from the Cairo Coder API or an error message
87
+ */
88
+ async handleCairoAssistance(args) {
89
+ try {
90
+ const { query, codeSnippets, history } = args;
91
+ if (!query) {
92
+ throw new Error('Query parameter is required');
93
+ }
94
+ // Add context to guide the backend towards code-focused responses
95
+ let contextualMessage = `As a Cairo code expert, help with the following technical question:\n\n${query}`;
96
+ if (codeSnippets && codeSnippets.length > 0) {
97
+ contextualMessage += `\n\nCode snippets for context:\n${codeSnippets.join('\n\n')}`;
98
+ }
99
+ if (history && history.length > 0) {
100
+ contextualMessage = `Previous conversation context:\n${history.join('\n')}\n\nCurrent query: ${contextualMessage}`;
101
+ }
102
+ const requestBody = {
103
+ messages: [
104
+ {
105
+ role: 'user',
106
+ content: contextualMessage,
107
+ },
108
+ ],
109
+ };
110
+ // Prepare headers based on mode
111
+ const headers = {
112
+ 'Content-Type': 'application/json',
113
+ mcp: 'true',
114
+ };
115
+ // Only add API key header in public API mode
116
+ if (!this.isLocalMode && this.apiKey) {
117
+ headers['x-api-key'] = this.apiKey;
118
+ }
119
+ const response = await fetch(this.apiUrl, {
120
+ method: 'POST',
121
+ headers,
122
+ body: JSON.stringify(requestBody),
123
+ });
124
+ if (!response.ok) {
125
+ const errorText = await response.text();
126
+ throw new Error(`API request failed: ${response.status} ${response.statusText} - ${errorText}`);
127
+ }
128
+ const data = (await response.json());
129
+ if (!data.choices || data.choices.length === 0) {
130
+ throw new Error('No response received from Cairo Coder API');
131
+ }
132
+ const assistantResponse = data.choices[0].message.content;
133
+ return {
134
+ content: [
135
+ {
136
+ type: 'text',
137
+ text: assistantResponse,
138
+ },
139
+ ],
140
+ };
141
+ }
142
+ catch (error) {
143
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
144
+ return {
145
+ content: [
146
+ {
147
+ type: 'text',
148
+ text: `Error: ${errorMessage}`,
149
+ },
150
+ ],
151
+ isError: true,
152
+ };
153
+ }
154
+ }
155
+ /**
156
+ * Handles general Starknet knowledge requests by calling the Cairo Coder API
157
+ * @param args - The arguments containing query and optional conversation history
158
+ * @returns The response from the Cairo Coder API or an error message
159
+ */
160
+ async handleGeneralKnowledge(args) {
161
+ try {
162
+ const { query, history } = args;
163
+ if (!query) {
164
+ throw new Error('Query parameter is required');
165
+ }
166
+ // Add context to guide the backend towards general knowledge responses
167
+ let contextualMessage = `As a Starknet ecosystem expert, answer the following question about Starknet concepts, or general knowledge:\n\n${query}`;
168
+ if (history && history.length > 0) {
169
+ contextualMessage = `Previous conversation context:\n${history.join('\n')}\n\nCurrent query: ${contextualMessage}`;
170
+ }
171
+ const requestBody = {
172
+ messages: [
173
+ {
174
+ role: 'user',
175
+ content: contextualMessage,
176
+ },
177
+ ],
178
+ };
179
+ // Prepare headers based on mode
180
+ const headers = {
181
+ 'Content-Type': 'application/json',
182
+ mcp: 'true',
183
+ };
184
+ // Only add API key header in public API mode
185
+ if (!this.isLocalMode && this.apiKey) {
186
+ headers['x-api-key'] = this.apiKey;
187
+ }
188
+ const response = await fetch(this.apiUrl, {
189
+ method: 'POST',
190
+ headers,
191
+ body: JSON.stringify(requestBody),
192
+ });
193
+ if (!response.ok) {
194
+ const errorText = await response.text();
195
+ throw new Error(`API request failed: ${response.status} ${response.statusText} - ${errorText}`);
196
+ }
197
+ const data = (await response.json());
198
+ if (!data.choices || data.choices.length === 0) {
199
+ throw new Error('No response received from Cairo Coder API');
200
+ }
201
+ const assistantResponse = data.choices[0].message.content;
202
+ return {
203
+ content: [
204
+ {
205
+ type: 'text',
206
+ text: assistantResponse,
207
+ },
208
+ ],
209
+ };
210
+ }
211
+ catch (error) {
212
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
213
+ return {
214
+ content: [
215
+ {
216
+ type: 'text',
217
+ text: `Error: ${errorMessage}`,
218
+ },
219
+ ],
220
+ isError: true,
221
+ };
222
+ }
223
+ }
224
+ /**
225
+ * Starts the MCP server with stdio transport
226
+ * @throws {Error} If the server fails to start
227
+ */
228
+ async run() {
229
+ const transport = new StdioServerTransport();
230
+ console.error('Cairo Coder MCP server running on stdio');
231
+ await this.server.connect(transport);
232
+ // Handle graceful shutdown
233
+ process.on('SIGINT', async () => {
234
+ await this.server.close();
235
+ process.exit(0);
236
+ });
237
+ }
238
+ }
239
+ /**
240
+ * Main entry point for the application
241
+ * Creates and starts the Cairo Coder MCP server
242
+ */
243
+ async function main() {
244
+ const server = new CairoCoderMCPServer();
245
+ await server.run();
246
+ }
247
+ main().catch((error) => {
248
+ console.error('Fatal error in main():', error);
249
+ process.exit(1);
250
+ });
251
+ export default CairoCoderMCPServer;
252
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,WAAW,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAChE,OAAO,EACL,qBAAqB,EAErB,8BAA8B,GAE/B,MAAM,cAAc,CAAC;AA6BtB;;;GAGG;AACH,MAAM,mBAAmB;IACf,MAAM,CAAY;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,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED;;;GAGG;AACH,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,IAAI,mBAAmB,EAAE,CAAC;IACzC,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC;AACrB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Schema for the assist_with_cairo tool
4
+ * Specialized for Cairo code generation, debugging, and technical assistance
5
+ */
6
+ export declare const assistWithCairoSchema: z.ZodObject<{
7
+ query: z.ZodString;
8
+ codeSnippets: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
9
+ history: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ query: string;
12
+ codeSnippets?: string[] | undefined;
13
+ history?: string[] | undefined;
14
+ }, {
15
+ query: string;
16
+ codeSnippets?: string[] | undefined;
17
+ history?: string[] | undefined;
18
+ }>;
19
+ export type AssistWithCairoInput = z.infer<typeof assistWithCairoSchema>;
20
+ /**
21
+ * Schema for the starknet_general_knowledge tool
22
+ * Specialized for general Starknet ecosystem knowledge, concepts, and news
23
+ */
24
+ export declare const starknetGeneralKnowledgeSchema: z.ZodObject<{
25
+ query: z.ZodString;
26
+ history: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
27
+ }, "strip", z.ZodTypeAny, {
28
+ query: string;
29
+ history?: string[] | undefined;
30
+ }, {
31
+ query: string;
32
+ history?: string[] | undefined;
33
+ }>;
34
+ export type StarknetGeneralKnowledgeInput = z.infer<typeof starknetGeneralKnowledgeSchema>;
35
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;EAkBhC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEzE;;;GAGG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;EAYzC,CAAC;AAEH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CACjD,OAAO,8BAA8B,CACtC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Schema for the assist_with_cairo tool
4
+ * Specialized for Cairo code generation, debugging, and technical assistance
5
+ */
6
+ export const assistWithCairoSchema = z.object({
7
+ query: z
8
+ .string()
9
+ .describe("The user's technical question about writing, refactoring, debugging, or understanding Cairo code. Be as specific as possible for better results (e.g., 'How to implement an ERC20 transfer function with OpenZeppelin' rather than just 'ERC20')."),
10
+ codeSnippets: z
11
+ .array(z.string())
12
+ .optional()
13
+ .describe("Optional: Code snippets for context. This will help the tool understand the user's intent and provide more accurate answers. Provide as much relevant code as possible to fit the user's request."),
14
+ history: z
15
+ .array(z.string())
16
+ .optional()
17
+ .describe('Optional: The preceding conversation history. This can help the tool understand the context of the discussion and provide more accurate answers.'),
18
+ });
19
+ /**
20
+ * Schema for the starknet_general_knowledge tool
21
+ * Specialized for general Starknet ecosystem knowledge, concepts, and news
22
+ */
23
+ export const starknetGeneralKnowledgeSchema = z.object({
24
+ query: z
25
+ .string()
26
+ .describe("The user's question about Starknet ecosystem, concepts, recent updates, or general knowledge. This is for understanding the Starknet protocol, ecosystem projects, news, and high-level concepts (e.g., 'What are the latest updates in Starknet?' or 'Explain account abstraction in Starknet')."),
27
+ history: z
28
+ .array(z.string())
29
+ .optional()
30
+ .describe('Optional: The preceding conversation history. This can help the tool understand the context of the discussion and provide more accurate answers.'),
31
+ });
32
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,QAAQ,CACP,mPAAmP,CACpP;IACH,YAAY,EAAE,CAAC;SACZ,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACjB,QAAQ,EAAE;SACV,QAAQ,CACP,mMAAmM,CACpM;IACH,OAAO,EAAE,CAAC;SACP,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACjB,QAAQ,EAAE;SACV,QAAQ,CACP,kJAAkJ,CACnJ;CACJ,CAAC,CAAC;AAIH;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC,MAAM,CAAC;IACrD,KAAK,EAAE,CAAC;SACL,MAAM,EAAE;SACR,QAAQ,CACP,mSAAmS,CACpS;IACH,OAAO,EAAE,CAAC;SACP,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACjB,QAAQ,EAAE;SACV,QAAQ,CACP,kJAAkJ,CACnJ;CACJ,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,23 +1,33 @@
1
1
  {
2
2
  "name": "@kasarlabs/cairo-coder-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "MCP server to interact with the Cairo Coder API",
5
5
  "type": "module",
6
- "main": "dist/index.js",
6
+ "main": "build/index.js",
7
7
  "exports": {
8
8
  ".": {
9
- "import": "./dist/index.js",
10
- "types": "./dist/index.d.ts"
9
+ "import": "./build/index.js",
10
+ "types": "./build/index.d.ts"
11
11
  }
12
12
  },
13
13
  "bin": {
14
- "cairo-coder-api": "./dist/index.js"
14
+ "cairo-coder-mcp": "./build/index.js"
15
15
  },
16
16
  "files": [
17
- "dist",
17
+ "build",
18
18
  "README.md",
19
19
  "LICENSE"
20
20
  ],
21
+ "scripts": {
22
+ "build": "tsc && chmod +x build/index.js",
23
+ "start": "node build/index.js",
24
+ "dev": "tsx src/index.ts",
25
+ "lint": "eslint src/**/*.ts",
26
+ "lint:fix": "eslint src/**/*.ts --fix",
27
+ "clean": "rm -rf build node_modules",
28
+ "prepublishOnly": "npm run clean && npm install && npm run build",
29
+ "test": "echo \"Error: no test specified\" && exit 1"
30
+ },
21
31
  "keywords": [
22
32
  "mcp",
23
33
  "cairo",
@@ -33,9 +43,9 @@
33
43
  "access": "public"
34
44
  },
35
45
  "dependencies": {
36
- "@modelcontextprotocol/sdk": "^0.4.0",
46
+ "@modelcontextprotocol/sdk": "^1.11.2",
37
47
  "dotenv": "^16.5.0",
38
- "node-fetch": "^3.3.2"
48
+ "zod": "^3.24.2"
39
49
  },
40
50
  "devDependencies": {
41
51
  "@types/node": "^20.0.0",
@@ -50,19 +60,12 @@
50
60
  },
51
61
  "repository": {
52
62
  "type": "git",
53
- "url": "https://github.com/kasarlabs/cairo-coder-mcp"
63
+ "url": "https://github.com/kasarlabs/ask-starknet",
64
+ "directory": "packages/mcps/cairo-coder"
54
65
  },
55
66
  "bugs": {
56
- "url": "https://github.com/kasarlabs/cairo-coder-mcp/issues"
67
+ "url": "https://github.com/kasarlabs/ask-starknet/issues"
57
68
  },
58
- "homepage": "https://github.com/kasarlabs/cairo-coder-mcp#readme",
59
- "scripts": {
60
- "build": "tsc && chmod +x dist/index.js",
61
- "start": "node dist/index.js",
62
- "dev": "tsx src/index.ts",
63
- "lint": "eslint src/**/*.ts",
64
- "lint:fix": "eslint src/**/*.ts --fix",
65
- "clean": "rm -rf dist node_modules",
66
- "test": "echo \"Error: no test specified\" && exit 1"
67
- }
68
- }
69
+ "homepage": "https://github.com/kasarlabs/ask-starknet/tree/main/packages/mcps/cairo-coder#readme",
70
+ "gitHead": "2239ec60f8e369abd318807cecd22fe97c0ab917"
71
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,eAAe,CAAC;AAsCvB;;;GAGG;AACH,cAAM,mBAAmB;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,WAAW,CAAU;IAE7B;;;OAGG;;IAwCH;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IA8DzB;;;;OAIG;YACW,qBAAqB;IAuFnC;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAW1B;;;OAGG;IACG,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAK3B;AAgBD,eAAe,mBAAmB,CAAC"}
package/dist/index.js DELETED
@@ -1,211 +0,0 @@
1
- #!/usr/bin/env node
2
- import "dotenv/config";
3
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
4
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
- import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
6
- import fetch from "node-fetch";
7
- /**
8
- * MCP Server implementation for Cairo Coder API integration
9
- * Provides AI-powered assistance for Cairo and Starknet development
10
- */
11
- class CairoCoderMCPServer {
12
- server;
13
- apiKey;
14
- apiUrl;
15
- isLocalMode;
16
- /**
17
- * Initializes the Cairo Coder MCP Server
18
- * @throws {Error} If CAIRO_CODER_API_KEY environment variable is not set when using public API
19
- */
20
- constructor() {
21
- this.server = new Server({
22
- name: "cairo-coder-api",
23
- version: "1.0.0",
24
- capabilities: {
25
- tools: {},
26
- },
27
- });
28
- // Check if local endpoint is specified
29
- const localEndpoint = process.env.CAIRO_CODER_API_ENDPOINT;
30
- if (localEndpoint) {
31
- // Local mode: use custom endpoint, no API key required
32
- this.isLocalMode = true;
33
- this.apiUrl = `${localEndpoint}/v1/chat/completions`;
34
- this.apiKey = "";
35
- console.error(`Cairo Coder MCP server configured for local mode: ${this.apiUrl}`);
36
- }
37
- else {
38
- // Public API mode: use official endpoint, API key required
39
- this.isLocalMode = false;
40
- this.apiUrl = "https://api.cairo-coder.com/v1/chat/completions";
41
- this.apiKey = process.env.CAIRO_CODER_API_KEY || "";
42
- if (!this.apiKey) {
43
- console.error("Error: CAIRO_CODER_API_KEY environment variable is required when using public API");
44
- process.exit(1);
45
- }
46
- console.error("Cairo Coder MCP server configured for public API mode");
47
- }
48
- this.setupToolHandlers();
49
- this.setupErrorHandling();
50
- }
51
- /**
52
- * Sets up the tool handlers for the MCP server
53
- * Configures the assist_with_cairo tool for Cairo/Starknet development assistance
54
- */
55
- setupToolHandlers() {
56
- this.server.setRequestHandler(ListToolsRequestSchema, async () => {
57
- return {
58
- tools: [
59
- {
60
- name: "assist_with_cairo",
61
- description: `Provides assistance with Cairo and Starknet development tasks through AI-powered analysis.
62
-
63
- Call this tool when the user's request involves **writing, refactoring, implementing from scratch, or completing specific parts (like TODOs)** of Cairo code or smart contracts.
64
-
65
- The tool analyzes the query and context against Cairo/Starknet best practices and documentation, returning helpful information to generate accurate code or explanations.
66
-
67
- This tool should also be called to get a better understanding of Starknet's ecosystem, features, and capacities.`,
68
- inputSchema: {
69
- type: "object",
70
- properties: {
71
- query: {
72
- type: "string",
73
- description: "The user's question regarding Cairo and Starknet development. Try to be as specific as possible for better results (e.g., 'Using OpenZeppelin to build an ERC20' rather than just 'ERC20').",
74
- },
75
- codeSnippets: {
76
- type: "array",
77
- items: {
78
- type: "string",
79
- },
80
- description: "Optional: Code snippets for context. This will help the tool understand the user's intent and provide more accurate answers. Provide as much relevant code as possible to fit the user's request.",
81
- },
82
- history: {
83
- type: "array",
84
- items: {
85
- type: "string",
86
- },
87
- description: "Optional: The preceding conversation history. This can help the tool understand the context of the discussion and provide more accurate answers.",
88
- },
89
- },
90
- required: ["query"],
91
- },
92
- },
93
- ],
94
- };
95
- });
96
- this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
97
- const { name, arguments: args } = request.params;
98
- if (name === "assist_with_cairo") {
99
- return await this.handleCairoAssistance(args);
100
- }
101
- throw new Error(`Unknown tool: ${name}`);
102
- });
103
- }
104
- /**
105
- * Handles Cairo assistance requests by calling the Cairo Coder API
106
- * @param args - The arguments containing query, optional code snippets, and conversation history
107
- * @returns The response from the Cairo Coder API or an error message
108
- */
109
- async handleCairoAssistance(args) {
110
- try {
111
- const { query, codeSnippets, history } = args;
112
- if (!query) {
113
- throw new Error("Query parameter is required");
114
- }
115
- let contextualMessage = query;
116
- if (codeSnippets && codeSnippets.length > 0) {
117
- contextualMessage += `\n\nCode snippets for context:\n${codeSnippets.join("\n\n")}`;
118
- }
119
- if (history && history.length > 0) {
120
- contextualMessage = `Previous conversation context:\n${history.join("\n")}\n\nCurrent query: ${contextualMessage}`;
121
- }
122
- const requestBody = {
123
- messages: [
124
- {
125
- role: "user",
126
- content: contextualMessage,
127
- },
128
- ],
129
- };
130
- // Prepare headers based on mode
131
- const headers = {
132
- "Content-Type": "application/json",
133
- mcp: "true",
134
- };
135
- // Only add API key header in public API mode
136
- if (!this.isLocalMode && this.apiKey) {
137
- headers["x-api-key"] = this.apiKey;
138
- }
139
- const response = await fetch(this.apiUrl, {
140
- method: "POST",
141
- headers,
142
- body: JSON.stringify(requestBody),
143
- });
144
- if (!response.ok) {
145
- const errorText = await response.text();
146
- throw new Error(`API request failed: ${response.status} ${response.statusText} - ${errorText}`);
147
- }
148
- const data = (await response.json());
149
- if (!data.choices || data.choices.length === 0) {
150
- throw new Error("No response received from Cairo Coder API");
151
- }
152
- const assistantResponse = data.choices[0].message.content;
153
- return {
154
- content: [
155
- {
156
- type: "text",
157
- text: assistantResponse,
158
- },
159
- ],
160
- };
161
- }
162
- catch (error) {
163
- const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
164
- return {
165
- content: [
166
- {
167
- type: "text",
168
- text: `Error: ${errorMessage}`,
169
- },
170
- ],
171
- isError: true,
172
- };
173
- }
174
- }
175
- /**
176
- * Sets up error handling for the server
177
- * Configures error logging and graceful shutdown on SIGINT
178
- */
179
- setupErrorHandling() {
180
- this.server.onerror = (error) => {
181
- console.error("[MCP Error]", error);
182
- };
183
- process.on("SIGINT", async () => {
184
- await this.server.close();
185
- process.exit(0);
186
- });
187
- }
188
- /**
189
- * Starts the MCP server with stdio transport
190
- * @throws {Error} If the server fails to start
191
- */
192
- async run() {
193
- const transport = new StdioServerTransport();
194
- console.error("Cairo Coder MCP server running on stdio");
195
- await this.server.connect(transport);
196
- }
197
- }
198
- /**
199
- * Main entry point for the application
200
- * Creates and starts the Cairo Coder MCP server
201
- */
202
- async function main() {
203
- const server = new CairoCoderMCPServer();
204
- await server.run();
205
- }
206
- main().catch((error) => {
207
- console.error("Fatal error in main():", error);
208
- process.exit(1);
209
- });
210
- export default CairoCoderMCPServer;
211
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GAEvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,MAAM,YAAY,CAAC;AA8B/B;;;GAGG;AACH,MAAM,mBAAmB;IACf,MAAM,CAAS;IACf,MAAM,CAAS;IACf,MAAM,CAAS;IACf,WAAW,CAAU;IAE7B;;;OAGG;IACH;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC;YACvB,IAAI,EAAE,iBAAiB;YACvB,OAAO,EAAE,OAAO;Y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