improvement(mcp): ditch custom mcp client in favor of mcp sdk#1780
Merged
waleedlatif1 merged 1 commit intostagingfrom Oct 31, 2025
Merged
improvement(mcp): ditch custom mcp client in favor of mcp sdk#1780waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1 merged 1 commit intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Greptile Overview
Greptile Summary
This PR refactors the MCP (Model Context Protocol) client implementation by replacing a custom JSON-RPC client with the official @modelcontextprotocol/sdk (v1.20.2). The refactoring simplifies the transport layer to only support Streamable HTTP, which is the modern standard for remote MCP servers.
Key Changes:
- Replaced custom
McpClientimplementation with SDK'sClientandStreamableHTTPClientTransport - Removed support for 'http' and 'sse' transport types, keeping only 'streamable-http'
- Removed transport type dropdown from UI - all connections now use Streamable HTTP
- Deleted unused
McpServerModalcomponent (581 lines) - Improved test connection error handling - now only marks success after tools list successfully
- Simplified codebase by leveraging maintained SDK instead of custom protocol implementation
Benefits:
- Uses officially maintained SDK with proper protocol version negotiation
- Reduces maintenance burden by removing ~500+ lines of custom JSON-RPC code
- Better alignment with MCP specification updates
- Cleaner, more focused user experience
Confidence Score: 5/5
- This PR is safe to merge - well-executed refactoring with no breaking changes to functionality
- Score reflects clean refactoring with clear benefits: (1) Replaces custom implementation with official SDK, reducing technical debt (2) Simplifies transport options to match real-world usage (3) Removes 581 lines of unused modal code (4) Improves error handling in test connection flow (5) No logical errors or security issues introduced
- No files require special attention - all changes are straightforward refactoring
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/lib/mcp/client.ts | 5/5 | Refactored to use @modelcontextprotocol/sdk - replaced custom JSON-RPC implementation with official SDK's Client and StreamableHTTPClientTransport |
| apps/sim/lib/mcp/types.ts | 5/5 | Updated McpTransport type to only support 'streamable-http', removing 'http' and 'sse' as separate options |
| apps/sim/lib/mcp/service.ts | 5/5 | Updated to use new SDK-based client, hardcoded transport to 'streamable-http' in getServerConfig method |
| apps/sim/app/api/mcp/servers/test-connection/route.ts | 4/5 | Updated test logic to set success=true only after tools list successfully, improving error handling and warnings |
| apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/settings-modal/components/mcp/mcp.tsx | 5/5 | Removed transport type dropdown UI, hardcoded to use 'streamable-http' - simplified user configuration |
| package.json | 5/5 | Added @modelcontextprotocol/sdk v1.20.2 as dependency to replace custom MCP client implementation |
Sequence Diagram
sequenceDiagram
participant User
participant UI as Settings UI
participant API as Test Connection API
participant McpClient as McpClient (SDK)
participant SDK as @modelcontextprotocol/sdk
participant Transport as StreamableHTTPClientTransport
participant Server as MCP Server
User->>UI: Configure MCP Server (name, URL, headers)
Note over UI: Only streamable-http transport
User->>UI: Click "Test Connection"
UI->>API: POST /api/mcp/servers/test-connection
API->>McpClient: new McpClient(config, securityPolicy)
McpClient->>SDK: new Client(clientInfo, capabilities)
McpClient->>Transport: new StreamableHTTPClientTransport(url, headers)
API->>McpClient: connect()
McpClient->>SDK: client.connect(transport)
SDK->>Server: HTTP POST (initialize handshake)
Server-->>SDK: Protocol version negotiation
SDK-->>McpClient: Connected
API->>McpClient: getNegotiatedVersion()
McpClient->>SDK: client.getServerVersion()
SDK-->>API: Protocol version
API->>McpClient: listTools()
McpClient->>SDK: client.listTools()
SDK->>Server: HTTP POST tools/list
Server-->>SDK: Tools array
SDK-->>McpClient: tools
McpClient-->>API: McpTool[]
alt Tool listing succeeds
API-->>UI: {success: true, toolCount, version}
UI-->>User: ✓ Connection successful
else Tool listing fails
API-->>UI: {success: false, error, warnings}
UI-->>User: ✗ Connection failed
end
API->>McpClient: disconnect()
McpClient->>SDK: client.close()
SDK->>Server: Close connection
12 files reviewed, no comments
waleedlatif1
added a commit
that referenced
this pull request
Nov 12, 2025
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.
Summary
Type of Change
Testing
Tested manually.
Checklist