@anyshift/mcp-proxy 0.6.3 → 0.6.4

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.
Files changed (2) hide show
  1. package/dist/index.js +28 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
19
19
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
20
20
  import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
21
21
  import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
22
+ import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
22
23
  import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
23
24
  import { createJqTool } from './jq/index.js';
24
25
  import { createTimeseriesTool } from './timeseries/index.js';
@@ -119,11 +120,16 @@ const CHILD_ARGS = process.env.MCP_PROXY_CHILD_ARGS
119
120
  : [];
120
121
  /**
121
122
  * MCP_PROXY_REMOTE_URL (OPTIONAL)
122
- * SSE URL of a remote MCP server to connect to instead of spawning a child process
123
- * When set, the proxy connects as an SSE client to the remote server
123
+ * URL of a remote MCP server to connect to instead of spawning a child process
124
124
  * Example: "http://internal-server:3100/sse"
125
125
  */
126
126
  const REMOTE_URL = process.env.MCP_PROXY_REMOTE_URL;
127
+ /**
128
+ * MCP_PROXY_REMOTE_TRANSPORT (OPTIONAL, default: "sse")
129
+ * Transport protocol for connecting to a remote MCP server.
130
+ * Values: "sse" (legacy GET-based SSE), "streamable-http" (POST-based, newer MCP spec)
131
+ */
132
+ const REMOTE_TRANSPORT = process.env.MCP_PROXY_REMOTE_TRANSPORT || 'sse';
127
133
  /**
128
134
  * MCP_PROXY_REMOTE_HEADERS (OPTIONAL)
129
135
  * JSON string of custom headers to send with SSE/POST requests to the remote server
@@ -295,7 +301,7 @@ for (const [key, value] of Object.entries(process.env)) {
295
301
  // ============================================================================
296
302
  if (ENABLE_LOGGING) {
297
303
  console.debug('[mcp-proxy] Configuration:');
298
- console.debug(` Mode: ${REMOTE_URL ? 'remote (SSE)' : CHILD_COMMAND ? 'wrapper' : 'standalone (JQ only)'}`);
304
+ console.debug(` Mode: ${REMOTE_URL ? `remote (${REMOTE_TRANSPORT})` : CHILD_COMMAND ? 'wrapper' : 'standalone (JQ only)'}`);
299
305
  if (REMOTE_URL) {
300
306
  console.debug(` Remote URL: ${REMOTE_URL}`);
301
307
  console.debug(` Remote headers: ${REMOTE_HEADERS ? 'configured' : 'none'}`);
@@ -360,20 +366,26 @@ async function main() {
360
366
  }
361
367
  headers['X-Client-Credentials'] = REMOTE_CREDENTIALS;
362
368
  }
363
- const childTransport = new SSEClientTransport(new URL(REMOTE_URL), {
364
- eventSourceInit: {
365
- fetch: (url, init) => {
366
- // Merge headers using the Headers API (case-insensitive set avoids duplicates
367
- // when requestInit headers are also passed through init by the SDK)
368
- const merged = new Headers(init?.headers);
369
- for (const [key, value] of Object.entries(headers)) {
370
- merged.set(key, value);
371
- }
372
- return fetch(url, { ...init, headers: merged });
369
+ let childTransport;
370
+ if (REMOTE_TRANSPORT === 'streamable-http') {
371
+ childTransport = new StreamableHTTPClientTransport(new URL(REMOTE_URL), {
372
+ requestInit: { headers },
373
+ });
374
+ }
375
+ else {
376
+ childTransport = new SSEClientTransport(new URL(REMOTE_URL), {
377
+ eventSourceInit: {
378
+ fetch: (url, init) => {
379
+ const merged = new Headers(init?.headers);
380
+ for (const [key, value] of Object.entries(headers)) {
381
+ merged.set(key, value);
382
+ }
383
+ return fetch(url, { ...init, headers: merged });
384
+ },
373
385
  },
374
- },
375
- requestInit: { headers },
376
- });
386
+ requestInit: { headers },
387
+ });
388
+ }
377
389
  childClient = new Client({
378
390
  name: 'mcp-proxy-client',
379
391
  version: '1.0.0'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anyshift/mcp-proxy",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "description": "Generic MCP proxy that adds truncation, file writing, and JQ capabilities to any MCP server",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",