feat(MssqlMcp/Node): Add multi-client HTTP/SSE transport and fix authentication fallback#94
Open
tripathishivani wants to merge 1 commit intoAzure-Samples:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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