@luutuankiet/mcp-proxy-shim 1.0.7 → 1.1.0-dev.1

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/dist/index.js CHANGED
@@ -1,586 +1,55 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * MCP Stdio Shim
3
+ * MCP Proxy Shim — Unified Entry Point
4
4
  *
5
- * A schema-transforming MCP proxy that sits between Claude Code (stdio)
6
- * and mcpproxy-go (StreamableHTTP).
7
- *
8
- * What it does:
9
- * - Passes through ALL upstream tools unchanged (retrieve_tools, upstream_servers, etc.)
10
- * - Transforms call_tool_read / call_tool_write / call_tool_destructive schemas:
11
- * upstream args_json:string → downstream args:object
12
- * - On tool call: serializes args back to args_json before forwarding upstream
13
- *
14
- * Why not use SDK StreamableHTTPClientTransport:
15
- * - Bug #396: 2nd callTool times out (broken session multiplexing)
16
- * - We use plain fetch for upstream — reliable, simple, zero SDK client bugs
17
- *
18
- * Why low-level Server class (not McpServer):
19
- * - Bug #893: McpServer.registerTool() breaks dynamic registration post-connect
20
- * - Low-level Server.setRequestHandler() works correctly
5
+ * Subcommands:
6
+ * (default) stdio transport for local MCP clients (Claude Code, Cursor, etc.)
7
+ * serve HTTP Streamable transport — for remote agents over HTTP
21
8
  *
22
9
  * Usage:
10
+ * # Stdio mode (default)
23
11
  * MCP_URL="https://proxy.example.com/mcp/?apikey=KEY" npx @luutuankiet/mcp-proxy-shim
24
12
  *
25
- * .mcp.json entry:
13
+ * # HTTP server mode
14
+ * MCP_URL="https://proxy.example.com/mcp/?apikey=KEY" npx @luutuankiet/mcp-proxy-shim serve
15
+ * MCP_URL="..." MCP_PORT=8080 npx @luutuankiet/mcp-proxy-shim serve
16
+ *
17
+ * .mcp.json entry (stdio):
26
18
  * { "mcpServers": { "proxy": { "type": "stdio", "command": "npx", "args": ["-y", "@luutuankiet/mcp-proxy-shim"], "env": { "MCP_URL": "..." } } } }
27
19
  */
28
- import { Server } from "@modelcontextprotocol/sdk/server/index.js";
29
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
30
- import { ListToolsRequestSchema, CallToolRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
31
- // Proxy support Node 22 built-in undici honors https_proxy via ProxyAgent
32
- // This makes the shim work in both native sessions (no proxy) and cloud sandboxes
33
- import { createRequire } from "node:module";
34
- const _require = createRequire(import.meta.url);
35
- const { ProxyAgent } = _require("undici");
36
- // ---------------------------------------------------------------------------
37
- // Config
38
- // ---------------------------------------------------------------------------
39
- const UPSTREAM_URL = process.env.MCP_URL ?? (() => {
40
- console.error("[mcp-shim] Fatal: MCP_URL environment variable is required.");
41
- console.error("[mcp-shim] Example: MCP_URL='https://your-proxy/mcp/?apikey=KEY' mcp-proxy-shim");
20
+ const subcommand = process.argv[2];
21
+ // Handle --help before any imports (avoids MCP_URL validation in core.ts)
22
+ if (subcommand === "--help" || subcommand === "-h") {
23
+ console.log("mcp-proxy-shimMCP proxy with schema transforms");
24
+ console.log("");
25
+ console.log("Usage: mcp-proxy-shim [serve]");
26
+ console.log("");
27
+ console.log("Subcommands:");
28
+ console.log(" (default) stdio transport for local MCP clients");
29
+ console.log(" serve HTTP Streamable server for remote agents");
30
+ console.log("");
31
+ console.log("Environment variables:");
32
+ console.log(" MCP_URL (required) upstream mcpproxy-go endpoint");
33
+ console.log(" MCP_PORT (serve only) port to listen on (default: 3000)");
34
+ console.log(" MCP_HOST (serve only) host to bind to (default: 0.0.0.0)");
35
+ console.log(" MCP_APIKEY (serve only) require ?apikey=KEY on /mcp requests");
36
+ console.log(" https_proxy HTTPS proxy for upstream connection");
37
+ process.exit(0);
38
+ }
39
+ if (subcommand === "serve") {
40
+ // Dynamic import — only loads http-server + core when needed
41
+ import("./http-server.js");
42
+ }
43
+ else if (subcommand) {
44
+ console.error(`Unknown subcommand: "${subcommand}"`);
45
+ console.error("Usage: mcp-proxy-shim [serve]");
46
+ console.error(" (no args) stdio transport (default)");
47
+ console.error(" serve HTTP Streamable server");
42
48
  process.exit(1);
43
- })();
44
- const REQUEST_TIMEOUT_MS = 120_000;
45
- const MAX_RETRIES = 2;
46
- // Auto-detect HTTPS proxy from environment
47
- const PROXY_URL = process.env.https_proxy || process.env.HTTPS_PROXY || "";
48
- const proxyDispatcher = PROXY_URL ? new ProxyAgent(PROXY_URL) : undefined;
49
- // Tools whose schemas get transformed (args_json:string → args:object)
50
- const CALL_TOOL_NAMES = new Set([
51
- "call_tool_read",
52
- "call_tool_write",
53
- "call_tool_destructive",
54
- ]);
55
- // ---------------------------------------------------------------------------
56
- // Shim-local tools (not forwarded upstream)
57
- // ---------------------------------------------------------------------------
58
- /**
59
- * describe_tools — batch-hydrate compact retrieve_tools results.
60
- *
61
- * Workflow: retrieve_tools (compact) → scan names → describe_tools (full schemas)
62
- * Zero network cost — reads from cached upstream tool list.
63
- *
64
- * Named for Claude Code lazy-load discovery: an agent that only sees the tool
65
- * name should immediately understand "this gives me full tool descriptions".
66
- */
67
- const DESCRIBE_TOOLS_SCHEMA = {
68
- name: "describe_tools",
69
- description: "Get full schemas for specific tools by name. Use after retrieve_tools to hydrate " +
70
- "compact results with complete inputSchema and descriptions. Accepts multiple tool " +
71
- "names for token-efficient batch lookup.",
72
- inputSchema: {
73
- type: "object",
74
- properties: {
75
- names: {
76
- type: "array",
77
- items: { type: "string" },
78
- description: "Tool names to describe — use the 'name' field from retrieve_tools results",
79
- },
80
- },
81
- required: ["names"],
82
- },
83
- };
84
- // ---------------------------------------------------------------------------
85
- // Upstream MCP session (manual HTTP — avoids SDK client bugs)
86
- // ---------------------------------------------------------------------------
87
- let sessionId = null;
88
- let reqId = 0;
89
- function log(...args) {
90
- // stderr only — stdout is the stdio transport
91
- console.error("[mcp-shim]", ...args);
92
- }
93
- /**
94
- * Send a JSON-RPC request/notification to upstream mcpproxy-go.
95
- * Handles session header, timeouts, and basic retry on transient failures.
96
- */
97
- async function mcpRequest(method, params, isNotification = false) {
98
- const body = { jsonrpc: "2.0", method, params };
99
- if (!isNotification) {
100
- body.id = ++reqId;
101
- }
102
- const headers = {
103
- "Content-Type": "application/json",
104
- Accept: "application/json, text/event-stream",
105
- };
106
- if (sessionId) {
107
- headers["Mcp-Session-Id"] = sessionId;
108
- }
109
- let lastError = null;
110
- for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
111
- try {
112
- // AbortSignal.timeout is self-cleaning (no timer leak on fetch failure)
113
- const fetchOpts = {
114
- method: "POST",
115
- headers,
116
- body: JSON.stringify(body),
117
- signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
118
- };
119
- if (proxyDispatcher) {
120
- fetchOpts.dispatcher = proxyDispatcher;
121
- }
122
- const resp = await fetch(UPSTREAM_URL, fetchOpts);
123
- // Capture session ID from response headers
124
- const sid = resp.headers.get("mcp-session-id");
125
- if (sid)
126
- sessionId = sid;
127
- // Notifications get 202 with no body
128
- if (isNotification || resp.status === 202) {
129
- return null;
130
- }
131
- if (!resp.ok) {
132
- const text = await resp.text();
133
- throw new Error(`Upstream HTTP ${resp.status}: ${text.slice(0, 500)}`);
134
- }
135
- // Handle SSE vs JSON response
136
- const contentType = resp.headers.get("content-type") || "";
137
- if (contentType.includes("text/event-stream")) {
138
- // StreamableHTTP can return SSE — collect all data events
139
- return await parseSseResponse(resp);
140
- }
141
- return (await resp.json());
142
- }
143
- catch (err) {
144
- lastError = err;
145
- if (attempt < MAX_RETRIES) {
146
- const delay = 1000 * 2 ** attempt; // 1s, 2s
147
- log(`Retry ${attempt + 1}/${MAX_RETRIES} after ${delay}ms:`, lastError.message);
148
- await sleep(delay);
149
- }
150
- }
151
- }
152
- throw lastError || new Error("mcpRequest failed");
153
49
  }
154
- /**
155
- * Parse an SSE response stream and extract the JSON-RPC result.
156
- * StreamableHTTP servers may respond with SSE for long-running operations.
157
- */
158
- async function parseSseResponse(resp) {
159
- const text = await resp.text();
160
- const lines = text.split("\n");
161
- let lastData = null;
162
- for (const line of lines) {
163
- if (line.startsWith("data: ")) {
164
- lastData = line.slice(6);
165
- }
166
- }
167
- if (lastData) {
168
- try {
169
- return JSON.parse(lastData);
170
- }
171
- catch {
172
- // fall through
173
- }
174
- }
175
- throw new Error("No valid JSON-RPC response in SSE stream");
176
- }
177
- function sleep(ms) {
178
- return new Promise((r) => setTimeout(r, ms));
179
- }
180
- // ---------------------------------------------------------------------------
181
- // Upstream session lifecycle
182
- // ---------------------------------------------------------------------------
183
- async function initUpstream() {
184
- log("Initializing upstream session...");
185
- const resp = await mcpRequest("initialize", {
186
- protocolVersion: "2024-11-05",
187
- capabilities: {},
188
- clientInfo: { name: "mcp-stdio-shim", version: "1.0.0" },
189
- });
190
- if (!sessionId) {
191
- throw new Error("No session ID received from upstream after initialize");
192
- }
193
- log("Session ID:", sessionId.slice(0, 12) + "...");
194
- // Send initialized notification (MCP spec requirement)
195
- await mcpRequest("notifications/initialized", {}, true);
196
- }
197
- async function ensureSession() {
198
- if (!sessionId) {
199
- await initUpstream();
200
- }
201
- }
202
- /**
203
- * Re-initialize on session expiry (e.g., upstream restart).
204
- * Returns true if re-init succeeded.
205
- */
206
- async function reinitOnExpiry() {
207
- log("Session may have expired — re-initializing...");
208
- sessionId = null;
209
- try {
210
- await initUpstream();
211
- return true;
212
- }
213
- catch (err) {
214
- log("Re-init failed:", err.message);
215
- return false;
216
- }
217
- }
218
- /**
219
- * Transform call_tool_* schemas: replace args_json:string with args:object.
220
- * All other tools pass through unchanged.
221
- */
222
- function transformToolSchema(tool) {
223
- if (!CALL_TOOL_NAMES.has(tool.name))
224
- return tool;
225
- if (!tool.inputSchema?.properties)
226
- return tool;
227
- const props = { ...tool.inputSchema.properties };
228
- // Only transform if args_json exists
229
- if (!("args_json" in props))
230
- return tool;
231
- // Remove args_json, add args:object
232
- delete props.args_json;
233
- props.args = {
234
- type: "object",
235
- description: "Tool arguments as a native JSON object. The shim serializes this to args_json before forwarding upstream.",
236
- additionalProperties: true,
237
- };
238
- // Update required array
239
- let required = tool.inputSchema.required;
240
- if (required) {
241
- required = required.map((r) => (r === "args_json" ? "args" : r));
242
- }
243
- return {
244
- ...tool,
245
- inputSchema: {
246
- ...tool.inputSchema,
247
- properties: props,
248
- ...(required ? { required } : {}),
249
- },
250
- };
50
+ else {
51
+ // Default: stdio mode
52
+ import("./stdio.js");
251
53
  }
252
- /**
253
- * On tool call: if it's a call_tool_*, serialize the args object back to
254
- * args_json string before forwarding upstream.
255
- */
256
- function transformToolCallArgs(toolName, args) {
257
- if (!CALL_TOOL_NAMES.has(toolName))
258
- return args;
259
- // If caller already sent args_json (backward compat), pass through
260
- if ("args_json" in args)
261
- return args;
262
- // Transform: args → args_json
263
- if ("args" in args) {
264
- const { args: argsObj, ...rest } = args;
265
- return {
266
- ...rest,
267
- args_json: JSON.stringify(argsObj),
268
- };
269
- }
270
- return args;
271
- }
272
- // ---------------------------------------------------------------------------
273
- // Response unwrapping (deep, recursive)
274
- // ---------------------------------------------------------------------------
275
- /**
276
- * Detect MCP content wrapper shape: {content: [{type: "text", text: "..."}]}
277
- */
278
- function isMcpContentWrapper(obj) {
279
- if (!obj || typeof obj !== "object" || Array.isArray(obj))
280
- return false;
281
- const o = obj;
282
- if (!Array.isArray(o.content) || o.content.length === 0)
283
- return false;
284
- const first = o.content[0];
285
- return first?.type === "text" && typeof first?.text === "string";
286
- }
287
- /**
288
- * Recursively unwrap a single text value.
289
- * Keeps parsing until it's no longer a JSON string or an MCP content wrapper.
290
- */
291
- function deepParseText(text, maxDepth = 5) {
292
- let value = text;
293
- let depth = 0;
294
- while (typeof value === "string" && depth < maxDepth) {
295
- try {
296
- const parsed = JSON.parse(value);
297
- if (isMcpContentWrapper(parsed)) {
298
- if (parsed.content.length === 1) {
299
- value = parsed.content[0].text;
300
- depth++;
301
- continue;
302
- }
303
- return parsed.content.map((c) => c.type === "text" ? deepParseText(c.text, maxDepth - depth - 1) : c);
304
- }
305
- return parsed;
306
- }
307
- catch {
308
- break;
309
- }
310
- }
311
- return value;
312
- }
313
- /**
314
- * Unwrap an MCP result object to its deepest payload.
315
- */
316
- function deepUnwrapResult(result) {
317
- if (!isMcpContentWrapper(result))
318
- return result;
319
- if (result.content.length === 1) {
320
- return deepParseText(result.content[0].text);
321
- }
322
- return result.content.map((c) => c.type === "text" ? deepParseText(c.text) : c);
323
- }
324
- /**
325
- * Unwrap then re-wrap for MCP protocol compliance.
326
- * The shim must return valid {content: [{type: "text", text: "..."}]} to Claude.
327
- */
328
- function unwrapAndRewrap(result) {
329
- const unwrapped = deepUnwrapResult(result);
330
- // If it's already a content wrapper with no further nesting, return as-is
331
- if (isMcpContentWrapper(unwrapped)) {
332
- return unwrapped;
333
- }
334
- const text = typeof unwrapped === "string" ? unwrapped : JSON.stringify(unwrapped);
335
- return { content: [{ type: "text", text }] };
336
- }
337
- /**
338
- * Smart compaction for retrieve_tools responses.
339
- * When payload > 5KB and compact !== false, strip inputSchema to save tokens.
340
- */
341
- function compactRetrieveTools(unwrapped, args) {
342
- const compact = args.compact !== false; // default true
343
- const limit = typeof args.limit === "number" ? args.limit : 0;
344
- let result = unwrapped;
345
- // retrieve_tools may return {query, tools[], total} or a raw array
346
- let tools = Array.isArray(result)
347
- ? result
348
- : (result && Array.isArray(result.tools) ? result.tools : undefined);
349
- let wasCompacted = false;
350
- if (compact && tools) {
351
- const fullJson = JSON.stringify(tools);
352
- if (fullJson.length > 5000) {
353
- wasCompacted = true;
354
- tools = tools.map((t) => {
355
- const tool = t;
356
- return {
357
- server: tool.server,
358
- name: tool.name,
359
- call_with: tool.call_with,
360
- description: typeof tool.description === "string"
361
- ? tool.description.slice(0, 100) + (tool.description.length > 100 ? "..." : "")
362
- : undefined,
363
- };
364
- });
365
- }
366
- }
367
- if (limit > 0 && tools) {
368
- tools = tools.slice(0, limit);
369
- }
370
- // Reconstruct the result with compacted tools
371
- let output;
372
- if (Array.isArray(result)) {
373
- output = tools || result;
374
- }
375
- else if (result && typeof result === "object" && tools) {
376
- output = {
377
- ...result,
378
- tools,
379
- // When compacted, tell the agent how to get full schemas
380
- ...(wasCompacted ? {
381
- note: "Results are compacted (inputSchema stripped). Before calling a tool, use describe_tools({names: [tool.name]}) to get the full inputSchema and avoid parameter errors.",
382
- } : {}),
383
- };
384
- }
385
- else {
386
- output = unwrapped;
387
- }
388
- const text = typeof output === "string" ? output : JSON.stringify(output);
389
- return { content: [{ type: "text", text }] };
390
- }
391
- // ---------------------------------------------------------------------------
392
- // Upstream tool list (cached, refreshed on tools/list)
393
- // ---------------------------------------------------------------------------
394
- let cachedTools = null;
395
- async function fetchUpstreamTools() {
396
- await ensureSession();
397
- const resp = await mcpRequest("tools/list", {});
398
- if (!resp || resp.error) {
399
- throw new Error(`Failed to list upstream tools: ${JSON.stringify(resp?.error || "no response")}`);
400
- }
401
- const result = resp.result;
402
- const tools = result?.tools || [];
403
- log(`Fetched ${tools.length} upstream tools`);
404
- return tools;
405
- }
406
- // ---------------------------------------------------------------------------
407
- // Main
408
- // ---------------------------------------------------------------------------
409
- async function main() {
410
- // Mask credentials in log output (apikey params, proxy auth)
411
- const maskUrl = (url) => url.replace(/apikey=[^&\s]+/gi, "apikey=***").replace(/\/\/[^@]*@/, "//***@");
412
- log("Upstream:", maskUrl(UPSTREAM_URL));
413
- if (proxyDispatcher) {
414
- log("Using HTTPS proxy:", maskUrl(PROXY_URL));
415
- }
416
- // 1. Connect upstream
417
- await initUpstream();
418
- // 2. Fetch initial tool list
419
- cachedTools = await fetchUpstreamTools();
420
- const transformed = cachedTools.map(transformToolSchema);
421
- const callToolCount = transformed.filter((t) => CALL_TOOL_NAMES.has(t.name)).length;
422
- log(`Ready: ${transformed.length} tools (${callToolCount} with schema transform)`);
423
- // 3. Create downstream stdio MCP server
424
- const server = new Server({ name: "mcp-stdio-shim", version: "1.0.0" }, { capabilities: { tools: {} } });
425
- // Handle tools/list — return transformed schemas
426
- server.setRequestHandler(ListToolsRequestSchema, async () => {
427
- // Refresh tool list on each request — upstream may have changed
428
- // (dynamic server management via /mcp/call mode)
429
- try {
430
- cachedTools = await fetchUpstreamTools();
431
- }
432
- catch (err) {
433
- log("Tool refresh failed, using cached:", err.message);
434
- // Fall back to cached if refresh fails
435
- if (!cachedTools)
436
- throw err;
437
- }
438
- return {
439
- tools: [
440
- ...cachedTools.map(transformToolSchema),
441
- DESCRIBE_TOOLS_SCHEMA, // shim-local: always present
442
- ],
443
- };
444
- });
445
- // Handle tools/call — transform args and forward upstream
446
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
447
- const { name, arguments: args } = request.params;
448
- // --- Shim-local: describe_tools ---
449
- // Hydrates compact retrieve_tools results with full schemas.
450
- // Must query upstream retrieve_tools (not tools/list) because remote tools
451
- // like "github__create_or_update_file" are only in the upstream search index.
452
- if (name === "describe_tools") {
453
- const names = (args?.names ?? []);
454
- if (!Array.isArray(names) || names.length === 0) {
455
- return {
456
- content: [{ type: "text", text: JSON.stringify({ error: "names array is required" }) }],
457
- isError: true,
458
- };
459
- }
460
- await ensureSession();
461
- // Derive BM25 search queries from tool names.
462
- // e.g. "github__create_or_update_file" → "create or update file"
463
- const nameSet = new Set(names);
464
- const queries = new Set();
465
- for (const n of nameSet) {
466
- const parts = n.split("__");
467
- const toolPart = parts[parts.length - 1] || n;
468
- queries.add(toolPart.replace(/_/g, " "));
469
- }
470
- // Fetch full tool entries from upstream (no compaction applied)
471
- const index = new Map();
472
- for (const query of queries) {
473
- try {
474
- log("describe_tools: querying upstream retrieve_tools with:", query);
475
- const resp = await mcpRequest("tools/call", {
476
- name: "retrieve_tools",
477
- arguments: { query },
478
- });
479
- log("describe_tools: resp exists:", !!resp, "resp.result exists:", !!resp?.result);
480
- if (resp?.result) {
481
- const unwrapped = deepUnwrapResult(resp.result);
482
- log("describe_tools: unwrapped type:", typeof unwrapped, "isArray:", Array.isArray(unwrapped));
483
- if (unwrapped && typeof unwrapped === "object" && !Array.isArray(unwrapped)) {
484
- log("describe_tools: unwrapped keys:", Object.keys(unwrapped).join(", "));
485
- }
486
- const result = unwrapped;
487
- const tools = Array.isArray(result)
488
- ? result
489
- : (result && Array.isArray(result.tools) ? result.tools : []);
490
- log("describe_tools: found", tools.length, "tools from query");
491
- for (const t of tools) {
492
- const tool = t;
493
- if (tool.name && !index.has(tool.name)) {
494
- index.set(tool.name, tool);
495
- }
496
- }
497
- }
498
- }
499
- catch (err) {
500
- log("describe_tools query failed:", query, err.message);
501
- }
502
- }
503
- log("describe_tools: index has", index.size, "tools, looking up:", names.join(", "));
504
- // Look up each requested tool — return full schema (with transform applied)
505
- const results = names.map((n) => {
506
- const tool = index.get(n);
507
- if (!tool)
508
- return { name: n, error: "not found" };
509
- return transformToolSchema(tool);
510
- });
511
- return {
512
- content: [{ type: "text", text: JSON.stringify(results) }],
513
- };
514
- }
515
- const forwardArgs = transformToolCallArgs(name, args || {});
516
- try {
517
- await ensureSession();
518
- const resp = await mcpRequest("tools/call", {
519
- name,
520
- arguments: forwardArgs,
521
- });
522
- if (!resp) {
523
- return {
524
- content: [{ type: "text", text: "No response from upstream" }],
525
- isError: true,
526
- };
527
- }
528
- if (resp.error) {
529
- // Check for session-expired errors
530
- if (resp.error.message?.includes("session") ||
531
- resp.error.message?.includes("Session") ||
532
- resp.error.code === -32001) {
533
- const ok = await reinitOnExpiry();
534
- if (ok) {
535
- // Retry once with new session
536
- const retry = await mcpRequest("tools/call", {
537
- name,
538
- arguments: forwardArgs,
539
- });
540
- if (retry && !retry.error) {
541
- if (name === "retrieve_tools") {
542
- return compactRetrieveTools(deepUnwrapResult(retry.result), args || {});
543
- }
544
- return unwrapAndRewrap(retry.result);
545
- }
546
- }
547
- }
548
- return {
549
- content: [
550
- {
551
- type: "text",
552
- text: JSON.stringify(resp.error),
553
- },
554
- ],
555
- isError: true,
556
- };
557
- }
558
- // Deep unwrap + re-wrap for clean responses
559
- if (name === "retrieve_tools") {
560
- return compactRetrieveTools(deepUnwrapResult(resp.result), args || {});
561
- }
562
- return unwrapAndRewrap(resp.result);
563
- }
564
- catch (err) {
565
- const msg = err.message;
566
- log("Tool call error:", name, msg);
567
- // Attempt re-init on network errors
568
- if (msg.includes("fetch") || msg.includes("abort") || msg.includes("ECONNR")) {
569
- await reinitOnExpiry();
570
- }
571
- return {
572
- content: [{ type: "text", text: `Error: ${msg}` }],
573
- isError: true,
574
- };
575
- }
576
- });
577
- // 4. Connect stdio transport
578
- const transport = new StdioServerTransport();
579
- await server.connect(transport);
580
- log("Stdio transport connected — shim is live");
581
- }
582
- main().catch((err) => {
583
- log("Fatal:", err);
584
- process.exit(1);
585
- });
54
+ export {};
586
55
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAE5C,4EAA4E;AAC5E,kFAAkF;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChD,MAAM,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAgD,CAAC;AAEzF,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAE9E,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,EAAE;IAChD,OAAO,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC;IAC7E,OAAO,CAAC,KAAK,CAAC,iFAAiF,CAAC,CAAC;IACjG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,EAAW,CAAC;AAEd,MAAM,kBAAkB,GAAG,OAAO,CAAC;AACnC,MAAM,WAAW,GAAG,CAAC,C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