@@ -26,6 +26,7 @@ import * as RpcSerialization from "../rpc/RpcSerialization.ts"
2626import * as RpcServer from "../rpc/RpcServer.ts"
2727import * as Schema from "../Schema.ts"
2828import type * as Scope from "../Scope.ts"
29+ import * as ModernMcpSchema from "./internal/mcpSchema/v2026_07_28.ts"
2930import type * as McpProtocol from "./McpProtocol.ts"
3031import * as McpSchema from "./McpSchema.ts"
3132import * as McpServer from "./McpServer.ts"
@@ -66,9 +67,15 @@ export interface Client {
6667 readonly listTools : (
6768 request ?: typeof McpSchema . ListTools . payloadSchema . Type
6869 ) => Effect . Effect < McpSchema . ListToolsResult , McpSchema . McpError >
70+ /**
71+ * A tool call that pauses on `2026-07-28` fails with `McpSchema.InputRequired`.
72+ * Supply its unchanged `requestState` and any `inputResponses` to continue.
73+ */
6974 readonly callTool : (
70- request : typeof McpSchema . CallTool . payloadSchema . Type
71- ) => Effect . Effect < McpSchema . CallToolResult , McpSchema . McpError >
75+ request :
76+ & typeof McpSchema . CallTool . payloadSchema . Type
77+ & Pick < typeof ModernMcpSchema . CallTool . payloadSchema . Type , "inputResponses" | "requestState" >
78+ ) => Effect . Effect < McpSchema . CallToolResult , McpSchema . McpError | McpSchema . InputRequired >
7279 readonly listResources : (
7380 request ?: typeof McpSchema . ListResources . payloadSchema . Type
7481 ) => Effect . Effect < McpSchema . ListResourcesResult , McpSchema . McpError >
@@ -327,10 +334,15 @@ export const makeClient: <
327334 }
328335 } ) )
329336 let nextRequestId = 1
330- const rpc = yield * RpcClient . make ( McpSchema . ClientRequestRpcs , {
337+ const rpcOptions = {
331338 spanPrefix : "McpTest" ,
332339 generateRequestId : ( ) => RpcMessage . RequestId ( nextRequestId ++ )
333- } ) . pipe ( Effect . provideService ( RpcClient . Protocol , protocol ) )
340+ }
341+ const rpc = yield * ( selected . protocolVersion === "2026-07-28"
342+ ? RpcClient . make ( modernClientRequestRpcs , rpcOptions )
343+ : RpcClient . make ( McpSchema . ClientRequestRpcs , rpcOptions ) ) . pipe (
344+ Effect . provideService ( RpcClient . Protocol , protocol )
345+ )
334346
335347 let protocolVersion = selected . protocolVersion
336348 if ( selected . runtime . _tag === "Stateful" ) {
@@ -349,7 +361,13 @@ export const makeClient: <
349361 notifications,
350362 ping : Effect . asVoid ( orDieClientError ( rpc . ping ( undefined ) ) ) ,
351363 listTools : ( request ) => orDieClientError ( rpc [ "tools/list" ] ( request ) ) ,
352- callTool : ( request ) => orDieClientError ( rpc [ "tools/call" ] ( request ) ) ,
364+ callTool : Effect . fnUntraced ( function * ( request ) {
365+ const result = yield * orDieClientError ( rpc [ "tools/call" ] ( request ) )
366+ if ( result instanceof McpSchema . CallToolResult ) {
367+ return result
368+ }
369+ return yield * Effect . fail ( new McpSchema . InputRequired ( result ) )
370+ } ) ,
353371 listResources : ( request ) => orDieClientError ( rpc [ "resources/list" ] ( request ) ) ,
354372 listResourceTemplates : ( request ) => orDieClientError ( rpc [ "resources/templates/list" ] ( request ) ) ,
355373 readResource : ( request ) => orDieClientError ( rpc [ "resources/read" ] ( request ) ) ,
@@ -362,6 +380,18 @@ export const makeClient: <
362380 } )
363381} ) as any
364382
383+ // Only the modern binding's tool call has continuation fields. Keep the public
384+ // result and error schemas so ordinary calls still return the same objects.
385+ const modernClientRequestRpcs = McpSchema . ClientRequestRpcs . omit ( "tools/call" ) . add (
386+ McpSchema . CallTool
387+ . setPayload ( {
388+ ...McpSchema . CallTool . payloadSchema . fields ,
389+ inputResponses : ModernMcpSchema . CallTool . payloadSchema . fields . inputResponses ,
390+ requestState : ModernMcpSchema . CallTool . payloadSchema . fields . requestState
391+ } )
392+ . setSuccess ( Schema . Union ( [ McpSchema . CallToolResult , ModernMcpSchema . InputRequiredResult ] ) )
393+ )
394+
365395const serialization = RpcSerialization . jsonRpc ( )
366396
367397const defaultClientInfo : McpSchema . Implementation = { name : "McpTest" , version : "1.0.0" }
0 commit comments