{"record":{"id":"a077a155f9057279","repo":"vercel/ai","slug":"unsupported-request-schema-only-elicitationreques","errorCode":null,"errorMessage":"Unsupported request schema. Only ElicitationRequestSchema is supported.","messagePattern":"Unsupported request schema\\. Only ElicitationRequestSchema is supported\\.","errorType":"exception","errorClass":"MCPClientError","httpStatus":null,"severity":"error","filePath":"packages/mcp/src/tool/mcp-client.ts","lineNumber":1396,"sourceCode":"    return this.getPromptInternal({ name, args, options });\n  }\n\n  complete(\n    args: CompleteRequestParams & {\n      options?: RequestOptions;\n    },\n  ): Promise<CompleteResult> {\n    return this.completeInternal(args);\n  }\n\n  onElicitationRequest(\n    schema: typeof ElicitationRequestSchema,\n    handler: (\n      request: ElicitationRequest,\n    ) => Promise<ElicitResult> | ElicitResult,\n  ): void {\n    if (schema !== ElicitationRequestSchema) {\n      throw new MCPClientError({\n        message:\n          'Unsupported request schema. Only ElicitationRequestSchema is supported.',\n      });\n    }\n\n    this.elicitationRequestHandler = handler;\n  }\n\n  private async onRequestMessage(request: JSONRPCRequest): Promise<void> {\n    try {\n      if (request.method === 'ping') {\n        await this.transport.send({\n          jsonrpc: '2.0',\n          id: request.id,\n          result: {},\n        });\n        return;\n      }","sourceCodeStart":1378,"sourceCodeEnd":1414,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/mcp/src/tool/mcp-client.ts#L1378-L1414","documentation":"onArrowTools/onToolRegistration (mcp-client.ts) accepts an elicitation handler, but only the MCP spec's ElicitationRequestSchema is supported as the request schema. Passing any other schema value (e.g. a different SDK schema object or a mistyped import) is rejected immediately with MCPClientError so unsupported request kinds are never silently registered.","triggerScenarios":"Calling client.experimental_onElicitationRequest (the elicitation handler registration API on DefaultMCPClient) with a first argument that is not the exact ElicitationRequestSchema identity — e.g. passing a re-declared/zod schema, a schema from a different MCP SDK version, or forgetting the argument entirely.","commonSituations":"Copy-pasting handler registration code from SDKs (like the official TypeScript MCP SDK) that use different schema objects; importing ElicitationRequestSchema from '@modelcontextprotocol/sdk' instead of the AI SDK's mcp package so the identity check (schema !== ElicitationRequestSchema) fails; wrapping or re-exporting the schema.","solutions":["Import ElicitationRequestSchema from the same module version the client uses (the package's exported symbol) and pass that exact object as the first argument","Check your @ai-sdk/mcp (or ai) package version — older versions did not support elicitation; upgrade so the schema and client come from the same release","If you need a different request kind, do not reuse this API; handle other server requests at the transport level or file/await library support"],"exampleFix":"// before\nimport { ElicitationRequestSchema } from '@modelcontextprotocol/sdk/types.js';\nclient.experimental_onElicitationRequest(ElicitationRequestSchema, handler);\n// after\nimport { ElicitationRequestSchema } from 'ai/mcp-stdio'; // same package as the client\nclient.experimental_onElicitationRequest(ElicitationRequestSchema, handler);","handlingStrategy":"validation","validationCode":"import { ElicitationRequestSchema } from 'ai/mcp-stdio'; // same module the client uses\nif (schema !== ElicitationRequestSchema) {\n  throw new Error('elicitation handler must be registered with ElicitationRequestSchema from this package');\n}","typeGuard":null,"tryCatchPattern":"try {\n  client.experimental_onElicitationRequest(ElicitationRequestSchema, handler);\n} catch (error) {\n  if (MCPClientError.isInstance(error) && error.message.includes('Unsupported request schema')) {\n    // fix the schema import/version\n  }\n}","preventionTips":["Always import ElicitationRequestSchema from the same package/version as the MCP client","Do not wrap, re-export, or recreate the schema object","Pin @ai-sdk versions so client and schema come from the same release"],"tags":["api-misuse","elicitation","schema"],"backgroundTag":"unsupported-request-schema","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}