Skip to content

chore: refactors components composing StreamableHttpRunner into their own files and moves nested function to their own methods#972

Open
himanshusinghs wants to merge 2 commits intomainfrom
chore/streamable-http-refactor
Open

chore: refactors components composing StreamableHttpRunner into their own files and moves nested function to their own methods#972
himanshusinghs wants to merge 2 commits intomainfrom
chore/streamable-http-refactor

Conversation

@himanshusinghs
Copy link
Collaborator

@himanshusinghs himanshusinghs commented Mar 13, 2026

Proposed changes

The StreamableHttpRunner starts a HealthCheckServer and an McpHttpServer both based on Express. All these components currently live in the same file. This PR splits the inidividual components into their own files and moves the nested function created in setupRoutes method to their own class methods.

The PR has no logic changes, pure refactor.

Please review the PR commit by commit:

  1. Commit 1: Moves individual components in StreamableHttpRunner file to their own files. This change improves scanability of the code.
  2. Commit 2 Moves the nested functions in setupRoutes method of McpHttpServer to their own class methods. This is a good change to ensure that we don't depend on lexical scope in the callbacks for some of the variables to be present.

Checklist

@himanshusinghs himanshusinghs requested a review from a team as a code owner March 13, 2026 11:19
Copilot AI review requested due to automatic review settings March 13, 2026 11:19
@himanshusinghs himanshusinghs added the no-title-validation Add this label to disable the title check for this PR. label Mar 13, 2026
Copy link
Contributor

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 refactors the StreamableHttpRunner module by splitting the monolithic src/transports/streamableHttp.ts file into a directory structure with individual files for each component. It also converts nested functions within the setupRoutes method of MCPHttpServer into proper class methods.

Changes:

  • Splits streamableHttp.ts into four files: streamableHttpRunner.ts, mcpHttpServer.ts, healthCheckServer.ts, and expressBasedHttpServer.ts under src/transports/streamableHttp/.
  • Converts nested functions (reportSessionError, handleSessionRequest, initializeServer) in MCPHttpServer.setupRoutes into private class methods.
  • Updates all import paths across source and test files to reference the new file locations.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/transports/streamableHttp.ts Deleted — original monolithic file removed
src/transports/streamableHttp/streamableHttpRunner.ts New file containing the StreamableHttpRunner class
src/transports/streamableHttp/httpServers/mcpHttpServer.ts New file containing MCPHttpServer with nested functions refactored to methods
src/transports/streamableHttp/httpServers/healthCheckServer.ts New file containing the HealthCheckServer class
src/transports/streamableHttp/httpServers/expressBasedHttpServer.ts New file containing the ExpressBasedHttpServer abstract base class
src/lib.ts Updated import path for StreamableHttpRunner
src/index.ts Updated import path for StreamableHttpRunner
tests/integration/transports/*.test.ts Updated import paths for StreamableHttpRunner (4 files)

You can also share your feedback on Copilot code review. Take the survey.

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 23048488605

Details

  • 391 of 476 (82.14%) changed or added relevant lines in 6 files are covered.
  • 34 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.3%) to 81.991%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/index.ts 0 1 0.0%
src/transports/streamableHttp/httpServers/expressBasedHttpServer.ts 59 70 84.29%
src/transports/streamableHttp/streamableHttpRunner.ts 112 130 86.15%
src/transports/streamableHttp/httpServers/mcpHttpServer.ts 200 255 78.43%
Files with Coverage Reduction New Missed Lines %
src/tools/mongodb/mongodbTool.ts 5 83.33%
src/common/session.ts 6 85.12%
src/tools/atlas/connect/connectCluster.ts 23 71.38%
Totals Coverage Status
Change from base Build 23016560869: -0.3%
Covered Lines: 8160
Relevant Lines: 9849

💛 - Coveralls

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

Labels

no-title-validation Add this label to disable the title check for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants