Skip to content

Commit 85b9bcf

Browse files
authored
Merge pull request #2 from adrianlzt/fix-python-mcp-servers
Allow to run python MCP servers
2 parents 3563d29 + 3bde146 commit 85b9bcf

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

src/commands/tool.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,21 @@ export default class Tool extends Command {
5353

5454
//console.log(propsObject);
5555

56+
const isNodePackage = server.startsWith('@');
57+
const command = isNodePackage ? (process.platform === "win32" ? "cmd" : "npx") : "uvx";
58+
const args = isNodePackage ? (process.platform === "win32" ? [
59+
"/c",
60+
"npx",
61+
"-y",
62+
server
63+
] : [
64+
"-y",
65+
server
66+
]) : [server];
67+
5668
const transport = new StdioClientTransport({
57-
//command: process.platform === "win32" ? "npx.cmd" : "npx",
58-
command: process.platform === "win32" ? "cmd" : "npx",
59-
args: process.platform === "win32" ? [
60-
"/c",
61-
"npx",
62-
"-y",
63-
server
64-
] : [
65-
"-y",
66-
server
67-
]
69+
command,
70+
args
6871
});
6972

7073
const client = new Client(

src/commands/tools.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,21 @@ export default class Tools extends Command {
2323
// Assert that argv is a string array.
2424
const stringArgs = argv as string[]
2525

26+
const isNodePackage = stringArgs[0].startsWith('@');
27+
const command = isNodePackage ? (process.platform === 'win32' ? 'cmd' : 'npx') : 'uvx';
28+
const args = isNodePackage ? (process.platform === 'win32' ? [
29+
"/c",
30+
"npx",
31+
"-y",
32+
...stringArgs
33+
] : [
34+
"-y",
35+
...stringArgs
36+
]) : stringArgs;
37+
2638
const transport = new StdioClientTransport({
27-
//command: process.platform === "win32" ? "npx.cmd" : "npx",
28-
command: process.platform === "win32" ? "cmd" : "npx",
29-
args: process.platform === "win32" ? [
30-
"/c",
31-
"npx",
32-
"-y",
33-
...stringArgs
34-
] : [
35-
"-y",
36-
...stringArgs
37-
]
39+
command,
40+
args
3841
});
3942

4043
const client = new Client(
@@ -107,4 +110,4 @@ export default class Tools extends Command {
107110

108111
process.exit(0);
109112
}
110-
}
113+
}

0 commit comments

Comments
 (0)