Skip to content

feat(MssqlMcp/Node): Add multi-client HTTP/SSE transport and fix authentication fallback#94

Open
tripathishivani wants to merge 1 commit intoAzure-Samples:mainfrom
tripathishivani:shivani/mssqlmcp-add-support-for-streamable-http
Open

feat(MssqlMcp/Node): Add multi-client HTTP/SSE transport and fix authentication fallback#94
tripathishivani wants to merge 1 commit intoAzure-Samples:mainfrom
tripathishivani:shivani/mssqlmcp-add-support-for-streamable-http

Conversation

@tripathishivani
Copy link
Copy Markdown

@tripathishivani tripathishivani commented Apr 27, 2026

This PR enhances the Node.js implementation of the MSSQL MCP Server by adding support for HTTP streaming via Server-Sent Events (SSE). This allows the server to be accessed remotely over a network or via cloud-based AI agents, rather than strictly as a local child process. Additionally, it resolves a bug in the database connection configuration where standard SQL authentication and Azure AD authentication were conflicting.

Key Changes
HTTP/SSE Transport (--sse): Added an optional command-line flag to boot the server using an HTTP streaming interface.

Multi-Client Architecture: Implemented a session-routing system using an activeTransports Map. This allows multiple clients to connect simultaneously without their data streams colliding. It includes memory cleanup on client disconnect (res.on('close')).

Zero New Dependencies: The HTTP server, CORS handling, and URL parsing were implemented using Node.js native http and url modules to keep package.json lightweight.

Authentication Fix: Refactored createSqlConfig() to properly branch between authentication methods. It now cleanly falls back to Standard SQL Auth if SQL_USER and SQL_PASSWORD are present in the environment, rather than forcing the InteractiveBrowserCredential popup simultaneously.

Early Env Loading: Added dotenv.config() at the top level to ensure environment variables are reliably loaded before initialization.

Backward Compatible: The default behavior (running the script without flags) remains completely unchanged, defaulting to the stdio transport. Output logging for the HTTP server uses console.error() to protect the stdio JSON-RPC stream.

How to Test
Build the project: npm run build

Test Legacy Stdio Mode: npm start

Test New SSE Mode: node dist/index.js --sse
Optionally test with a custom port: node dist/index.js --sse --port 8080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant