Skip to content

Add streamable HTTP server mode#14

Closed
syucream wants to merge 1 commit intomainfrom
mzv6j1-codex/mcp-sdkの最新化とtransport設定の変更

Hidden character warning

The head ref may contain hidden characters: "mzv6j1-codex/mcp-sdk\u306e\u6700\u65b0\u5316\u3068transport\u8a2d\u5b9a\u306e\u5909\u66f4"
Closed

Add streamable HTTP server mode#14
syucream wants to merge 1 commit intomainfrom
mzv6j1-codex/mcp-sdkの最新化とtransport設定の変更

Conversation

@syucream
Copy link
Copy Markdown
Owner

Summary

  • update MCP SDK to ^1.1.0
  • add ability to run server either on stdio or streamable HTTP
  • support --port command line flag to enable HTTP mode
  • document --port flag in README
  • fix npm lockfile integrity

Testing

  • npm run lint
  • npm test

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds the ability to run the Lightdash MCP Server in streamable HTTP mode using Server-Sent Events (SSE) and provides a CLI flag to enable it, while still supporting the existing stdio mode.

  • Upgraded the MCP SDK to ^1.1.0
  • Added HTTP mode with SSE endpoint support and corresponding error handling
  • Updated README to document the usage of the --port flag

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/index.ts Introduces separate functions for stdio and HTTP modes including SSE transport handling
README.md Documents the new --port flag for activating the HTTP server mode
Files not reviewed (1)
  • package.json: Language not supported

Comment thread src/index.ts
Comment on lines +454 to +464
let transport: SSEServerTransport | undefined;

app.get('/sse', async (_req, res) => {
transport = new SSEServerTransport('/message', res);
await server.connect(transport);
console.error(
`Lightdash MCP Server new SSE connection ${transport.sessionId}`
);
});

app.post('/message', async (req, res) => {
Copy link

Copilot AI May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a single 'transport' variable to manage the SSE connection might lead to issues when handling multiple concurrent connections; consider implementing a mechanism (e.g., mapping session IDs to transports) to support multiple clients.

Suggested change
let transport: SSEServerTransport | undefined;
app.get('/sse', async (_req, res) => {
transport = new SSEServerTransport('/message', res);
await server.connect(transport);
console.error(
`Lightdash MCP Server new SSE connection ${transport.sessionId}`
);
});
app.post('/message', async (req, res) => {
const transports = new Map<string, SSEServerTransport>();
app.get('/sse', async (_req, res) => {
const transport = new SSEServerTransport('/message', res);
transports.set(transport.sessionId, transport);
await server.connect(transport);
console.error(
`Lightdash MCP Server new SSE connection ${transport.sessionId}`
);
// Clean up when the connection is closed
res.on('close', () => {
transports.delete(transport.sessionId);
console.error(`SSE connection closed: ${transport.sessionId}`);
});
});
app.post('/message', async (req, res) => {
const sessionId = req.body.sessionId;
const transport = transports.get(sessionId);

Copilot uses AI. Check for mistakes.
@syucream syucream closed this May 27, 2025
@syucream syucream deleted the mzv6j1-codex/mcp-sdkの最新化とtransport設定の変更 branch May 27, 2025 05:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants