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 — feat(core): add runtime MCP controls by opencode-agent[bot] · Pull Request #37308 · anomalyco/opencode

Conversation

@opencode-agent

@opencode-agent opencode-agent Bot commented Jul 16, 2026 •
edited by rekram1-node
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

  • add or replace Location-scoped MCP servers at runtime from a full local or remote config
  • connect, disconnect, and remove known MCP servers without persisting runtime state to config; remove deletes the entry and disposes its integration registration while keeping credential rows so re-adding the same server needs no re-auth
  • preserve OAuth integration registration and credential-driven reconnects for dynamically added remote servers
  • clear cached tools, prompts, and resources and publish lifecycle events when replacing or disconnecting a server
  • serialize all lifecycle operations (startup, add, connect, disconnect, credential reconnect) per server with a KeyedMutex<ServerName>; different servers stay concurrent
  • route connection callbacks through the same lock with a single staleness guard (whenLive) so late SDK callbacks and refreshes cannot commit state from a replaced connection
  • settle a new entry's startup deferred even when add fails or is interrupted, so readers awaiting startup can never hang
  • fix whenAllReady capturing a single-use Map iterator: the second query call skipped startup waiting entirely and never saw entries created by add
  • store each remote server's integration registration on its entry and dispose it when add replaces the server, instead of appending a permanent remove transform

This provides the core runtime operations used by V1 ACP while intentionally leaving protocol/server endpoints for a separate change.

Known trade-offs (reviewed, deliberately retained)

  • connect() shows the prior status during the handshake; no pending status or StatusChanged is published at connect/add admission time (UX nit)
  • init-time registration is not batched (N remote servers cause N registry reloads at startup), and replacing a remote server materializes twice (dispose + re-register); State.batch would coalesce
  • whenLive tool/prompt refreshes perform network I/O while holding the per-server lock — intentional; holding the lock through commit is what makes the staleness check sound (bounded by catalog timeout)
  • disconnect() sets status disabled without mutating config.disabled — mirrors V1 semantics; config disabled is only the startup default
  • lock hold during connect is bounded by the startup timeout; a disconnect waits behind an in-flight connect
  • the concurrency test is a probabilistic smoke test, not a deterministic race reproducer
  • an interrupted add() can leave the old entry stopped with a stale status until the next lifecycle op for that name (recoverable; making the section uninterruptible was judged not worth the complexity)
  • disposed integration registrations leave a no-op finalizer in the root scope (idempotent, tiny)
  • the register/dispose integration path has no direct test coverage (the test layer's Integration mock dies on use); correctness was traced through State semantics in review
  • the initial startup fork carries no staleness guard: verified empirically that forked fibers acquire their per-server lock synchronously inside fork() during layer construction, before the Service object exists, so no runtime operation can win that race

Tests

  • bun test test/mcp.test.ts (packages/core), including a lifecycle-race smoke test and NotFoundError coverage
  • bun typecheck (packages/core)
  • scoped oxlint and Effect pattern scan

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node 𝓛𝓲𝓽𝓽𝓵𝓮 𝓕𝓻𝓪𝓷𝓴
feat(core): add runtime MCP controls
0d2b166
@opencode-agent opencode-agent Bot assigned rekram1-node Jul 16, 2026
@github-actions github-actions Bot added the contributor label Jul 16, 2026
rekram1-node and others added 4 commits July 16, 2026 15:08
@rekram1-node 𝓛𝓲𝓽𝓽𝓵𝓮 𝓕𝓻𝓪𝓷𝓴
feat(core): add runtime MCP servers
641caec
@rekram1-node
fix(core): serialize MCP lifecycle operations
2c5bdef
@rekram1-node
fix(core): dispose replaced MCP integration registrations
da830c9
@rekram1-node
feat(core): add runtime MCP server removal
2532cff
@rekram1-node
rekram1-node merged commit cd3cca0 into v2 Jul 18, 2026
10 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@rekram1-node
rekram1-node deleted the mcp-runtime-control branch July 18, 2026 03:56
This was referenced Jul 18, 2026
feat(core): publish pending MCP status during connect #37605
Merged
fix(core): detach disposed MCP registrations from root scope #37660
Merged
This was referenced Jul 18, 2026
toolChoice unwired at v2 HEAD — Kimi K3 skips MCP tool calls under default "auto" #37672
Closed
feat(session): expose toolChoice via PromptInput and agent config #37678
Closed
feat(mcp): bridge runtime-added MCP tools into the core tool registry #37684
Closed
paperview added a commit to paperview/opencode_ex that referenced this pull request Jul 18, 2026
@paperview
feat: MCP runtime API + toolChoice + directory scoping
177890d
Additions supporting the sync_server chatbot bridge against our
patched opencode daemon (paperview/opencode:paperview-stable):

- New OpencodeEx.MCP module: `status/2`, `add/4`, `disconnect/2`,
  `connect/2`. Wraps the runtime MCP endpoints introduced in
  anomalyco/opencode#37308. Accepts `directory:` keyword for
  workspace-scoped operations (`?directory=...`).
- `OpencodeEx.Session.create/2` accepts `directory:` for scoping the
  session to a specific instance. Runtime MCP entries added with the
  same directory become visible to that session's tool registry.
- `OpencodeEx.Session.prompt/4` accepts `tool_choice:` ("auto" |
  "required" | "none"). Serialized as `toolChoice` on the request
  body. Silently ignored by stock upstream (unknown field on legacy
  endpoint); honored on our patched fork via
  anomalyco/opencode#37678.

Backward-compatible: default paths and bodies unchanged when the new
options are unset.
@simonklee simonklee mentioned this pull request Jul 19, 2026
mini: fix shell tool output display #37711
Merged
@rekram1-node rekram1-node mentioned this pull request Jul 19, 2026
feat(server): expose runtime MCP controls over HTTP #37712
Merged
@simonklee simonklee mentioned this pull request Jul 20, 2026
tui/mini: consolidate stream and panel internals #37903
Merged
@abhirampuranik abhirampuranik mentioned this pull request Jul 26, 2026
[FEATURE]: Add and Remove MCP servers from the TUI dialog with config persistence #38993
Closed
1 of 6 tasks
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
@opencode-agent @rekram1-node
feat(core): add runtime MCP controls (anomalyco#37308)
7e2dca9
Co-authored-by: Aiden Cline <[email protected]>
Co-authored-by: Aiden Cline <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@rekram1-node rekram1-node

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@rekram1-node
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.
You are visitor 01402775 — 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.