GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — better mcp support - should fix hanging when streamable http server i… · pecastro/opencode@e8eaa77

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • opencode.json
  • packages/opencode/src/mcp
    • index.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎opencode.json‎

Copy file name to clipboardExpand all lines: opencode.json
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
}
2121
},
2222
"mcp": {
23+
"context7": {
24+
"type": "remote",
25+
"url": "https://mcp.context7.com/sse"
26+
},
2327
"weather": {
2428
"type": "local",
2529
"command": ["opencode", "x", "@h1deya/mcp-server-weather"]
Collapse file

‎packages/opencode/src/mcp/index.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/mcp/index.ts
+26-14Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { experimental_createMCPClient, type Tool } from "ai"
2-
import { Experimental_StdioMCPTransport } from "ai/mcp-stdio"
2+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
3+
import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js"
4+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"
35
import { App } from "../app/app"
46
import { Config } from "../config/config"
57
import { Log } from "../util/log"
@@ -32,15 +34,28 @@ export namespace MCP {
3234
}
3335
log.info("found", { key, type: mcp.type })
3436
if (mcp.type === "remote") {
35-
const client = await experimental_createMCPClient({
36-
name: key,
37-
transport: {
38-
type: "sse",
39-
url: mcp.url,
40-
headers: mcp.headers,
41-
},
42-
}).catch(() => {})
43-
if (!client) {
37+
const transports = [
38+
new StreamableHTTPClientTransport(new URL(mcp.url), {
39+
requestInit: {
40+
headers: mcp.headers,
41+
},
42+
}),
43+
new SSEClientTransport(new URL(mcp.url), {
44+
requestInit: {
45+
headers: mcp.headers,
46+
},
47+
}),
48+
]
49+
for (const transport of transports) {
50+
const client = await experimental_createMCPClient({
51+
name: key,
52+
transport,
53+
}).catch(() => {})
54+
if (!client) continue
55+
clients[key] = client
56+
break
57+
}
58+
if (!clients[key])
4459
Bus.publish(Session.Event.Error, {
4560
error: {
4661
name: "UnknownError",
@@ -49,16 +64,13 @@ export namespace MCP {
4964
},
5065
},
5166
})
52-
continue
53-
}
54-
clients[key] = client
5567
}
5668

5769
if (mcp.type === "local") {
5870
const [cmd, ...args] = mcp.command
5971
const client = await experimental_createMCPClient({
6072
name: key,
61-
transport: new Experimental_StdioMCPTransport({
73+
transport: new StdioClientTransport({
6274
stderr: "ignore",
6375
command: cmd,
6476
args,

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.