Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/opencode/src/cli/cmd/tui/context/sync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,11 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
break
}

case "tui.mcp.refresh": {
sdk.client.mcp.status().then((x) => setStore("mcp", reconcile(x.data!)))
break
}

case "vcs.branch.updated": {
setStore("vcs", { branch: event.properties.branch })
break
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/src/cli/cmd/tui/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import z from "zod"

export const TuiEvent = {
PromptAppend: BusEvent.define("tui.prompt.append", z.object({ text: z.string() })),
McpRefresh: BusEvent.define("tui.mcp.refresh", z.object({})),
CommandExecute: BusEvent.define(
"tui.command.execute",
z.object({
Expand Down
10 changes: 10 additions & 0 deletions packages/opencode/src/mcp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ export namespace MCP {
s.clients[name] = result.mcpClient
s.status[name] = result.status

// Notify TUI to refresh MCP status
Bus.publish(TuiEvent.McpRefresh, {})

return {
status: s.status,
}
Expand Down Expand Up @@ -488,6 +491,13 @@ export namespace MCP {
result[key] = s.status[key] ?? { status: "disabled" }
}

// Include dynamically registered MCPs not in config
for (const [key, status] of Object.entries(s.status)) {
if (!(key in result)) {
result[key] = status
}
}

return result
}

Expand Down
8 changes: 7 additions & 1 deletion packages/sdk/js/src/v2/gen/sdk.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type {
ConfigUpdateResponses,
EventSubscribeResponses,
EventTuiCommandExecute,
EventTuiMcpRefresh,
EventTuiPromptAppend,
EventTuiSessionSelect,
EventTuiToastShow,
Expand Down Expand Up @@ -2898,7 +2899,12 @@ export class Tui extends HeyApiClient {
public publish<ThrowOnError extends boolean = false>(
parameters?: {
directory?: string
body?: EventTuiPromptAppend | EventTuiCommandExecute | EventTuiToastShow | EventTuiSessionSelect
body?:
| EventTuiPromptAppend
| EventTuiMcpRefresh
| EventTuiCommandExecute
| EventTuiToastShow
| EventTuiSessionSelect
},
options?: Options<never, ThrowOnError>,
) {
Expand Down
10 changes: 9 additions & 1 deletion packages/sdk/js/src/v2/gen/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,13 @@ export type EventTuiPromptAppend = {
}
}

export type EventTuiMcpRefresh = {
type: "tui.mcp.refresh"
properties: {
[key: string]: unknown
}
}

export type EventTuiCommandExecute = {
type: "tui.command.execute"
properties: {
Expand Down Expand Up @@ -862,6 +869,7 @@ export type Event =
| EventFileEdited
| EventTodoUpdated
| EventTuiPromptAppend
| EventTuiMcpRefresh
| EventTuiCommandExecute
| EventTuiToastShow
| EventTuiSessionSelect
Expand Down Expand Up @@ -4605,7 +4613,7 @@ export type TuiShowToastResponses = {
export type TuiShowToastResponse = TuiShowToastResponses[keyof TuiShowToastResponses]

export type TuiPublishData = {
body?: EventTuiPromptAppend | EventTuiCommandExecute | EventTuiToastShow | EventTuiSessionSelect
body?: EventTuiPromptAppend | EventTuiMcpRefresh | EventTuiCommandExecute | EventTuiToastShow | EventTuiSessionSelect
path?: never
query?: {
directory?: string
Expand Down