@meldocio/mcp-stdio-proxy 1.0.1 → 1.0.2
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/bin/meldoc-mcp-proxy.js +71 -1
- package/package.json +1 -1
package/bin/meldoc-mcp-proxy.js
CHANGED
|
@@ -127,7 +127,19 @@ async function handleRequest(request) {
|
|
|
127
127
|
// Process batch requests sequentially
|
|
128
128
|
for (const req of request) {
|
|
129
129
|
if (req) {
|
|
130
|
-
|
|
130
|
+
// Check if this is a protocol method that should be handled locally
|
|
131
|
+
const method = req.method;
|
|
132
|
+
if (method === 'initialize') {
|
|
133
|
+
handleInitialize(req);
|
|
134
|
+
} else if (method === 'initialized') {
|
|
135
|
+
// Notification - no response needed
|
|
136
|
+
continue;
|
|
137
|
+
} else if (method === 'ping') {
|
|
138
|
+
handlePing(req);
|
|
139
|
+
} else {
|
|
140
|
+
// Forward to backend
|
|
141
|
+
await processSingleRequest(req);
|
|
142
|
+
}
|
|
131
143
|
}
|
|
132
144
|
}
|
|
133
145
|
return;
|
|
@@ -140,11 +152,69 @@ async function handleRequest(request) {
|
|
|
140
152
|
return;
|
|
141
153
|
}
|
|
142
154
|
|
|
155
|
+
// Handle MCP protocol methods locally (not forwarded to backend)
|
|
156
|
+
const method = request.method;
|
|
157
|
+
if (method === 'initialize') {
|
|
158
|
+
handleInitialize(request);
|
|
159
|
+
return;
|
|
160
|
+
} else if (method === 'initialized') {
|
|
161
|
+
// Notification - no response needed per MCP spec
|
|
162
|
+
return;
|
|
163
|
+
} else if (method === 'ping') {
|
|
164
|
+
handlePing(request);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// All other methods (tools/*, resources/*, etc.) are forwarded to backend
|
|
143
169
|
await processSingleRequest(request);
|
|
144
170
|
}
|
|
145
171
|
|
|
172
|
+
/**
|
|
173
|
+
* Handle MCP initialize method
|
|
174
|
+
* This is called by Claude Desktop to establish the connection
|
|
175
|
+
*/
|
|
176
|
+
function handleInitialize(request) {
|
|
177
|
+
const response = {
|
|
178
|
+
jsonrpc: '2.0',
|
|
179
|
+
id: request.id,
|
|
180
|
+
result: {
|
|
181
|
+
protocolVersion: '2025-06-18',
|
|
182
|
+
capabilities: {
|
|
183
|
+
tools: {},
|
|
184
|
+
resources: {}
|
|
185
|
+
},
|
|
186
|
+
serverInfo: {
|
|
187
|
+
name: '@meldocio/mcp-stdio-proxy',
|
|
188
|
+
version: '1.0.1'
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
process.stdout.write(JSON.stringify(response) + '\n');
|
|
194
|
+
if (process.stdout.isTTY) {
|
|
195
|
+
process.stdout.flush();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Handle MCP ping method (keep-alive)
|
|
201
|
+
*/
|
|
202
|
+
function handlePing(request) {
|
|
203
|
+
const response = {
|
|
204
|
+
jsonrpc: '2.0',
|
|
205
|
+
id: request.id,
|
|
206
|
+
result: {}
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
process.stdout.write(JSON.stringify(response) + '\n');
|
|
210
|
+
if (process.stdout.isTTY) {
|
|
211
|
+
process.stdout.flush();
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
146
215
|
/**
|
|
147
216
|
* Process a single JSON-RPC request
|
|
217
|
+
* Forwards the request to the backend MCP API
|
|
148
218
|
*/
|
|
149
219
|
async function processSingleRequest(request) {
|
|
150
220
|
try {
|