Skip to content

Commit 02c9801

Browse files
docs: explain why the mcpReq.send structural cast is needed and sound
1 parent 5c25abd commit 02c9801

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/core/src/shared/protocol.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,10 @@ export abstract class Protocol<ContextT extends BaseContext> {
609609
method: request.method,
610610
_meta: request.params?._meta,
611611
signal: abortController.signal,
612-
// Arrow literals can't carry overload signatures; cast asserts this impl matches the overloaded property type.
612+
// BaseContext.mcpReq.send is declared with two overloads (spec-method-keyed and explicit-schema). Arrow
613+
// literals can't carry overload signatures, so the inferred single-signature type isn't assignable to
614+
// that overloaded property type. The cast is sound: this impl dispatches both overload paths via the
615+
// isStandardSchema guard, and sendRequest validates the result against the resolved schema either way.
613616
send: ((r: Request, schemaOrOptions?: StandardSchemaV1 | TaskRequestOptions, maybeOptions?: TaskRequestOptions) => {
614617
if (isStandardSchema(schemaOrOptions)) {
615618
return sendRequest(r, schemaOrOptions, maybeOptions);

0 commit comments

Comments
 (0)