ropilot 0.1.35 → 0.1.36
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/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
|
}
|