add clear logging to server
This commit is contained in:
@@ -19,6 +19,7 @@ let transports: SSEServerTransport[] = [];
|
|||||||
app.get("/sse", async (req, res) => {
|
app.get("/sse", async (req, res) => {
|
||||||
console.log("New SSE connection");
|
console.log("New SSE connection");
|
||||||
const transportType = req.query.transportType as string;
|
const transportType = req.query.transportType as string;
|
||||||
|
console.log(`Transport type: ${transportType}`);
|
||||||
|
|
||||||
let backingServerTransport;
|
let backingServerTransport;
|
||||||
console.log("Query parameters:", req.query);
|
console.log("Query parameters:", req.query);
|
||||||
@@ -26,13 +27,18 @@ app.get("/sse", async (req, res) => {
|
|||||||
if (transportType === "stdio") {
|
if (transportType === "stdio") {
|
||||||
const command = decodeURIComponent(req.query.command as string);
|
const command = decodeURIComponent(req.query.command as string);
|
||||||
const args = decodeURIComponent(req.query.args as string).split(",");
|
const args = decodeURIComponent(req.query.args as string).split(",");
|
||||||
|
console.log(`Stdio transport: command=${command}, args=${args}`);
|
||||||
backingServerTransport = new StdioClientTransport();
|
backingServerTransport = new StdioClientTransport();
|
||||||
await backingServerTransport.spawn({ command, args });
|
await backingServerTransport.spawn({ command, args });
|
||||||
|
console.log("Spawned stdio transport");
|
||||||
} else if (transportType === "sse") {
|
} else if (transportType === "sse") {
|
||||||
const url = decodeURIComponent(req.query.url as string);
|
const url = decodeURIComponent(req.query.url as string);
|
||||||
|
console.log(`SSE transport: url=${url}`);
|
||||||
backingServerTransport = new SSEClientTransport();
|
backingServerTransport = new SSEClientTransport();
|
||||||
await backingServerTransport.connect(new URL(url));
|
await backingServerTransport.connect(new URL(url));
|
||||||
|
console.log("Connected to SSE transport");
|
||||||
} else {
|
} else {
|
||||||
|
console.error(`Invalid transport type: ${transportType}`);
|
||||||
throw new Error("Invalid transport type specified");
|
throw new Error("Invalid transport type specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,6 +54,7 @@ app.get("/sse", async (req, res) => {
|
|||||||
console.error(error);
|
console.error(error);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
console.log("Set up MCP proxy");
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post("/message", async (req, res) => {
|
app.post("/message", async (req, res) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user