Skip to content

Commit 3110cf9

Browse files
authored
Merge pull request #88 from modelcontextprotocol/ani/fix-npx
Enable using 'npx' as your command on Windows
2 parents e700bc7 + 2c04fa3 commit 3110cf9

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

server/src/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
1313
import express from "express";
1414
import mcpProxy from "./mcpProxy.js";
15+
import { findActualExecutable } from "spawn-rx";
1516

1617
// Polyfill EventSource for an SSE client in Node.js
1718
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -37,14 +38,17 @@ const createTransport = async (query: express.Request["query"]) => {
3738

3839
if (transportType === "stdio") {
3940
const command = query.command as string;
40-
const args = (query.args as string).split(/\s+/);
41+
const origArgs = (query.args as string).split(/\s+/);
4142
const env = query.env ? JSON.parse(query.env as string) : undefined;
4243

44+
const { cmd, args } = findActualExecutable(command, origArgs);
45+
4346
console.log(
44-
`Stdio transport: command=${command}, args=${args}, env=${JSON.stringify(env)}`,
47+
`Stdio transport: command=${cmd}, args=${args}, env=${JSON.stringify(env)}`,
4548
);
49+
4650
const transport = new StdioClientTransport({
47-
command,
51+
command: cmd,
4852
args,
4953
env,
5054
stderr: "pipe",

0 commit comments

Comments
 (0)