ropilot 0.1.35 → 0.1.37
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/lib/proxy.js +50 -5
- package/lib/setup.js +28 -22
- package/package.json +1 -1
package/lib/proxy.js
CHANGED
|
@@ -70,25 +70,70 @@ async function forwardToEdge(apiKey, request) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
* Handle MCP initialize request
|
|
73
|
+
* Handle MCP initialize request
|
|
74
|
+
* Always succeed so Claude doesn't mark server as failed
|
|
75
|
+
* Errors will surface when tools are actually called
|
|
74
76
|
*/
|
|
75
77
|
async function handleInitialize(apiKey, request) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
+
try {
|
|
79
|
+
const edgeResponse = await forwardToEdge(apiKey, request);
|
|
80
|
+
return edgeResponse;
|
|
81
|
+
} catch (err) {
|
|
82
|
+
// Return a minimal valid response so MCP connects
|
|
83
|
+
// The error will surface when user tries to use tools
|
|
84
|
+
return {
|
|
85
|
+
jsonrpc: '2.0',
|
|
86
|
+
id: request.id,
|
|
87
|
+
result: {
|
|
88
|
+
protocolVersion: '2024-11-05',
|
|
89
|
+
capabilities: { tools: {} },
|
|
90
|
+
serverInfo: { name: 'ropilot', version: '1.0.0' }
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
78
94
|
}
|
|
79
95
|
|
|
96
|
+
// Cache the error from initialize for showing in tools
|
|
97
|
+
let cachedKeyError = null;
|
|
98
|
+
|
|
80
99
|
/**
|
|
81
100
|
* Handle MCP tools/list request
|
|
101
|
+
* If key is invalid, return a helper tool that explains the error
|
|
82
102
|
*/
|
|
83
103
|
async function handleToolsList(apiKey, request) {
|
|
84
|
-
|
|
85
|
-
|
|
104
|
+
try {
|
|
105
|
+
return await forwardToEdge(apiKey, request);
|
|
106
|
+
} catch (err) {
|
|
107
|
+
cachedKeyError = err.message;
|
|
108
|
+
// Return a single tool that explains the error when called
|
|
109
|
+
return {
|
|
110
|
+
jsonrpc: '2.0',
|
|
111
|
+
id: request.id,
|
|
112
|
+
result: {
|
|
113
|
+
tools: [{
|
|
114
|
+
name: 'ropilot_status',
|
|
115
|
+
description: err.message,
|
|
116
|
+
inputSchema: { type: 'object', properties: {} }
|
|
117
|
+
}]
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
86
121
|
}
|
|
87
122
|
|
|
88
123
|
/**
|
|
89
124
|
* Handle MCP tools/call request
|
|
90
125
|
*/
|
|
91
126
|
async function handleToolsCall(apiKey, request) {
|
|
127
|
+
// If we have a cached error and user is calling our status tool, return the error
|
|
128
|
+
if (cachedKeyError && request.params?.name === 'ropilot_status') {
|
|
129
|
+
return {
|
|
130
|
+
jsonrpc: '2.0',
|
|
131
|
+
id: request.id,
|
|
132
|
+
result: {
|
|
133
|
+
content: [{ type: 'text', text: cachedKeyError }]
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
92
137
|
// Forward to edge
|
|
93
138
|
return await forwardToEdge(apiKey, request);
|
|
94
139
|
}
|
package/lib/setup.js
CHANGED
|
@@ -245,20 +245,6 @@ function getDefaultPrompts() {
|
|
|
245
245
|
};
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
/**
|
|
249
|
-
* Generate .mcp.json for Claude Code MCP server configuration
|
|
250
|
-
*/
|
|
251
|
-
function generateMcpJson() {
|
|
252
|
-
return JSON.stringify({
|
|
253
|
-
mcpServers: {
|
|
254
|
-
ropilot: {
|
|
255
|
-
command: "npx",
|
|
256
|
-
args: ["ropilot", "serve"]
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}, null, 2);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
248
|
/**
|
|
263
249
|
* Set up agent files in current project
|
|
264
250
|
*/
|
|
@@ -302,20 +288,40 @@ function setupProjectPrompts(pkg) {
|
|
|
302
288
|
}
|
|
303
289
|
}
|
|
304
290
|
|
|
305
|
-
//
|
|
306
|
-
const mcpJson = generateMcpJson();
|
|
291
|
+
// Update .mcp.json - preserve existing servers, only add/update ropilot
|
|
307
292
|
const mcpPath = '.mcp.json';
|
|
293
|
+
const ropilotServer = {
|
|
294
|
+
command: "npx",
|
|
295
|
+
args: ["ropilot", "serve"]
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
let mcpConfig = { mcpServers: {} };
|
|
308
299
|
if (existsSync(mcpPath)) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
300
|
+
try {
|
|
301
|
+
const existing = readFileSync(mcpPath, 'utf-8');
|
|
302
|
+
mcpConfig = JSON.parse(existing);
|
|
303
|
+
if (!mcpConfig.mcpServers) {
|
|
304
|
+
mcpConfig.mcpServers = {};
|
|
305
|
+
}
|
|
306
|
+
} catch {
|
|
307
|
+
// Invalid JSON, start fresh but warn user
|
|
308
|
+
console.log('Warning: .mcp.json was invalid, recreating it');
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const existingRopilot = mcpConfig.mcpServers.ropilot;
|
|
313
|
+
const ropilotChanged = JSON.stringify(existingRopilot) !== JSON.stringify(ropilotServer);
|
|
314
|
+
|
|
315
|
+
if (ropilotChanged) {
|
|
316
|
+
mcpConfig.mcpServers.ropilot = ropilotServer;
|
|
317
|
+
writeFileSync(mcpPath, JSON.stringify(mcpConfig, null, 2));
|
|
318
|
+
if (existingRopilot) {
|
|
312
319
|
updated++;
|
|
313
320
|
} else {
|
|
314
|
-
|
|
321
|
+
created++;
|
|
315
322
|
}
|
|
316
323
|
} else {
|
|
317
|
-
|
|
318
|
-
created++;
|
|
324
|
+
skipped++;
|
|
319
325
|
}
|
|
320
326
|
|
|
321
327
|
console.log(`Project files: ${created} created, ${updated} updated, ${skipped} unchanged`);
|