mcp-proxy 6.1.8 → 6.1.10

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/jsr.json CHANGED
@@ -3,5 +3,5 @@
3
3
  "include": ["src/index.ts", "src/bin/mcp-proxy.ts"],
4
4
  "license": "MIT",
5
5
  "name": "@punkpeye/mcp-proxy",
6
- "version": "6.1.8"
6
+ "version": "6.1.10"
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-proxy",
3
- "version": "6.1.8",
3
+ "version": "6.1.10",
4
4
  "main": "dist/index.mjs",
5
5
  "scripts": {
6
6
  "build": "tsdown",
@@ -3,11 +3,15 @@
3
3
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
4
4
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
5
5
  import { EventSource } from "eventsource";
6
+ import { createRequire } from "node:module";
6
7
  import { setTimeout } from "node:timers";
7
8
  import util from "node:util";
8
9
  import yargs from "yargs";
9
10
  import { hideBin } from "yargs/helpers";
10
11
 
12
+ const require = createRequire(import.meta.url);
13
+ const packageJson = require("../../package.json") as { version: string };
14
+
11
15
  import { InMemoryEventStore } from "../InMemoryEventStore.js";
12
16
  import { proxyServer } from "../proxyServer.js";
13
17
  import { SSEServer, startHTTPServer } from "../startHTTPServer.js";
@@ -22,7 +26,18 @@ if (!("EventSource" in global)) {
22
26
 
23
27
  const argv = await yargs(hideBin(process.argv))
24
28
  .scriptName("mcp-proxy")
25
- .usage("$0 [options] -- <command> [args...]")
29
+ .version(packageJson.version)
30
+ .command("$0 [command] [args...]", "Proxy an MCP stdio server over HTTP")
31
+ .positional("command", {
32
+ describe: "The command to run",
33
+ type: "string",
34
+ })
35
+ .positional("args", {
36
+ array: true,
37
+ describe: "The arguments to pass to the command",
38
+ type: "string",
39
+ })
40
+ .usage("$0 [options] -- <command> [args...]\n $0 <command> [args...]")
26
41
  .env("MCP_PROXY")
27
42
  .parserConfiguration({
28
43
  "populate--": true,
@@ -105,16 +120,29 @@ const argv = await yargs(hideBin(process.argv))
105
120
  .help()
106
121
  .parseAsync();
107
122
 
108
- // Determine the final command and args from -- separator
123
+ // If -- separator was used, everything after -- is the command and its args
109
124
  const dashDashArgs = argv["--"] as string[] | undefined;
110
- if (!dashDashArgs || dashDashArgs.length === 0) {
125
+
126
+ let finalCommand: string;
127
+ let finalArgs: string[];
128
+
129
+ if (dashDashArgs && dashDashArgs.length > 0) {
130
+ // -- was used: first item after -- is command, rest are args
131
+ [finalCommand, ...finalArgs] = dashDashArgs;
132
+ } else if (argv.command) {
133
+ // No -- used: use positional command and args
134
+ finalCommand = argv.command as string;
135
+ finalArgs = (argv.args as string[]) || [];
136
+ } else {
111
137
  console.error("Error: No command specified.");
112
138
  console.error("Usage: mcp-proxy [options] -- <command> [args...]");
139
+ console.error(" or: mcp-proxy <command> [args...]");
113
140
  console.error("");
114
- console.error("Example: mcp-proxy --port 8080 -- node server.js --port 3000");
141
+ console.error("Examples:");
142
+ console.error(" mcp-proxy --port 8080 -- node server.js --port 3000");
143
+ console.error(" mcp-proxy node server.js");
115
144
  process.exit(1);
116
145
  }
117
- const [finalCommand, ...finalArgs] = dashDashArgs;
118
146
 
119
147
  const connect = async (client: Client) => {
120
148
  const transport = new StdioClientTransport({