Skip to content

Commit adc2068

Browse files
refactor(server): rename ServerNotifySugar to ServerNotifier
The type and its factory drop the "-Sugar" suffix: - `ServerNotifySugar` interface → `ServerNotifier` - `createNotifySugar()` → `createServerNotifier()` The runtime export is unchanged (`handler.notify` and the four method names); this is a type/docs-level rename only. Changeset wording, JSDoc, and the serverEventBus tests are updated to match.
1 parent 2427b58 commit adc2068

5 files changed

Lines changed: 15 additions & 15 deletions

File tree

‎.changeset/subscriptions-listen-server.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
New public surface:
1010

11-
- `@modelcontextprotocol/server`: `ServerEventBus`, `ServerEvent`, `ServerNotifySugar` (types); `InMemoryServerEventBus` (class).
12-
- `McpHttpHandler` gains `.notify` (`ServerNotifySugar`: `toolsChanged()`, `promptsChanged()`, `resourcesChanged()`, `resourceUpdated(uri)`) and `.bus` (the `ServerEventBus` listen streams subscribe to).
11+
- `@modelcontextprotocol/server`: `ServerEventBus`, `ServerEvent`, `ServerNotifier` (types); `InMemoryServerEventBus` (class).
12+
- `McpHttpHandler` gains `.notify` (`ServerNotifier`: `toolsChanged()`, `promptsChanged()`, `resourcesChanged()`, `resourceUpdated(uri)`) and `.bus` (the `ServerEventBus` listen streams subscribe to).
1313
- `CreateMcpHandlerOptions` gains `bus?: ServerEventBus` (an in-process `InMemoryServerEventBus` is created when omitted), `maxSubscriptions?: number` (default 1024), and `keepAliveMs?: number` (default 15000).
1414
- `ServeStdioOptions` gains `maxSubscriptions?: number` (default 1024). On a modern-pinned connection `serveStdio` routes the pinned instance's existing `send*ListChanged()` calls onto active subscriptions; legacy connections are unchanged.
1515
- `@modelcontextprotocol/core`: `SUBSCRIPTION_ID_META_KEY` (const); `SubscriptionFilter`, `SubscriptionsListenRequest`, `SubscriptionsListenRequestParams`, `SubscriptionsAcknowledgedNotification`, `SubscriptionsAcknowledgedNotificationParams` (types).

‎packages/server/src/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export { PerRequestHTTPServerTransport } from './server/perRequestTransport.js';
4444
export type { ServerOptions } from './server/server.js';
4545
export { Server } from './server/server.js';
4646
// subscriptions/listen change-event sourcing seam (protocol revision 2026-07-28).
47-
export type { ServerEvent, ServerEventBus, ServerNotifySugar } from './server/serverEventBus.js';
47+
export type { ServerEvent, ServerEventBus, ServerNotifier } from './server/serverEventBus.js';
4848
export { InMemoryServerEventBus } from './server/serverEventBus.js';
4949
// StdioServerTransport and the serveStdio entry are exported from the './stdio' subpath — server stdio
5050
// has only type-level Node imports (erased at compile time), but matching the client's `./stdio` subpath

‎packages/server/src/server/createMcpHandler.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ import { McpServer } from './mcp.js';
6161
import type { PerRequestResponseMode } from './perRequestTransport.js';
6262
import type { Server } from './server.js';
6363
import { installModernOnlyHandlers, seedClientIdentityFromEnvelope } from './server.js';
64-
import type { ServerEventBus, ServerNotifySugar } from './serverEventBus.js';
65-
import { createNotifySugar, InMemoryServerEventBus } from './serverEventBus.js';
64+
import type { ServerEventBus, ServerNotifier } from './serverEventBus.js';
65+
import { createServerNotifier, InMemoryServerEventBus } from './serverEventBus.js';
6666
import { WebStandardStreamableHTTPServerTransport } from './streamableHttp.js';
6767

6868
/* ------------------------------------------------------------------------ *
@@ -242,13 +242,13 @@ export interface McpHttpHandler {
242242
*/
243243
close: () => Promise<void>;
244244
/**
245-
* Typed publish-side sugar over the handler's `subscriptions/listen` bus:
245+
* Typed publish-side facade over the handler's `subscriptions/listen` bus:
246246
* each method publishes the corresponding change event to every open
247247
* subscription stream that opted in to that notification type.
248248
*
249249
* Safe to call when no subscription is open (no-op).
250250
*/
251-
notify: ServerNotifySugar;
251+
notify: ServerNotifier;
252252
/**
253253
* The change-event bus this handler's `subscriptions/listen` streams
254254
* subscribe to (the supplied `bus` option, or the auto-created in-process
@@ -611,7 +611,7 @@ export function createMcpHandler(factory: McpServerFactory, options: CreateMcpHa
611611
};
612612

613613
const bus: ServerEventBus = options.bus ?? new InMemoryServerEventBus(reportError);
614-
const notify = createNotifySugar(bus);
614+
const notify = createServerNotifier(bus);
615615
const listenRouter = createListenRouter({
616616
bus,
617617
maxSubscriptions: options.maxSubscriptions ?? DEFAULT_MAX_SUBSCRIPTIONS,

‎packages/server/src/server/serverEventBus.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ export class InMemoryServerEventBus implements ServerEventBus {
8989
}
9090

9191
/**
92-
* Typed publish-side sugar over `bus.publish` returned by `createMcpHandler`:
92+
* Typed publish-side facade over `bus.publish` returned by `createMcpHandler`:
9393
* each method publishes the corresponding {@linkcode ServerEvent}. Prefer this
9494
* over calling `bus.publish` directly — the names match the wire methods.
9595
*/
96-
export interface ServerNotifySugar {
96+
export interface ServerNotifier {
9797
/** Publish `notifications/tools/list_changed` to every open subscription that opted in. */
9898
toolsChanged(): void;
9999
/** Publish `notifications/prompts/list_changed` to every open subscription that opted in. */
@@ -104,8 +104,8 @@ export interface ServerNotifySugar {
104104
resourceUpdated(uri: string): void;
105105
}
106106

107-
/** Build a {@linkcode ServerNotifySugar} over a bus. */
108-
export function createNotifySugar(bus: ServerEventBus): ServerNotifySugar {
107+
/** Build a {@linkcode ServerNotifier} over a bus. */
108+
export function createServerNotifier(bus: ServerEventBus): ServerNotifier {
109109
return {
110110
toolsChanged: () => bus.publish({ kind: 'tools_list_changed' }),
111111
promptsChanged: () => bus.publish({ kind: 'prompts_list_changed' }),

‎packages/server/test/server/serverEventBus.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest';
22

33
import {
44
InMemoryServerEventBus,
5-
createNotifySugar,
5+
createServerNotifier,
66
honoredSubset,
77
listenFilterAccepts,
88
serverEventToNotification
@@ -114,11 +114,11 @@ describe('InMemoryServerEventBus', () => {
114114
expect(errors[0]!.message).toBe('boom');
115115
});
116116

117-
it('createNotifySugar publishes the matching event kind', () => {
117+
it('createServerNotifier publishes the matching event kind', () => {
118118
const bus = new InMemoryServerEventBus();
119119
const seen: unknown[] = [];
120120
bus.subscribe(e => seen.push(e));
121-
const notify = createNotifySugar(bus);
121+
const notify = createServerNotifier(bus);
122122
notify.toolsChanged();
123123
notify.promptsChanged();
124124
notify.resourcesChanged();

0 commit comments

Comments
 (0)