Skip to content

Commit 8356e05

Browse files
authored
feat: support streameable http transport (RooCodeInc#3413)
* feat: support Stremeable Http transport * feat: add http to rpc method
1 parent 0870c65 commit 8356e05

File tree

5 files changed

+44
-41
lines changed

5 files changed

+44
-41
lines changed

.changeset/rare-flowers-switch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": minor
3+
---
4+
5+
Support Streameable Http Transport for MCPs

esbuild.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,6 @@ const baseConfig = {
134134
aliasResolverPlugin,
135135
/* add to the end of plugins array */
136136
esbuildProblemMatcherPlugin,
137-
{
138-
name: "alias-plugin",
139-
setup(build) {
140-
build.onResolve({ filter: /^pkce-challenge$/ }, (args) => {
141-
return { path: require.resolve("pkce-challenge/dist/index.browser.js") }
142-
})
143-
},
144-
},
145137
],
146138
format: "cjs",
147139
sourcesContent: false,

package-lock.json

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@
341341
"@grpc/grpc-js": "^1.9.15",
342342
"@grpc/reflection": "^1.0.4",
343343
"@mistralai/mistralai": "^1.5.0",
344-
"@modelcontextprotocol/sdk": "^1.7.0",
344+
"@modelcontextprotocol/sdk": "^1.11.1",
345345
"@opentelemetry/api": "^1.4.1",
346346
"@opentelemetry/exporter-trace-otlp-http": "^0.39.1",
347347
"@opentelemetry/resources": "^1.30.1",

src/services/mcp/McpHub.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { arePathsEqual } from "@utils/path"
3030
import { secondsToMs } from "@utils/time"
3131
import { GlobalFileNames } from "@core/storage/disk"
3232
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js"
33+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
3334
import { ExtensionMessage } from "@shared/ExtensionMessage"
3435

3536
// Default timeout for internal MCP data requests in milliseconds; is not the same as the user facing timeout stored as DEFAULT_MCP_TIMEOUT_SECONDS
@@ -38,10 +39,10 @@ const DEFAULT_REQUEST_TIMEOUT_MS = 5000
3839
export type McpConnection = {
3940
server: McpServer
4041
client: Client
41-
transport: StdioClientTransport | SSEClientTransport
42+
transport: StdioClientTransport | SSEClientTransport | StreamableHTTPClientTransport
4243
}
4344

44-
export type McpTransportType = "stdio" | "sse"
45+
export type McpTransportType = "stdio" | "sse" | "http"
4546

4647
export type McpServerConfig = z.infer<typeof ServerConfigSchema>
4748

@@ -54,22 +55,23 @@ const BaseConfigSchema = z.object({
5455
})
5556

5657
const SseConfigSchema = BaseConfigSchema.extend({
58+
transportType: z.literal("sse"),
5759
url: z.string().url(),
58-
}).transform((config) => ({
59-
...config,
60-
transportType: "sse" as const,
61-
}))
60+
})
6261

6362
const StdioConfigSchema = BaseConfigSchema.extend({
63+
transportType: z.literal("stdio"),
6464
command: z.string(),
6565
args: z.array(z.string()).optional(),
6666
env: z.record(z.string()).optional(),
67-
}).transform((config) => ({
68-
...config,
69-
transportType: "stdio" as const,
70-
}))
67+
})
68+
69+
const StreamableHTTPConfigSchema = BaseConfigSchema.extend({
70+
transportType: z.literal("http"),
71+
url: z.string().url(),
72+
})
7173

72-
const ServerConfigSchema = z.union([StdioConfigSchema, SseConfigSchema])
74+
const ServerConfigSchema = z.discriminatedUnion("transportType", [StdioConfigSchema, SseConfigSchema, StreamableHTTPConfigSchema])
7375

7476
const McpSettingsSchema = z.object({
7577
mcpServers: z.record(ServerConfigSchema),
@@ -183,7 +185,7 @@ export class McpHub {
183185

184186
private async connectToServerRPC(
185187
name: string,
186-
config: z.infer<typeof StdioConfigSchema> | z.infer<typeof SseConfigSchema>,
188+
config: z.infer<typeof StdioConfigSchema> | z.infer<typeof SseConfigSchema> | z.infer<typeof StreamableHTTPConfigSchema>,
187189
): Promise<void> {
188190
// Remove existing connection if it exists (should never happen, the connection should be deleted beforehand)
189191
this.connections = this.connections.filter((conn) => conn.server.name !== name)
@@ -200,10 +202,12 @@ export class McpHub {
200202
},
201203
)
202204

203-
let transport: StdioClientTransport | SSEClientTransport
205+
let transport: StdioClientTransport | SSEClientTransport | StreamableHTTPClientTransport
204206

205207
if (config.transportType === "sse") {
206208
transport = new SSEClientTransport(new URL(config.url), {})
209+
} else if (config.transportType === "http") {
210+
transport = new StreamableHTTPClientTransport(new URL(config.url), {})
207211
} else {
208212
transport = new StdioClientTransport({
209213
command: config.command,
@@ -297,7 +301,7 @@ export class McpHub {
297301

298302
private async connectToServer(
299303
name: string,
300-
config: z.infer<typeof StdioConfigSchema> | z.infer<typeof SseConfigSchema>,
304+
config: z.infer<typeof StdioConfigSchema> | z.infer<typeof SseConfigSchema> | z.infer<typeof StreamableHTTPConfigSchema>,
301305
): Promise<void> {
302306
// Remove existing connection if it exists (should never happen, the connection should be deleted beforehand)
303307
this.connections = this.connections.filter((conn) => conn.server.name !== name)
@@ -314,10 +318,12 @@ export class McpHub {
314318
},
315319
)
316320

317-
let transport: StdioClientTransport | SSEClientTransport
321+
let transport: StdioClientTransport | SSEClientTransport | StreamableHTTPClientTransport
318322

319323
if (config.transportType === "sse") {
320324
transport = new SSEClientTransport(new URL(config.url), {})
325+
} else if (config.transportType === "http") {
326+
transport = new StreamableHTTPClientTransport(new URL(config.url), {})
321327
} else {
322328
transport = new StdioClientTransport({
323329
command: config.command,

0 commit comments

Comments
 (0)