mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
sync
This commit is contained in:
parent
b8a2a9e7f8
commit
77ec0bda4c
2 changed files with 13 additions and 1 deletions
|
|
@ -5,6 +5,13 @@
|
|||
"weather": {
|
||||
"type": "local",
|
||||
"command": ["bun", "x", "@h1deya/mcp-server-weather"]
|
||||
},
|
||||
"context7": {
|
||||
"type": "remote",
|
||||
"url": "https://mcp.context7.com/mcp",
|
||||
"headers": {
|
||||
"CONTEXT7_API_KEY": "{env:CONTEXT7_API_KEY}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,15 +83,17 @@ export namespace MCP {
|
|||
]
|
||||
let lastError: Error | undefined
|
||||
for (const { name, transport } of transports) {
|
||||
await experimental_createMCPClient({
|
||||
const result = await experimental_createMCPClient({
|
||||
name: "opencode",
|
||||
transport,
|
||||
})
|
||||
.then((client) => {
|
||||
log.info("connected", { key, transport: name })
|
||||
clients[key] = client
|
||||
status[key] = {
|
||||
status: "connected",
|
||||
}
|
||||
return true
|
||||
})
|
||||
.catch((error) => {
|
||||
lastError = error instanceof Error ? error : new Error(String(error))
|
||||
|
|
@ -105,7 +107,9 @@ export namespace MCP {
|
|||
status: "failed",
|
||||
error: lastError.message,
|
||||
}
|
||||
return false
|
||||
})
|
||||
if (result) break
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -145,6 +149,7 @@ export namespace MCP {
|
|||
}
|
||||
|
||||
for (const [key, client] of Object.entries(clients)) {
|
||||
log.info("checking tools", { key })
|
||||
const result = await withTimeout(client.tools(), 5000).catch(() => {})
|
||||
if (!result) {
|
||||
client.close()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue