Skip to content

Commit

Permalink
Merge pull request #88 from modelcontextprotocol/ani/fix-npx
Browse files Browse the repository at this point in the history
Enable using 'npx' as your command on Windows
  • Loading branch information
ashwin-ant authored Nov 27, 2024
2 parents e700bc7 + 2c04fa3 commit 3110cf9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
import express from "express";
import mcpProxy from "./mcpProxy.js";
import { findActualExecutable } from "spawn-rx";

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

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

const { cmd, args } = findActualExecutable(command, origArgs);

console.log(
`Stdio transport: command=${command}, args=${args}, env=${JSON.stringify(env)}`,
`Stdio transport: command=${cmd}, args=${args}, env=${JSON.stringify(env)}`,
);

const transport = new StdioClientTransport({
command,
command: cmd,
args,
env,
stderr: "pipe",
Expand Down

0 comments on commit 3110cf9

Please sign in to comment.