Skip to content

Commit 7792070

Browse files
committed
Add debugging
1 parent 34a2843 commit 7792070

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

bin/cli.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { fileURLToPath } from "url";
66

77
const __dirname = dirname(fileURLToPath(import.meta.url));
88

9+
function delay(ms) {
10+
return new Promise((resolve) => setTimeout(resolve, ms));
11+
}
12+
913
async function main() {
1014
// Get command line arguments
1115
const [, , command, ...mcpServerArgs] = process.argv;
@@ -64,7 +68,7 @@ async function main() {
6468
try {
6569
await Promise.any([server, client]);
6670
} catch (e) {
67-
if (!cancelled) throw e;
71+
if (!cancelled || process.env.DEBUG) throw e;
6872
}
6973

7074
return 0;

server/src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const createTransport = async (query: express.Request["query"]) => {
3939
const command = query.command as string;
4040
const args = (query.args as string).split(/\s+/);
4141
const env = query.env ? JSON.parse(query.env as string) : undefined;
42+
4243
console.log(
4344
`Stdio transport: command=${command}, args=${args}, env=${JSON.stringify(env)}`,
4445
);
@@ -48,14 +49,18 @@ const createTransport = async (query: express.Request["query"]) => {
4849
env,
4950
stderr: "pipe",
5051
});
52+
5153
await transport.start();
54+
5255
console.log("Spawned stdio transport");
5356
return transport;
5457
} else if (transportType === "sse") {
5558
const url = query.url as string;
5659
console.log(`SSE transport: url=${url}`);
60+
5761
const transport = new SSEClientTransport(new URL(url));
5862
await transport.start();
63+
5964
console.log("Connected to SSE transport");
6065
return transport;
6166
} else {
@@ -99,6 +104,7 @@ app.get("/sse", async (req, res) => {
99104
console.error(error);
100105
},
101106
});
107+
102108
console.log("Set up MCP proxy");
103109
} catch (error) {
104110
console.error("Error in /sse route:", error);
@@ -126,6 +132,7 @@ app.post("/message", async (req, res) => {
126132
app.get("/config", (req, res) => {
127133
try {
128134
const defaultEnvironment = getDefaultEnvironment();
135+
129136
res.json({
130137
defaultEnvironment,
131138
defaultCommand: values.env,
@@ -138,4 +145,4 @@ app.get("/config", (req, res) => {
138145
});
139146

140147
const PORT = process.env.PORT || 3000;
141-
app.listen(PORT, () => { });
148+
app.listen(PORT, () => {});

0 commit comments

Comments
 (0)