Skip to content

Conversation

@aheizi
Copy link
Contributor

@aheizi aheizi commented Mar 8, 2025

Context

support sse mcp

Implementation

use @modelcontextprotocol/sdk SSEClientTransport

Screenshots

image

How to Test

step1:

here is a simple SSE MCP server : https://github.com/aheizi/simple-sse-mcp, you can start it yourself

or you can use https://mcp.composio.dev/

step2:

update cline_mcp_settings.json

{
  "mcpServers": {
    "exchange": {
      "type":"sse",
      "url": "http://localhost:3001/sse"
    }
  }
}

Now you can use this SSE MCP.

Get in Touch

aheizi


Important

Adds SSE MCP support in McpHub.ts with SSEClientTransport, error handling, and reconnection logic.

  • Behavior:
    • Adds support for SSE MCP using SSEClientTransport in McpHub.ts.
    • Implements SSE-specific error handling and reconnection logic with exponential backoff in connectToServer() and handleSSEReconnection().
    • Updates McpSettingsSchema to include SSE configuration.
  • Dependencies:
    • Updates @modelcontextprotocol/sdk to ^1.5.0 and adds eventsource to package.json.
  • Configuration:
    • Introduces SSEConfigSchema and ServerConfigSchema in McpHub.ts to handle both Stdio and SSE configurations.

This description was created by Ellipsis for bb42fb6. It will automatically update as commits are pushed.

@changeset-bot
Copy link

changeset-bot bot commented Mar 8, 2025

⚠️ No Changeset found

Latest commit: cad2741

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 8, 2025
@ellipsis-dev
Copy link
Contributor

ellipsis-dev bot commented Mar 8, 2025

The pull request is quite large, with 4966 lines added and 3323 lines removed. While the changes in package.json and McpHub.ts seem related to adding SSE support, the size of the changes is substantial. If possible, consider splitting the pull request into smaller, more manageable parts. For example, you could separate the dependency updates in package.json from the implementation of SSE support in McpHub.ts. This would make it easier to review and test the changes.

@dosubot dosubot bot added the enhancement New feature or request label Mar 8, 2025
@mrubens
Copy link
Collaborator

mrubens commented Mar 8, 2025

Awesome! Excited to take a look at this.

@aheizi aheizi force-pushed the feature/add_sse_mcp branch from c0b1d12 to b4f808d Compare March 8, 2025 17:26
@hannesrudolph
Copy link
Collaborator

@mrubens I want this.. this is a big big deal.

@hannesrudolph hannesrudolph moved this from New to PR [Unverified] in Roo Code Roadmap Mar 10, 2025
@mrubens
Copy link
Collaborator

mrubens commented Mar 10, 2025

Looks good other than my one comment. Nice work!

@mrubens
Copy link
Collaborator

mrubens commented Mar 10, 2025

I merged main into your branch, hope that's ok.

@mrubens
Copy link
Collaborator

mrubens commented Mar 10, 2025

Do you think we should update the system prompt instructions around MCP to tell it about SSE support and the type field?

https://github.com/RooVetGit/Roo-Code/blob/main/src/core/prompts/sections/mcp-servers.ts

package.json Outdated
"delay": "^6.0.0",
"diff": "^5.2.0",
"diff-match-patch": "^1.0.5",
"eventsource": "^3.0.5",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can I recommend using https://www.npmjs.com/package/reconnecting-eventsource instead?

I've had a lot of issues with MCP SSE stability when implementing it in Glama.

reconnecting-eventsource helped a lot with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is really a good suggestion, i'll try it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@punkpeye I have replaced reconnecting-eventsource with eventsource, thank you for your suggestion.

}
}

private async handleSSEReconnection(name: string, config: z.infer<typeof ServerConfigSchema>): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding reconnecting-eventsource would get rid of some of this boilerplate code too.

@punkpeye
Copy link
Contributor

@aheizi after seeing this PR, I realized that the ecosystem would benefit from a higher level abstraction for interacting with MCP, and I built https://github.com/punkpeye/mcp-client. Would you consider using it for this PR?

@aheizi
Copy link
Contributor Author

aheizi commented Mar 11, 2025

Do you think we should update the system prompt instructions around MCP to tell it about SSE support and the type field?

https://github.com/RooVetGit/Roo-Code/blob/main/src/core/prompts/sections/mcp-servers.ts

ok

@aheizi
Copy link
Contributor Author

aheizi commented Mar 11, 2025

Do you think we should update the system prompt instructions around MCP to tell it about SSE support and the type field?

https://github.com/RooVetGit/Roo-Code/blob/main/src/core/prompts/sections/mcp-servers.ts

@mrubens done

@aheizi aheizi force-pushed the feature/add_sse_mcp branch from 8e6927c to f534e80 Compare March 11, 2025 16:46
@aheizi
Copy link
Contributor Author

aheizi commented Mar 12, 2025

@aheizi after seeing this PR, I realized that the ecosystem would benefit from a higher level abstraction for interacting with MCP, and I built https://github.com/punkpeye/mcp-client. Would you consider using it for this PR?

I thought about it and think this is another matter; we can first use the native @modelcontextprotocol/sdk support for SSE MCP and then consider the optimization matters later.

@mrubens How do you think about it?

@mrubens
Copy link
Collaborator

mrubens commented Mar 12, 2025

@aheizi after seeing this PR, I realized that the ecosystem would benefit from a higher level abstraction for interacting with MCP, and I built https://github.com/punkpeye/mcp-client. Would you consider using it for this PR?

I thought about it and think this is another matter; we can first use the native @modelcontextprotocol/sdk support for SSE MCP and then consider the optimization matters later.

@mrubens How do you think about it?

Yeah that sounds fine to me. Excited to get this in. I just tried to resolve the conflicts.

Copy link
Collaborator

@mrubens mrubens left a comment

Choose a reason for hiding this comment

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

Looks good!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 12, 2025
@mrubens mrubens merged commit 5b7ed8e into RooCodeInc:main Mar 12, 2025
9 checks passed
@github-project-automation github-project-automation bot moved this from PR [Pre Approval Review] to Done in Roo Code Roadmap Mar 12, 2025
ipattis pushed a commit to ipattis/roo-code that referenced this pull request Mar 15, 2025
Uncomment i18n Feature + Add to Welcome Page
@aheizi aheizi mentioned this pull request Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants