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): publish MCP events on the bus by rekram1-node · Pull Request #63261 · anomalyco/opencode

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Nov 11, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Problem

#63254 added an MCP Events client, but only code inside the MCP service could read a server's events, one stream per caller, with nothing keeping a subscription alive across a broken stream or a reconnect. Clients and plugins could not see them at all.

Change

Experimental, behind the mcp_events flag (MCP Events is a draft extension).

  • Public bus event (reaches clients through /event and plugins through ctx.event.subscribe, like the other MCP events):
    • experimental.mcp.event { id, server, name, eventId, timestamp, data, cursor, truncated? }: one per event. Delivery is at least once; dedupe on id + eventId.
  • Subscription status changes stay internal to core and are queryable through Mcp.Service.subscriptions().
  • Mcp.Service: subscribe(server, { name, arguments?, cursor? }), unsubscribe(id), subscriptions(). A subscription has status: pending | active | ended(terminated | rejected | unavailable) (Mcp.SubscriptionStatus) and its last cursor. Its id hashes server, name and arguments with keys sorted at every depth, so the same subscription is returned instead of a second stream.
  • Lifecycle, in one place: the service already publishes mcp.status.changed on every server status change; it listens to it and starts or stops that server's subscriptions. Connected with events: stream. Pending or failed: stop, pending. Removed, disabled or no events: ended: unavailable. Streams run in the service, in its Location, never in a pooled connection's scope.
  • Each stream reopens from the last cursor after a close, a break or 60 s of silence, with backoff from 1 s to 30 s. terminated ends it; so does a rejection (EventStreamRejectedError, JSON-RPC -32601, -32602, -32023, -32024 or -32026). If the server reports a replay gap with a non-null cursor, the next event carries truncated: true. Reopening without a cursor does not imply a gap.
  • Client: events/stream rejections fail with EventStreamRejectedError instead of a bare error. Live events use the existing stream handoff without a new cutoff.

Not included: HTTP routes to create or list subscriptions, persistence across restarts, keeping an idle Location alive for its subscriptions.

Tests

test/mcp.test.ts over Streamable HTTP with a held-open event stream and a working bus: events reach the bus with every field and status follows pending → active; the same arguments in another key order return the same subscription; unsubscribing cancels the stream; a closed stream reopens from the last cursor (heartbeats advance it); terminated and a NotFound rejection end it without reopening; a reconnect resumes from the cursor and disabling ends it; the flag off refuses, and a server without events ends unavailable.

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" fill="none" stroke="currentColor">
  <style>
    .e{animation:f 3s linear infinite;opacity:.9}
    .e2{animation-delay:-1s;transform:translateX(40px)}.e3{animation-delay:-2s;transform:translateX(80px)}
    @keyframes f{0%{transform:translateX(0);opacity:0}10%{opacity:.9}85%{opacity:.9}100%{transform:translateX(118px);opacity:0}}
    @media (prefers-reduced-motion:reduce){.e{animation:none}}
  </style>
  <rect x="12" y="20" width="56" height="32" rx="6" stroke-opacity=".7"/>
  <text x="40" y="40" text-anchor="middle" font-family="ui-monospace,monospace" font-size="10" fill="currentColor" stroke="none" opacity=".8">MCP</text>
  <path d="M68 36H196" stroke-opacity=".3" stroke-dasharray="3 4"/>
  <rect x="196" y="16" width="32" height="40" rx="6" stroke-opacity=".7"/>
  <path d="M204 28h16M204 36h16M204 44h16" stroke-opacity=".5"/>
  <g fill="currentColor" stroke="none">
    <circle class="e" cx="74" cy="36" r="4"/>
    <circle class="e e2" cx="74" cy="36" r="4"/>
    <circle class="e e3" cx="74" cy="36" r="4"/>
  </g>
</svg>

Added by the opencode bot (AI-generated).

Related: #48855

Public API: adds the experimental.mcp.event event, Mcp.SubscriptionStatus and Mcp.Service subscribe/unsubscribe/subscriptions (backwards compatible)

Sorry, something went wrong.

Uh oh!

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

All reactions
@github-actions github-actions Bot added the contributor label Nov 11, 2026
Base automatically changed from mcp-events to dev November 11, 2026 06:22
opencodejr[bot]
opencodejr Bot reviewed Nov 11, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The design looks sound. Subscriptions are deduplicated by ID, cursor resume and reconnect handling are correct, the client buffer is bounded and fails instead of dropping messages, and everything is behind the mcp_events flag. I ran the new MCP Events tests in mcp.test.ts and mcp-events.test.ts and they all pass. The one failing test in mcp.test.ts also fails on the base. tsc --noEmit is clean for packages/core and packages/schema. The packages' typecheck script can't run here because this Bun has no bun check.

Public API impact, all additions and backwards compatible:

  • New non-durable events experimental.mcp.event and experimental.mcp.event.ended, on /event and ctx.event.subscribe, in openapi.json and in the generated client types.
  • New config flag mcp_events.
  • Mcp.Service gains events, subscribe, unsubscribe and subscriptions, plus EventsUnavailableError.
  • Event definitions accept a description, which appears in the OpenAPI spec.
  • When the flag is on, connections declare the io.modelcontextprotocol/events extension to servers, and the pool key includes it.

One concern, inline: an events/stream request rejected with a permanent error, such as an unknown event name, is retried forever and never publishes ended.

Note: the diff against the base also contains #63254's commits until this pull request is retargeted.

Related: #48855

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread packages/core/src/mcp/index.ts Resolved

Uh oh!

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

@rekram1-node
feat(core): publish MCP events on the bus
3bfdd39
@rekram1-node
rekram1-node force-pushed the mcp-event-bus branch from add0896 to 3bfdd39 Compare November 11, 2026 07:32
opencodejr[bot]
opencodejr Bot reviewed Nov 11, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rejected events/stream requests now end the subscription as rejected, which fixes my earlier point. The new MCP Events tests pass and tsc --noEmit is clean for packages/core and packages/schema. The one failing test in mcp.test.ts also fails on the base.

Public API, all experimental additions and backwards compatible:

  • Events experimental.mcp.event ({ id, server, name, eventId, timestamp, data, cursor, truncated? }) and experimental.mcp.subscription.changed ({ id }), on /event, in openapi.json and in the client types.
  • Mcp.SubscriptionStatus schema.
  • Mcp.Service subscribe / unsubscribe / subscriptions, plus EventsUnavailableError and McpClient.EventStreamRejectedError.

Two new points, inline: the reopen backoff never resets after a healthy stream, and two tests run on the real clock with a fixed sleep.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread packages/core/src/mcp/index.ts Resolved

Uh oh!

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

Comment thread packages/core/test/mcp.test.ts Resolved

Uh oh!

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

@rekram1-node
fix(schema): keep MCP subscription status changes internal
9c1cfa5
opencodejr[bot]
opencodejr Bot reviewed Nov 11, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push takes experimental.mcp.subscription.changed out of the public event manifest, openapi.json and the client types. Subscription status is now readable only through Mcp.Service.subscriptions(), with the event kept internal to core. The manifest test passes and tsc --noEmit is clean for packages/schema.

Public API, compared with the previous revision: experimental.mcp.subscription.changed is removed from /event and the OpenAPI spec. That event had not shipped, so nothing breaks. The remaining additions are all experimental and backwards compatible: experimental.mcp.event, Mcp.SubscriptionStatus, Mcp.Service subscribe / unsubscribe / subscriptions, EventsUnavailableError and EventStreamRejectedError.

The open points on reopen backoff and live-clock tests are unchanged by this push.

Sorry, something went wrong.

Uh oh!

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

All reactions
@rekram1-node
refactor(schema): keep MCP event documentation local
c6ec2f0
opencodejr[bot]
opencodejr Bot reviewed Nov 12, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push removes the description option from event definitions, and with it the description on experimental.mcp.event in openapi.json. tsc --noEmit is clean for packages/schema and packages/core, and the manifest test passes.

Public API, compared with the previous revision: the spec only loses a doc string, which is backwards compatible. Overall the PR still adds, all experimental and backwards compatible: experimental.mcp.event, Mcp.SubscriptionStatus, Mcp.Service subscribe / unsubscribe / subscriptions, EventsUnavailableError and EventStreamRejectedError.

The open points on reopen backoff and live-clock tests aren't touched by this push.

Sorry, something went wrong.

Uh oh!

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

All reactions
@github-actions github-actions Bot mentioned this pull request Nov 12, 2026
📊 AI CLI 工具社区动态日报 2026-11-12 litang9/big_model_radar#691
Open
@rekram1-node
fix(core): forward MCP events without an overflow disconnect
53c1036
opencodejr[bot]
opencodejr Bot reviewed Nov 12, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This push sets truncated only when the server reports a gap with a non-null cursor, and drops the per-stream buffer cap. Without a cap the queue is unbounded rather than dropping messages. The updated MCP Events tests pass and tsc --noEmit is clean for packages/core.

The public API is unchanged from the previous revision. It still adds, all experimental and backwards compatible: experimental.mcp.event, Mcp.SubscriptionStatus, Mcp.Service subscribe / unsubscribe / subscriptions, EventsUnavailableError and EventStreamRejectedError.

The open points on reopen backoff and live-clock tests aren't touched by this push.

Sorry, something went wrong.

Uh oh!

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

All reactions
@rekram1-node
fix(core): reset MCP event retry delay after an active stream
f2bf996
opencodejr[bot]
opencodejr Bot reviewed Nov 12, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reopen backoff now resets once a stream sends active, so the delay no longer climbs to 30 s over a long-lived subscription. The terminate/reject test runs on TestClock without the fixed sleep. The MCP Events tests passed on each of 3 runs and tsc --noEmit is clean for packages/core. The public API is unchanged in this push.

One new point, inline: the backoff test intercepts Clock.sleep to pick out retry delays, which is hard to follow.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread packages/core/test/mcp.test.ts Resolved

Uh oh!

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

@rekram1-node
test(core): observe MCP stream opens instead of intercepting sleeps
4ca00f0
opencodejr[bot]
opencodejr Bot reviewed Nov 12, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backoff test no longer wraps Clock. It records when each events/stream open happens under TestClock and checks that failed opens back off 1 s then 2 s, and that the delay resets to 1 s after a stream that sent active closes. That addresses my earlier point about the test. The MCP Events tests passed on all 5 runs and tsc --noEmit is clean for packages/core. The public API is unchanged in this push; nothing new to raise.

Sorry, something went wrong.

Uh oh!

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

All reactions
@rekram1-node
refactor(core): carry JSON and typed errors through MCP event subscri…
c15c950
…ptions
opencodejr[bot]
opencodejr Bot reviewed Nov 12, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup with no behaviour change, and nothing new to raise. Key-sorted hashing is now one shared canonicalJson helper, and the instructions test pins the existing hash value. The event stream errors live in a small module, so mcp/index.ts uses instanceof without loading the client module. Event data and arguments are typed as JSON. The MCP Events and instructions tests pass; the one failing test in mcp.test.ts also fails on the base. tsc --noEmit is clean for packages/core and packages/schema.

Public API in this push: the generated ExperimentalMcpEvent.data type is now JsonValue instead of any. It's narrower but experimental and unreleased, so nothing breaks. Mcp.SubscriptionStatus now requires error on terminated and rejected.

Sorry, something went wrong.

Uh oh!

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

All reactions
@rekram1-node
rekram1-node merged commit 2c1e17b into dev Nov 12, 2026
11 checks passed

Uh oh!

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

@rekram1-node
rekram1-node deleted the mcp-event-bus branch November 12, 2026 03:41
simonklee added a commit that referenced this pull request Nov 12, 2026
@simonklee
feat(cli-rs): decode the experimental MCP event (#63261)
e29c4e6
Regenerate the API types and the F.7 fold oracle for experimental.mcp.event. No client shows the event: the TS TUI and mini do not subscribe to it, and the store ignores it.
simonklee added a commit that referenced this pull request Nov 12, 2026
@simonklee
feat(cli-rs): decode the experimental MCP event (#63261)
e52d2e4
Regenerate the API types and the F.7 fold oracle for experimental.mcp.event. No client shows the event: the TS TUI and mini do not subscribe to it, and the store ignores it.
simonklee added a commit that referenced this pull request Nov 12, 2026
@simonklee
feat(cli-rs): decode the experimental MCP event (#63261)
0485dca
Regenerate the API types and the F.7 fold oracle for experimental.mcp.event. No client shows the event: the TS TUI and mini do not subscribe to it, and the store ignores it.
simonklee added a commit that referenced this pull request Nov 12, 2026
@simonklee
feat(cli-rs): decode the experimental MCP event (#63261)
3b6d3fc
Regenerate the API types and the F.7 fold oracle for experimental.mcp.event. No client shows the event: the TS TUI and mini do not subscribe to it, and the store ignores it.
simonklee added a commit that referenced this pull request Nov 13, 2026
@simonklee
feat(cli-rs): decode the experimental MCP event (#63261)
3c8c723
Regenerate the API types and the F.7 fold oracle for experimental.mcp.event. No client shows the event: the TS TUI and mini do not subscribe to it, and the store ignores it.
@amrkmn amrkmn mentioned this pull request Nov 13, 2026
opencode 2.3.0 amrkmn/homebrew-tap#1231
Closed
1 task
@github-actions github-actions Bot mentioned this pull request Nov 13, 2026
feat: opencode release v2.3.0 sprisa/opencode-server#86
Merged
@kobzevvv kobzevvv mentioned this pull request Nov 13, 2026
chore(upstream): порт v2.3.0 — 101 в порт, 75 на решение gpt-mem/opencode-mem#222
Open
simonklee added a commit that referenced this pull request Nov 13, 2026
@simonklee
feat(cli-rs): decode the experimental MCP event (#63261)
b7fb3ce
Regenerate the API types and the F.7 fold oracle for experimental.mcp.event. No client shows the event: the TS TUI and mini do not subscribe to it, and the store ignores it.
@github-actions github-actions Bot mentioned this pull request Nov 14, 2026
Tool release: OpenCode 2 v2.3.0 (was v2.2.7) agent-sh/agnix#1844
Closed
simonklee added a commit that referenced this pull request Nov 14, 2026
@simonklee
feat(cli-rs): decode the experimental MCP event (#63261)
e17c513
Regenerate the API types and the F.7 fold oracle for experimental.mcp.event. No client shows the event: the TS TUI and mini do not subscribe to it, and the store ignores it.
simonklee added a commit that referenced this pull request Nov 14, 2026
@simonklee
feat(cli-rs): decode the experimental MCP event (#63261)
d4b230f
Regenerate the API types and the F.7 fold oracle for experimental.mcp.event. No client shows the event: the TS TUI and mini do not subscribe to it, and the store ignores it.
simonklee added a commit that referenced this pull request Nov 15, 2026
@simonklee
feat(cli-rs): decode the experimental MCP event (#63261)
1a1a7c3
Regenerate the API types and the F.7 fold oracle for experimental.mcp.event. No client shows the event: the TS TUI and mini do not subscribe to it, and the store ignores it.
simonklee added a commit that referenced this pull request Nov 15, 2026
@simonklee
feat(cli-rs): decode the experimental MCP event (#63261)
93c092e
Regenerate the API types and the F.7 fold oracle for experimental.mcp.event. No client shows the event: the TS TUI and mini do not subscribe to it, and the store ignores it.
simonklee added a commit that referenced this pull request Nov 16, 2026
@simonklee
feat(cli-rs): decode the experimental MCP event (#63261)
17e1da9
Regenerate the API types and the F.7 fold oracle for experimental.mcp.event. No client shows the event: the TS TUI and mini do not subscribe to it, and the store ignores it.
simonklee added a commit that referenced this pull request Nov 16, 2026
@simonklee
feat(cli-rs): decode the experimental MCP event (#63261)
2f671ea
Regenerate the API types and the F.7 fold oracle for experimental.mcp.event. No client shows the event: the TS TUI and mini do not subscribe to it, and the store ignores it.
simonklee added a commit that referenced this pull request Nov 17, 2026
@simonklee
feat(cli-rs): decode the experimental MCP event (#63261)
1b4202f
Regenerate the API types and the F.7 fold oracle for experimental.mcp.event. No client shows the event: the TS TUI and mini do not subscribe to it, and the store ignores it.
@scottames-github-bot scottames-github-bot Bot mentioned this pull request Nov 17, 2026
chore(deps): update ⬆️ mise-packages scottames/dots#1167
Merged
1 task
simonklee added a commit that referenced this pull request Nov 17, 2026
@simonklee
feat(cli-rs): decode the experimental MCP event (#63261)
c1b5cc3
Regenerate the API types and the F.7 fold oracle for experimental.mcp.event. No client shows the event: the TS TUI and mini do not subscribe to it, and the store ignores it.
simonklee added a commit that referenced this pull request Nov 18, 2026
@simonklee
feat(cli-rs): decode the experimental MCP event (#63261)
bc86a83
Regenerate the API types and the F.7 fold oracle for experimental.mcp.event. No client shows the event: the TS TUI and mini do not subscribe to it, and the store ignores it.
@mkobit mkobit mentioned this pull request Nov 20, 2026
Update opencode from 2.2.7 to 2.3.0 mkobit/dotfiles#1116
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

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

Assignees

No one assigned

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.