Skip to content

Commit fc9885b

Browse files
simplify: remove dispatchRaw + RawDispatchOutput + grpc-integration doc
No consumer; synthesizes id:0 which breaks correlation/cancellation; SEP-2598 (which would govern the mapping) is still draft. Re-add when a real gRPC transport is in scope.
1 parent 94c5403 commit fc9885b

3 files changed

Lines changed: 0 additions & 140 deletions

File tree

docs/grpc-integration.md

Lines changed: 0 additions & 75 deletions
This file was deleted.

packages/core/src/shared/dispatcher.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@ export type DispatchOutput =
2929
| { kind: 'notification'; message: JSONRPCNotification }
3030
| { kind: 'response'; message: JSONRPCResponse | JSONRPCErrorResponse };
3131

32-
/**
33-
* Envelope-agnostic output from {@linkcode Dispatcher.dispatchRaw}. No JSON-RPC `{jsonrpc, id}` wrapping.
34-
*/
35-
export type RawDispatchOutput =
36-
| { kind: 'notification'; method: string; params?: Record<string, unknown> }
37-
| { kind: 'result'; result: Result }
38-
| { kind: 'error'; code: number; message: string; data?: unknown };
39-
4032
type RawHandler<ContextT> = (request: JSONRPCRequest, ctx: ContextT) => Promise<Result>;
4133

4234
/** Signature of {@linkcode Dispatcher.dispatch}. Target type for {@linkcode DispatchMiddleware}. */
@@ -191,31 +183,6 @@ export class Dispatcher<ContextT extends BaseContext = BaseContext> {
191183
yield { kind: 'response', message: final! };
192184
}
193185

194-
/**
195-
* Envelope-agnostic dispatch for non-JSON-RPC drivers (gRPC, protobuf, REST).
196-
* Takes `{method, params}` directly and yields unwrapped notifications and a terminal
197-
* result/error. The JSON-RPC `{jsonrpc, id}` envelope is synthesized internally so
198-
* registered handlers (which receive `JSONRPCRequest`) work unchanged.
199-
*
200-
* @experimental Shape may change to align with SEP-1319 named param/result types.
201-
*/
202-
async *dispatchRaw(
203-
method: string,
204-
params: Record<string, unknown> | undefined,
205-
env: RequestEnv = {}
206-
): AsyncGenerator<RawDispatchOutput, void, void> {
207-
const synthetic: JSONRPCRequest = { jsonrpc: '2.0', id: 0, method, params };
208-
for await (const out of this.dispatch(synthetic, env)) {
209-
if (out.kind === 'notification') {
210-
yield { kind: 'notification', method: out.message.method, params: out.message.params };
211-
} else if ('result' in out.message) {
212-
yield { kind: 'result', result: out.message.result };
213-
} else {
214-
yield { kind: 'error', ...out.message.error };
215-
}
216-
}
217-
}
218-
219186
/**
220187
* Dispatch one inbound notification to its handler. Errors are reported via the
221188
* returned promise; unknown methods are silently ignored.

packages/core/test/shared/dispatcher.test.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -212,35 +212,3 @@ describe('Dispatcher.setRequestHandler 3-arg (custom method + paramsSchema)', ()
212212
expect(r.error.message).toMatch(/Invalid params for acme\/search/);
213213
});
214214
});
215-
216-
describe('Dispatcher.dispatchRaw (envelope-agnostic)', () => {
217-
test('yields result without JSON-RPC envelope', async () => {
218-
const d = new Dispatcher();
219-
d.setRawRequestHandler('greet', async r => ({ hello: (r.params as { name: string }).name }) as Result);
220-
const out = [];
221-
for await (const o of d.dispatchRaw('greet', { name: 'proto' })) out.push(o);
222-
expect(out).toEqual([{ kind: 'result', result: { hello: 'proto' } }]);
223-
});
224-
225-
test('yields error without envelope', async () => {
226-
const d = new Dispatcher();
227-
d.setRawRequestHandler('boom', async () => {
228-
throw new ProtocolError(ProtocolErrorCode.InvalidParams, 'bad');
229-
});
230-
const out = [];
231-
for await (const o of d.dispatchRaw('boom', {})) out.push(o);
232-
expect(out).toEqual([{ kind: 'error', code: ProtocolErrorCode.InvalidParams, message: 'bad' }]);
233-
});
234-
235-
test('yields notifications then result', async () => {
236-
const d = new Dispatcher();
237-
d.setRawRequestHandler('work', async (_r, ctx) => {
238-
await ctx.mcpReq.notify({ method: 'notifications/progress', params: { progressToken: 't', progress: 1 } });
239-
return { done: true } as Result;
240-
});
241-
const out = [];
242-
for await (const o of d.dispatchRaw('work', {})) out.push(o);
243-
expect(out[0]).toMatchObject({ kind: 'notification', method: 'notifications/progress' });
244-
expect(out[1]).toEqual({ kind: 'result', result: { done: true } });
245-
});
246-
});

0 commit comments

Comments
 (0)