MCPcopy
hub / github.com/codeaashu/claude-code / startLegacySSE

Function startLegacySSE

mcp-server/src/http.ts:110–132  ·  view source on GitHub ↗
(app: express.Express)

Source from the content-addressed store, hash-verified

108// ---------------------------------------------------------------------------
109
110async function startLegacySSE(app: express.Express): Promise<void> {
111 const transports = new Map<string, SSEServerTransport>();
112
113 app.get("/sse", async (_req, res) => {
114 const server = createServer();
115 const transport = new SSEServerTransport("/messages", res);
116 transports.set(transport.sessionId, transport);
117 transport.onclose = () => {
118 transports.delete(transport.sessionId);
119 };
120 await server.connect(transport);
121 });
122
123 app.post("/messages", async (req, res) => {
124 const sessionId = req.query.sessionId as string;
125 const transport = transports.get(sessionId);
126 if (!transport) {
127 res.status(400).json({ error: "Unknown session" });
128 return;
129 }
130 await transport.handlePostMessage(req, res, req.body);
131 });
132}
133
134// ---------------------------------------------------------------------------
135// Main

Callers 1

mainFunction · 0.85

Calls 7

createServerFunction · 0.85
postMethod · 0.80
statusMethod · 0.80
getMethod · 0.65
deleteMethod · 0.65
setMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected