@modelcontextprotocol/sdk
    Preparing search index...

    Class Client<RequestT, NotificationT, ResultT>

    An MCP client on top of a pluggable transport.

    The client will automatically begin the initialization flow with the server when connect() is called.

    To use with custom types, extend the base Request/Notification/Result types and pass them as type parameters:

    // Custom schemas
    const CustomRequestSchema = RequestSchema.extend({...})
    const CustomNotificationSchema = NotificationSchema.extend({...})
    const CustomResultSchema = ResultSchema.extend({...})

    // Type aliases
    type CustomRequest = z.infer<typeof CustomRequestSchema>
    type CustomNotification = z.infer<typeof CustomNotificationSchema>
    type CustomResult = z.infer<typeof CustomResultSchema>

    // Create typed client
    const client = new Client<CustomRequest, CustomNotification, CustomResult>({
    name: "CustomClient",
    version: "1.0.0"
    })

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    • Initializes this client with the given name and version information.

      Type Parameters

      • RequestT extends {
            method: string;
            params?: {
                _meta?: { progressToken?: string | number; [key: string]: unknown };
                [key: string]: unknown;
            };
        } = {
            method: string;
            params?: {
                _meta?: { progressToken?: string | number; [key: string]: unknown };
                [key: string]: unknown;
            };
        }
      • NotificationT extends {
            method: string;
            params?: { _meta?: { [key: string]: unknown }; [key: string]: unknown };
        } = {
            method: string;
            params?: { _meta?: { [key: string]: unknown }; [key: string]: unknown };
        }
      • ResultT extends { _meta?: { [key: string]: unknown }; [key: string]: unknown } = { _meta?: { [key: string]: unknown }; [key: string]: unknown }

      Parameters

      • _clientInfo: {
            icons?: {
                mimeType?: string;
                sizes?: string[];
                src: string;
                [key: string]: unknown;
            }[];
            name: string;
            title?: string;
            version: string;
            websiteUrl?: string;
            [key: string]: unknown;
        }
        • [key: string]: unknown
        • Optionalicons?: { mimeType?: string; sizes?: string[]; src: string; [key: string]: unknown }[]

          Optional set of sized icons that the client can display in a user interface.

          Clients that support rendering icons MUST support at least the following MIME types:

          • image/png - PNG images (safe, universal compatibility)
          • image/jpeg (and image/jpg) - JPEG images (safe, universal compatibility)

          Clients that support rendering icons SHOULD also support:

          • image/svg+xml - SVG images (scalable but requires security precautions)
          • image/webp - WebP images (modern, efficient format)
        • name: string

          Intended for programmatic or logical use, but used as a display name in past specs or fallback

        • Optionaltitle?: string

          Intended for UI and end-user contexts — optimized to be human-readable and easily understood, even by those unfamiliar with domain-specific terminology.

          If not provided, the name should be used for display (except for Tool, where annotations.title should be given precedence over using name, if present).

        • version: string
        • OptionalwebsiteUrl?: string

          An optional URL of the website for this implementation.

      • Optionaloptions: ClientOptions

      Returns Client<RequestT, NotificationT, ResultT>

    Properties

    fallbackNotificationHandler?: (
        notification: {
            method: string;
            params?: { _meta?: { [key: string]: unknown }; [key: string]: unknown };
        },
    ) => Promise<void>

    A handler to invoke for any notification types that do not have their own handler installed.

    fallbackRequestHandler?: (
        request: {
            id: string | number;
            jsonrpc: "2.0";
            method: string;
            params?: {
                _meta?: { progressToken?: string | number; [key: string]: unknown };
                [key: string]: unknown;
            };
        },
        extra: RequestHandlerExtra<
            ClientRequest
            | RequestT,
            ClientNotification | NotificationT,
        >,
    ) => Promise<ClientResult | ResultT>

    A handler to invoke for any request types that do not have their own handler installed.

    onclose?: () => void

    Callback for when the connection is closed for any reason.

    This is invoked when close() is called as well.

    onerror?: (error: Error) => void

    Callback for when an error occurs.

    Note that errors are not necessarily fatal; they are used for reporting any kind of exceptional condition out of band.

    Accessors

    Methods

    • Asserts that a request handler has not already been set for the given method, in preparation for a new one being automatically installed.

      Parameters

      • method: string

      Returns void

    • Parameters

      • capability: string | number
      • method: string

      Returns void

    • A method to check if a request handler is supported by the local side, for the given method to be handled.

      This should be implemented by subclasses.

      Parameters

      • method: string

      Returns void

    • Parameters

      • params: {
            _meta?: { progressToken?: string | number; [key: string]: unknown };
            arguments?: { [key: string]: unknown };
            name: string;
            [key: string]: unknown;
        }
      • resultSchema:
            | ZodObject<
                extendShape<
                    {
                        _meta: ZodOptional<
                            ZodObject<
                                {},
                                "passthrough",
                                ZodTypeAny,
                                objectOutputType<{}, ZodTypeAny, "passthrough">,
                                objectInputType<{}, ZodTypeAny, "passthrough">,
                            >,
                        >;
                    },
                    {
                        content: ZodDefault<
                            ZodArray<
                                ZodUnion<
                                    [
                                        ZodObject<
                                            {
                                                _meta: ZodOptional<(...)>;
                                                text: ZodString;
                                                type: ZodLiteral<(...)>;
                                            },
                                            "passthrough",
                                            ZodTypeAny,
                                            objectOutputType<
                                                { _meta: ...; text: ...; type: ... },
                                                ZodTypeAny,
                                                "passthrough",
                                            >,
                                            objectInputType<
                                                { _meta: ...; text: ...; type: ... },
                                                ZodTypeAny,
                                                "passthrough",
                                            >,
                                        >,
                                        ZodObject<
                                            {
                                                _meta: ZodOptional<(...)>;
                                                data: ZodEffects<(...), (...), (...)>;
                                                mimeType: ZodString;
                                                type: ZodLiteral<(...)>;
                                            },
                                            "passthrough",
                                            ZodTypeAny,
                                            objectOutputType<
                                                { _meta: ...; data: ...; mimeType: ...; type: ... },
                                                ZodTypeAny,
                                                "passthrough",
                                            >,
                                            objectInputType<
                                                { _meta: ...; data: ...; mimeType: ...; type: ... },
                                                ZodTypeAny,
                                                "passthrough",
                                            >,
                                        >,
                                        ZodObject<
                                            {
                                                _meta: ZodOptional<(...)>;
                                                data: ZodEffects<(...), (...), (...)>;
                                                mimeType: ZodString;
                                                type: ZodLiteral<(...)>;
                                            },
                                            "passthrough",
                                            ZodTypeAny,
                                            objectOutputType<
                                                { _meta: ...; data: ...; mimeType: ...; type: ... },
                                                ZodTypeAny,
                                                "passthrough",
                                            >,
                                            objectInputType<
                                                { _meta: ...; data: ...; mimeType: ...; type: ... },
                                                ZodTypeAny,
                                                "passthrough",
                                            >,
                                        >,
                                        ZodObject<
                                            extendShape<extendShape<(...), (...)>, { type: ... }>,
                                            "passthrough",
                                            ZodTypeAny,
                                            objectOutputType<
                                                extendShape<(...), (...)>,
                                                ZodTypeAny,
                                                "passthrough",
                                            >,
                                            objectInputType<
                                                extendShape<(...), (...)>,
                                                ZodTypeAny,
                                                "passthrough",
                                            >,
                                        >,
                                        ZodObject<
                                            {
                                                _meta: ZodOptional<(...)>;
                                                resource: ZodUnion<(...)>;
                                                type: ZodLiteral<(...)>;
                                            },
                                            "passthrough",
                                            ZodTypeAny,
                                            objectOutputType<
                                                { _meta: ...; resource: ...; type: ... },
                                                ZodTypeAny,
                                                "passthrough",
                                            >,
                                            objectInputType<
                                                { _meta: ...; resource: ...; type: ... },
                                                ZodTypeAny,
                                                "passthrough",
                                            >,
                                        >,
                                    ],
                                >,
                                "many",
                            >,
                        >;
                        isError: ZodOptional<ZodBoolean>;
                        structuredContent: ZodOptional<
                            ZodObject<
                                {},
                                "passthrough",
                                ZodTypeAny,
                                objectOutputType<{}, ZodTypeAny, "passthrough">,
                                objectInputType<{}, ZodTypeAny, "passthrough">,
                            >,
                        >;
                    },
                >,
                "passthrough",
                ZodTypeAny,
                objectOutputType<
                    extendShape<
                        {
                            _meta: ZodOptional<
                                ZodObject<
                                    {},
                                    "passthrough",
                                    ZodTypeAny,
                                    objectOutputType<{}, ZodTypeAny, "passthrough">,
                                    objectInputType<{}, ZodTypeAny, "passthrough">,
                                >,
                            >;
                        },
                        {
                            content: ZodDefault<
                                ZodArray<
                                    ZodUnion<
                                        [
                                            ZodObject<
                                                { _meta: ...; text: ...; type: ... },
                                                "passthrough",
                                                ZodTypeAny,
                                                objectOutputType<(...), (...), (...)>,
                                                objectInputType<(...), (...), (...)>,
                                            >,
                                            ZodObject<
                                                { _meta: ...; data: ...; mimeType: ...; type: ... },
                                                "passthrough",
                                                ZodTypeAny,
                                                objectOutputType<(...), (...), (...)>,
                                                objectInputType<(...), (...), (...)>,
                                            >,
                                            ZodObject<
                                                { _meta: ...; data: ...; mimeType: ...; type: ... },
                                                "passthrough",
                                                ZodTypeAny,
                                                objectOutputType<(...), (...), (...)>,
                                                objectInputType<(...), (...), (...)>,
                                            >,
                                            ZodObject<
                                                extendShape<(...), (...)>,
                                                "passthrough",
                                                ZodTypeAny,
                                                objectOutputType<(...), (...), (...)>,
                                                objectInputType<(...), (...), (...)>,
                                            >,
                                            ZodObject<
                                                { _meta: ...; resource: ...; type: ... },
                                                "passthrough",
                                                ZodTypeAny,
                                                objectOutputType<(...), (...), (...)>,
                                                objectInputType<(...), (...), (...)>,
                                            >,
                                        ],
                                    >,
                                    "many",
                                >,
                            >;
                            isError: ZodOptional<ZodBoolean>;
                            structuredContent: ZodOptional<
                                ZodObject<
                                    {},
                                    "passthrough",
                                    ZodTypeAny,
                                    objectOutputType<{}, ZodTypeAny, "passthrough">,
                                    objectInputType<{}, ZodTypeAny, "passthrough">,
                                >,
                            >;
                        },
                    >,
                    ZodTypeAny,
                    "passthrough",
                >,
                objectInputType<
                    extendShape<
                        {
                            _meta: ZodOptional<
                                ZodObject<
                                    {},
                                    "passthrough",
                                    ZodTypeAny,
                                    objectOutputType<{}, ZodTypeAny, "passthrough">,
                                    objectInputType<{}, ZodTypeAny, "passthrough">,
                                >,
                            >;
                        },
                        {
                            content: ZodDefault<
                                ZodArray<
                                    ZodUnion<
                                        [
                                            ZodObject<
                                                { _meta: ...; text: ...; type: ... },
                                                "passthrough",
                                                ZodTypeAny,
                                                objectOutputType<(...), (...), (...)>,
                                                objectInputType<(...), (...), (...)>,
                                            >,
                                            ZodObject<
                                                { _meta: ...; data: ...; mimeType: ...; type: ... },
                                                "passthrough",
                                                ZodTypeAny,
                                                objectOutputType<(...), (...), (...)>,
                                                objectInputType<(...), (...), (...)>,
                                            >,
                                            ZodObject<
                                                { _meta: ...; data: ...; mimeType: ...; type: ... },
                                                "passthrough",
                                                ZodTypeAny,
                                                objectOutputType<(...), (...), (...)>,
                                                objectInputType<(...), (...), (...)>,
                                            >,
                                            ZodObject<
                                                extendShape<(...), (...)>,
                                                "passthrough",
                                                ZodTypeAny,
                                                objectOutputType<(...), (...), (...)>,
                                                objectInputType<(...), (...), (...)>,
                                            >,
                                            ZodObject<
                                                { _meta: ...; resource: ...; type: ... },
                                                "passthrough",
                                                ZodTypeAny,
                                                objectOutputType<(...), (...), (...)>,
                                                objectInputType<(...), (...), (...)>,
                                            >,
                                        ],
                                    >,
                                    "many",
                                >,
                            >;
                            isError: ZodOptional<ZodBoolean>;
                            structuredContent: ZodOptional<
                                ZodObject<
                                    {},
                                    "passthrough",
                                    ZodTypeAny,
                                    objectOutputType<{}, ZodTypeAny, "passthrough">,
                                    objectInputType<{}, ZodTypeAny, "passthrough">,
                                >,
                            >;
                        },
                    >,
                    ZodTypeAny,
                    "passthrough",
                >,
            >
            | ZodUnion<
                [
                    ZodObject<
                        extendShape<
                            {
                                _meta: ZodOptional<
                                    ZodObject<
                                        {},
                                        "passthrough",
                                        ZodTypeAny,
                                        objectOutputType<{}, ZodTypeAny, "passthrough">,
                                        objectInputType<{}, ZodTypeAny, "passthrough">,
                                    >,
                                >;
                            },
                            {
                                content: ZodDefault<
                                    ZodArray<
                                        ZodUnion<
                                            [
                                                ZodObject<(...), (...), (...), (...), (...)>,
                                                ZodObject<(...), (...), (...), (...), (...)>,
                                                ZodObject<(...), (...), (...), (...), (...)>,
                                                ZodObject<(...), (...), (...), (...), (...)>,
                                                ZodObject<(...), (...), (...), (...), (...)>,
                                            ],
                                        >,
                                        "many",
                                    >,
                                >;
                                isError: ZodOptional<ZodBoolean>;
                                structuredContent: ZodOptional<
                                    ZodObject<
                                        {},
                                        "passthrough",
                                        ZodTypeAny,
                                        objectOutputType<{}, ZodTypeAny, "passthrough">,
                                        objectInputType<{}, ZodTypeAny, "passthrough">,
                                    >,
                                >;
                            },
                        >,
                        "passthrough",
                        ZodTypeAny,
                        objectOutputType<
                            extendShape<
                                {
                                    _meta: ZodOptional<
                                        ZodObject<
                                            {},
                                            "passthrough",
                                            ZodTypeAny,
                                            objectOutputType<{}, ZodTypeAny, "passthrough">,
                                            objectInputType<{}, ZodTypeAny, "passthrough">,
                                        >,
                                    >;
                                },
                                {
                                    content: ZodDefault<
                                        ZodArray<ZodUnion<[(...), (...), (...), (...), (...)]>, "many">,
                                    >;
                                    isError: ZodOptional<ZodBoolean>;
                                    structuredContent: ZodOptional<
                                        ZodObject<
                                            {},
                                            "passthrough",
                                            ZodTypeAny,
                                            objectOutputType<{}, ZodTypeAny, "passthrough">,
                                            objectInputType<{}, ZodTypeAny, "passthrough">,
                                        >,
                                    >;
                                },
                            >,
                            ZodTypeAny,
                            "passthrough",
                        >,
                        objectInputType<
                            extendShape<
                                {
                                    _meta: ZodOptional<
                                        ZodObject<
                                            {},
                                            "passthrough",
                                            ZodTypeAny,
                                            objectOutputType<{}, ZodTypeAny, "passthrough">,
                                            objectInputType<{}, ZodTypeAny, "passthrough">,
                                        >,
                                    >;
                                },
                                {
                                    content: ZodDefault<
                                        ZodArray<ZodUnion<[(...), (...), (...), (...), (...)]>, "many">,
                                    >;
                                    isError: ZodOptional<ZodBoolean>;
                                    structuredContent: ZodOptional<
                                        ZodObject<
                                            {},
                                            "passthrough",
                                            ZodTypeAny,
                                            objectOutputType<{}, ZodTypeAny, "passthrough">,
                                            objectInputType<{}, ZodTypeAny, "passthrough">,
                                        >,
                                    >;
                                },
                            >,
                            ZodTypeAny,
                            "passthrough",
                        >,
                    >,
                    ZodObject<
                        extendShape<
                            {
                                _meta: ZodOptional<
                                    ZodObject<
                                        {},
                                        "passthrough",
                                        ZodTypeAny,
                                        objectOutputType<{}, ZodTypeAny, "passthrough">,
                                        objectInputType<{}, ZodTypeAny, "passthrough">,
                                    >,
                                >;
                            },
                            { toolResult: ZodUnknown },
                        >,
                        "passthrough",
                        ZodTypeAny,
                        objectOutputType<
                            extendShape<
                                {
                                    _meta: ZodOptional<
                                        ZodObject<
                                            {},
                                            "passthrough",
                                            ZodTypeAny,
                                            objectOutputType<{}, ZodTypeAny, "passthrough">,
                                            objectInputType<{}, ZodTypeAny, "passthrough">,
                                        >,
                                    >;
                                },
                                { toolResult: ZodUnknown },
                            >,
                            ZodTypeAny,
                            "passthrough",
                        >,
                        objectInputType<
                            extendShape<
                                {
                                    _meta: ZodOptional<
                                        ZodObject<
                                            {},
                                            "passthrough",
                                            ZodTypeAny,
                                            objectOutputType<{}, ZodTypeAny, "passthrough">,
                                            objectInputType<{}, ZodTypeAny, "passthrough">,
                                        >,
                                    >;
                                },
                                { toolResult: ZodUnknown },
                            >,
                            ZodTypeAny,
                            "passthrough",
                        >,
                    >,
                ],
            > = CallToolResultSchema
      • Optionaloptions: RequestOptions

      Returns Promise<
          | objectOutputType<
              extendShape<
                  {
                      _meta: ZodOptional<
                          ZodObject<
                              {},
                              "passthrough",
                              ZodTypeAny,
                              objectOutputType<{}, ZodTypeAny, "passthrough">,
                              objectInputType<{}, ZodTypeAny, "passthrough">,
                          >,
                      >;
                  },
                  {
                      content: ZodDefault<
                          ZodArray<
                              ZodUnion<
                                  [
                                      ZodObject<
                                          { _meta: ...; text: ...; type: ... },
                                          "passthrough",
                                          ZodTypeAny,
                                          objectOutputType<(...), (...), (...)>,
                                          objectInputType<(...), (...), (...)>,
                                      >,
                                      ZodObject<
                                          { _meta: ...; data: ...; mimeType: ...; type: ... },
                                          "passthrough",
                                          ZodTypeAny,
                                          objectOutputType<(...), (...), (...)>,
                                          objectInputType<(...), (...), (...)>,
                                      >,
                                      ZodObject<
                                          { _meta: ...; data: ...; mimeType: ...; type: ... },
                                          "passthrough",
                                          ZodTypeAny,
                                          objectOutputType<(...), (...), (...)>,
                                          objectInputType<(...), (...), (...)>,
                                      >,
                                      ZodObject<
                                          extendShape<(...), (...)>,
                                          "passthrough",
                                          ZodTypeAny,
                                          objectOutputType<(...), (...), (...)>,
                                          objectInputType<(...), (...), (...)>,
                                      >,
                                      ZodObject<
                                          { _meta: ...; resource: ...; type: ... },
                                          "passthrough",
                                          ZodTypeAny,
                                          objectOutputType<(...), (...), (...)>,
                                          objectInputType<(...), (...), (...)>,
                                      >,
                                  ],
                              >,
                              "many",
                          >,
                      >;
                      isError: ZodOptional<ZodBoolean>;
                      structuredContent: ZodOptional<
                          ZodObject<
                              {},
                              "passthrough",
                              ZodTypeAny,
                              objectOutputType<{}, ZodTypeAny, "passthrough">,
                              objectInputType<{}, ZodTypeAny, "passthrough">,
                          >,
                      >;
                  },
              >,
              ZodTypeAny,
              "passthrough",
          >
          | objectOutputType<
              extendShape<
                  {
                      _meta: ZodOptional<
                          ZodObject<
                              {},
                              "passthrough",
                              ZodTypeAny,
                              objectOutputType<{}, ZodTypeAny, "passthrough">,
                              objectInputType<{}, ZodTypeAny, "passthrough">,
                          >,
                      >;
                  },
                  { toolResult: ZodUnknown },
              >,
              ZodTypeAny,
              "passthrough",
          >,
      >

    • Parameters

      • params: {
            _meta?: { progressToken?: string | number; [key: string]: unknown };
            argument: { name: string; value: string; [key: string]: unknown };
            context?: { arguments?: { [key: string]: string } };
            ref:
                | { type: "ref/resource"; uri: string; [key: string]: unknown }
                | { name: string; type: "ref/prompt"; [key: string]: unknown };
            [key: string]: unknown;
        }
        • [key: string]: unknown
        • Optional_meta?: { progressToken?: string | number; [key: string]: unknown }
          • OptionalprogressToken?: string | number

            If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

        • argument: { name: string; value: string; [key: string]: unknown }

          The argument's information

          • name: string

            The name of the argument

          • value: string

            The value of the argument to use for completion matching.

        • Optionalcontext?: { arguments?: { [key: string]: string } }
          • Optionalarguments?: { [key: string]: string }

            Previously-resolved variables in a URI template or prompt.

        • ref:
              | { type: "ref/resource"; uri: string; [key: string]: unknown }
              | { name: string; type: "ref/prompt"; [key: string]: unknown }
      • Optionaloptions: RequestOptions

      Returns Promise<
          objectOutputType<
              extendShape<
                  {
                      _meta: ZodOptional<
                          ZodObject<
                              {},
                              "passthrough",
                              ZodTypeAny,
                              objectOutputType<{}, ZodTypeAny, "passthrough">,
                              objectInputType<{}, ZodTypeAny, "passthrough">,
                          >,
                      >;
                  },
                  {
                      completion: ZodObject<
                          {
                              hasMore: ZodOptional<ZodBoolean>;
                              total: ZodOptional<ZodNumber>;
                              values: ZodArray<ZodString, "many">;
                          },
                          "passthrough",
                          ZodTypeAny,
                          objectOutputType<
                              {
                                  hasMore: ZodOptional<ZodBoolean>;
                                  total: ZodOptional<ZodNumber>;
                                  values: ZodArray<ZodString, "many">;
                              },
                              ZodTypeAny,
                              "passthrough",
                          >,
                          objectInputType<
                              {
                                  hasMore: ZodOptional<ZodBoolean>;
                                  total: ZodOptional<ZodNumber>;
                                  values: ZodArray<ZodString, "many">;
                              },
                              ZodTypeAny,
                              "passthrough",
                          >,
                      >;
                  },
              >,
              ZodTypeAny,
              "passthrough",
          >,
      >

    • Attaches to the given transport, starts it, and starts listening for messages.

      The Protocol object assumes ownership of the Transport, replacing any callbacks that have already been set, and expects that it is the only user of the Transport instance going forward.

      Parameters

      Returns Promise<void>

    • After initialization has completed, this may be populated with information about the server's instructions.

      Returns string | undefined

    • Parameters

      • params: {
            _meta?: { progressToken?: string | number; [key: string]: unknown };
            arguments?: { [key: string]: string };
            name: string;
            [key: string]: unknown;
        }
        • [key: string]: unknown
        • Optional_meta?: { progressToken?: string | number; [key: string]: unknown }
          • OptionalprogressToken?: string | number

            If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

        • Optionalarguments?: { [key: string]: string }

          Arguments to use for templating the prompt.

        • name: string

          The name of the prompt or prompt template.

      • Optionaloptions: RequestOptions

      Returns Promise<
          objectOutputType<
              extendShape<
                  {
                      _meta: ZodOptional<
                          ZodObject<
                              {},
                              "passthrough",
                              ZodTypeAny,
                              objectOutputType<{}, ZodTypeAny, "passthrough">,
                              objectInputType<{}, ZodTypeAny, "passthrough">,
                          >,
                      >;
                  },
                  {
                      description: ZodOptional<ZodString>;
                      messages: ZodArray<
                          ZodObject<
                              {
                                  content: ZodUnion<
                                      [
                                          ZodObject<
                                              { _meta: ...; text: ...; type: ... },
                                              "passthrough",
                                              ZodTypeAny,
                                              objectOutputType<(...), (...), (...)>,
                                              objectInputType<(...), (...), (...)>,
                                          >,
                                          ZodObject<
                                              { _meta: ...; data: ...; mimeType: ...; type: ... },
                                              "passthrough",
                                              ZodTypeAny,
                                              objectOutputType<(...), (...), (...)>,
                                              objectInputType<(...), (...), (...)>,
                                          >,
                                          ZodObject<
                                              { _meta: ...; data: ...; mimeType: ...; type: ... },
                                              "passthrough",
                                              ZodTypeAny,
                                              objectOutputType<(...), (...), (...)>,
                                              objectInputType<(...), (...), (...)>,
                                          >,
                                          ZodObject<
                                              extendShape<(...), (...)>,
                                              "passthrough",
                                              ZodTypeAny,
                                              objectOutputType<(...), (...), (...)>,
                                              objectInputType<(...), (...), (...)>,
                                          >,
                                          ZodObject<
                                              { _meta: ...; resource: ...; type: ... },
                                              "passthrough",
                                              ZodTypeAny,
                                              objectOutputType<(...), (...), (...)>,
                                              objectInputType<(...), (...), (...)>,
                                          >,
                                      ],
                                  >;
                                  role: ZodEnum<["user", "assistant"]>;
                              },
                              "passthrough",
                              ZodTypeAny,
                              objectOutputType<
                                  {
                                      content: ZodUnion<
                                          [
                                              ZodObject<(...), (...), (...), (...), (...)>,
                                              ZodObject<(...), (...), (...), (...), (...)>,
                                              ZodObject<(...), (...), (...), (...), (...)>,
                                              ZodObject<(...), (...), (...), (...), (...)>,
                                              ZodObject<(...), (...), (...), (...), (...)>,
                                          ],
                                      >;
                                      role: ZodEnum<["user", "assistant"]>;
                                  },
                                  ZodTypeAny,
                                  "passthrough",
                              >,
                              objectInputType<
                                  {
                                      content: ZodUnion<
                                          [
                                              ZodObject<(...), (...), (...), (...), (...)>,
                                              ZodObject<(...), (...), (...), (...), (...)>,
                                              ZodObject<(...), (...), (...), (...), (...)>,
                                              ZodObject<(...), (...), (...), (...), (...)>,
                                              ZodObject<(...), (...), (...), (...), (...)>,
                                          ],
                                      >;
                                      role: ZodEnum<["user", "assistant"]>;
                                  },
                                  ZodTypeAny,
                                  "passthrough",
                              >,
                          >,
                          "many",
                      >;
                  },
              >,
              ZodTypeAny,
              "passthrough",
          >,
      >

    • After initialization has completed, this will be populated with the server's reported capabilities.

      Returns
          | {
              completions?: { [key: string]: unknown };
              experimental?: { [key: string]: unknown };
              logging?: { [key: string]: unknown };
              prompts?: { listChanged?: boolean; [key: string]: unknown };
              resources?: {
                  listChanged?: boolean;
                  subscribe?: boolean;
                  [key: string]: unknown;
              };
              tools?: { listChanged?: boolean; [key: string]: unknown };
              [key: string]: unknown;
          }
          | undefined

      • {
            completions?: { [key: string]: unknown };
            experimental?: { [key: string]: unknown };
            logging?: { [key: string]: unknown };
            prompts?: { listChanged?: boolean; [key: string]: unknown };
            resources?: {
                listChanged?: boolean;
                subscribe?: boolean;
                [key: string]: unknown;
            };
            tools?: { listChanged?: boolean; [key: string]: unknown };
            [key: string]: unknown;
        }
        • [key: string]: unknown
        • Optionalcompletions?: { [key: string]: unknown }

          Present if the server supports sending completions to the client.

        • Optionalexperimental?: { [key: string]: unknown }

          Experimental, non-standard capabilities that the server supports.

        • Optionallogging?: { [key: string]: unknown }

          Present if the server supports sending log messages to the client.

        • Optionalprompts?: { listChanged?: boolean; [key: string]: unknown }

          Present if the server offers any prompt templates.

          • OptionallistChanged?: boolean

            Whether this server supports issuing notifications for changes to the prompt list.

        • Optionalresources?: { listChanged?: boolean; subscribe?: boolean; [key: string]: unknown }

          Present if the server offers any resources to read.

          • OptionallistChanged?: boolean

            Whether this server supports issuing notifications for changes to the resource list.

          • Optionalsubscribe?: boolean

            Whether this server supports clients subscribing to resource updates.

        • Optionaltools?: { listChanged?: boolean; [key: string]: unknown }

          Present if the server offers any tools to call.

          • OptionallistChanged?: boolean

            Whether this server supports issuing notifications for changes to the tool list.

      • undefined
    • After initialization has completed, this will be populated with information about the server's name and version.

      Returns
          | {
              icons?: {
                  mimeType?: string;
                  sizes?: string[];
                  src: string;
                  [key: string]: unknown;
              }[];
              name: string;
              title?: string;
              version: string;
              websiteUrl?: string;
              [key: string]: unknown;
          }
          | undefined

      • {
            icons?: {
                mimeType?: string;
                sizes?: string[];
                src: string;
                [key: string]: unknown;
            }[];
            name: string;
            title?: string;
            version: string;
            websiteUrl?: string;
            [key: string]: unknown;
        }
        • [key: string]: unknown
        • Optionalicons?: { mimeType?: string; sizes?: string[]; src: string; [key: string]: unknown }[]

          Optional set of sized icons that the client can display in a user interface.

          Clients that support rendering icons MUST support at least the following MIME types:

          • image/png - PNG images (safe, universal compatibility)
          • image/jpeg (and image/jpg) - JPEG images (safe, universal compatibility)

          Clients that support rendering icons SHOULD also support:

          • image/svg+xml - SVG images (scalable but requires security precautions)
          • image/webp - WebP images (modern, efficient format)
        • name: string

          Intended for programmatic or logical use, but used as a display name in past specs or fallback

        • Optionaltitle?: string

          Intended for UI and end-user contexts — optimized to be human-readable and easily understood, even by those unfamiliar with domain-specific terminology.

          If not provided, the name should be used for display (except for Tool, where annotations.title should be given precedence over using name, if present).

        • version: string
        • OptionalwebsiteUrl?: string

          An optional URL of the website for this implementation.

      • undefined
    • Parameters

      • Optionalparams: {
            _meta?: { progressToken?: string | number; [key: string]: unknown };
            cursor?: string;
            [key: string]: unknown;
        }
        • [key: string]: unknown
        • Optional_meta?: { progressToken?: string | number; [key: string]: unknown }
          • OptionalprogressToken?: string | number

            If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

        • Optionalcursor?: string

          An opaque token representing the current pagination position. If provided, the server should return results starting after this cursor.

      • Optionaloptions: RequestOptions

      Returns Promise<
          objectOutputType<
              extendShape<
                  extendShape<
                      {
                          _meta: ZodOptional<
                              ZodObject<
                                  {},
                                  "passthrough",
                                  ZodTypeAny,
                                  objectOutputType<{}, ZodTypeAny, "passthrough">,
                                  objectInputType<{}, ZodTypeAny, "passthrough">,
                              >,
                          >;
                      },
                      { nextCursor: ZodOptional<ZodString> },
                  >,
                  {
                      prompts: ZodArray<
                          ZodObject<
                              extendShape<
                                  extendShape<
                                      { name: ZodString; title: ZodOptional<ZodString> },
                                      {
                                          _meta: ZodOptional<ZodObject<(...), (...), (...), (...), (...)>>;
                                          arguments: ZodOptional<ZodArray<(...), (...)>>;
                                          description: ZodOptional<ZodString>;
                                      },
                                  >,
                                  {
                                      icons: ZodOptional<
                                          ZodArray<ZodObject<(...), (...), (...), (...), (...)>, "many">,
                                      >;
                                  },
                              >,
                              "passthrough",
                              ZodTypeAny,
                              objectOutputType<
                                  extendShape<
                                      extendShape<
                                          { name: ZodString; title: ZodOptional<(...)> },
                                          {
                                              _meta: ZodOptional<(...)>;
                                              arguments: ZodOptional<(...)>;
                                              description: ZodOptional<(...)>;
                                          },
                                      >,
                                      { icons: ZodOptional<ZodArray<(...), (...)>> },
                                  >,
                                  ZodTypeAny,
                                  "passthrough",
                              >,
                              objectInputType<
                                  extendShape<
                                      extendShape<
                                          { name: ZodString; title: ZodOptional<(...)> },
                                          {
                                              _meta: ZodOptional<(...)>;
                                              arguments: ZodOptional<(...)>;
                                              description: ZodOptional<(...)>;
                                          },
                                      >,
                                      { icons: ZodOptional<ZodArray<(...), (...)>> },
                                  >,
                                  ZodTypeAny,
                                  "passthrough",
                              >,
                          >,
                          "many",
                      >;
                  },
              >,
              ZodTypeAny,
              "passthrough",
          >,
      >

    • Parameters

      • Optionalparams: {
            _meta?: { progressToken?: string | number; [key: string]: unknown };
            cursor?: string;
            [key: string]: unknown;
        }
        • [key: string]: unknown
        • Optional_meta?: { progressToken?: string | number; [key: string]: unknown }
          • OptionalprogressToken?: string | number

            If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

        • Optionalcursor?: string

          An opaque token representing the current pagination position. If provided, the server should return results starting after this cursor.

      • Optionaloptions: RequestOptions

      Returns Promise<
          objectOutputType<
              extendShape<
                  extendShape<
                      {
                          _meta: ZodOptional<
                              ZodObject<
                                  {},
                                  "passthrough",
                                  ZodTypeAny,
                                  objectOutputType<{}, ZodTypeAny, "passthrough">,
                                  objectInputType<{}, ZodTypeAny, "passthrough">,
                              >,
                          >;
                      },
                      { nextCursor: ZodOptional<ZodString> },
                  >,
                  {
                      resources: ZodArray<
                          ZodObject<
                              extendShape<
                                  extendShape<
                                      { name: ZodString; title: ZodOptional<ZodString> },
                                      {
                                          _meta: ZodOptional<ZodObject<(...), (...), (...), (...), (...)>>;
                                          description: ZodOptional<ZodString>;
                                          mimeType: ZodOptional<ZodString>;
                                          uri: ZodString;
                                      },
                                  >,
                                  {
                                      icons: ZodOptional<
                                          ZodArray<ZodObject<(...), (...), (...), (...), (...)>, "many">,
                                      >;
                                  },
                              >,
                              "passthrough",
                              ZodTypeAny,
                              objectOutputType<
                                  extendShape<
                                      extendShape<
                                          { name: ZodString; title: ZodOptional<(...)> },
                                          {
                                              _meta: ZodOptional<(...)>;
                                              description: ZodOptional<(...)>;
                                              mimeType: ZodOptional<(...)>;
                                              uri: ZodString;
                                          },
                                      >,
                                      { icons: ZodOptional<ZodArray<(...), (...)>> },
                                  >,
                                  ZodTypeAny,
                                  "passthrough",
                              >,
                              objectInputType<
                                  extendShape<
                                      extendShape<
                                          { name: ZodString; title: ZodOptional<(...)> },
                                          {
                                              _meta: ZodOptional<(...)>;
                                              description: ZodOptional<(...)>;
                                              mimeType: ZodOptional<(...)>;
                                              uri: ZodString;
                                          },
                                      >,
                                      { icons: ZodOptional<ZodArray<(...), (...)>> },
                                  >,
                                  ZodTypeAny,
                                  "passthrough",
                              >,
                          >,
                          "many",
                      >;
                  },
              >,
              ZodTypeAny,
              "passthrough",
          >,
      >

    • Parameters

      • Optionalparams: {
            _meta?: { progressToken?: string | number; [key: string]: unknown };
            cursor?: string;
            [key: string]: unknown;
        }
        • [key: string]: unknown
        • Optional_meta?: { progressToken?: string | number; [key: string]: unknown }
          • OptionalprogressToken?: string | number

            If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

        • Optionalcursor?: string

          An opaque token representing the current pagination position. If provided, the server should return results starting after this cursor.

      • Optionaloptions: RequestOptions

      Returns Promise<
          objectOutputType<
              extendShape<
                  extendShape<
                      {
                          _meta: ZodOptional<
                              ZodObject<
                                  {},
                                  "passthrough",
                                  ZodTypeAny,
                                  objectOutputType<{}, ZodTypeAny, "passthrough">,
                                  objectInputType<{}, ZodTypeAny, "passthrough">,
                              >,
                          >;
                      },
                      { nextCursor: ZodOptional<ZodString> },
                  >,
                  {
                      resourceTemplates: ZodArray<
                          ZodObject<
                              extendShape<
                                  extendShape<
                                      { name: ZodString; title: ZodOptional<ZodString> },
                                      {
                                          _meta: ZodOptional<ZodObject<(...), (...), (...), (...), (...)>>;
                                          description: ZodOptional<ZodString>;
                                          mimeType: ZodOptional<ZodString>;
                                          uriTemplate: ZodString;
                                      },
                                  >,
                                  {
                                      icons: ZodOptional<
                                          ZodArray<ZodObject<(...), (...), (...), (...), (...)>, "many">,
                                      >;
                                  },
                              >,
                              "passthrough",
                              ZodTypeAny,
                              objectOutputType<
                                  extendShape<
                                      extendShape<
                                          { name: ZodString; title: ZodOptional<(...)> },
                                          {
                                              _meta: ZodOptional<(...)>;
                                              description: ZodOptional<(...)>;
                                              mimeType: ZodOptional<(...)>;
                                              uriTemplate: ZodString;
                                          },
                                      >,
                                      { icons: ZodOptional<ZodArray<(...), (...)>> },
                                  >,
                                  ZodTypeAny,
                                  "passthrough",
                              >,
                              objectInputType<
                                  extendShape<
                                      extendShape<
                                          { name: ZodString; title: ZodOptional<(...)> },
                                          {
                                              _meta: ZodOptional<(...)>;
                                              description: ZodOptional<(...)>;
                                              mimeType: ZodOptional<(...)>;
                                              uriTemplate: ZodString;
                                          },
                                      >,
                                      { icons: ZodOptional<ZodArray<(...), (...)>> },
                                  >,
                                  ZodTypeAny,
                                  "passthrough",
                              >,
                          >,
                          "many",
                      >;
                  },
              >,
              ZodTypeAny,
              "passthrough",
          >,
      >

    • Parameters

      • Optionalparams: {
            _meta?: { progressToken?: string | number; [key: string]: unknown };
            cursor?: string;
            [key: string]: unknown;
        }
        • [key: string]: unknown
        • Optional_meta?: { progressToken?: string | number; [key: string]: unknown }
          • OptionalprogressToken?: string | number

            If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

        • Optionalcursor?: string

          An opaque token representing the current pagination position. If provided, the server should return results starting after this cursor.

      • Optionaloptions: RequestOptions

      Returns Promise<
          objectOutputType<
              extendShape<
                  extendShape<
                      {
                          _meta: ZodOptional<
                              ZodObject<
                                  {},
                                  "passthrough",
                                  ZodTypeAny,
                                  objectOutputType<{}, ZodTypeAny, "passthrough">,
                                  objectInputType<{}, ZodTypeAny, "passthrough">,
                              >,
                          >;
                      },
                      { nextCursor: ZodOptional<ZodString> },
                  >,
                  {
                      tools: ZodArray<
                          ZodObject<
                              extendShape<
                                  extendShape<
                                      { name: ZodString; title: ZodOptional<ZodString> },
                                      {
                                          _meta: ZodOptional<ZodObject<(...), (...), (...), (...), (...)>>;
                                          annotations: ZodOptional<
                                              ZodObject<(...), (...), (...), (...), (...)>,
                                          >;
                                          description: ZodOptional<ZodString>;
                                          inputSchema: ZodObject<
                                              { properties: ...; required: ...; type: ... },
                                              "passthrough",
                                              ZodTypeAny,
                                              objectOutputType<(...), (...), (...)>,
                                              objectInputType<(...), (...), (...)>,
                                          >;
                                          outputSchema: ZodOptional<
                                              ZodObject<(...), (...), (...), (...), (...)>,
                                          >;
                                      },
                                  >,
                                  {
                                      icons: ZodOptional<
                                          ZodArray<ZodObject<(...), (...), (...), (...), (...)>, "many">,
                                      >;
                                  },
                              >,
                              "passthrough",
                              ZodTypeAny,
                              objectOutputType<
                                  extendShape<
                                      extendShape<
                                          { name: ZodString; title: ZodOptional<(...)> },
                                          {
                                              _meta: ZodOptional<(...)>;
                                              annotations: ZodOptional<(...)>;
                                              description: ZodOptional<(...)>;
                                              inputSchema: ZodObject<(...), (...), (...), (...), (...)>;
                                              outputSchema: ZodOptional<(...)>;
                                          },
                                      >,
                                      { icons: ZodOptional<ZodArray<(...), (...)>> },
                                  >,
                                  ZodTypeAny,
                                  "passthrough",
                              >,
                              objectInputType<
                                  extendShape<
                                      extendShape<
                                          { name: ZodString; title: ZodOptional<(...)> },
                                          {
                                              _meta: ZodOptional<(...)>;
                                              annotations: ZodOptional<(...)>;
                                              description: ZodOptional<(...)>;
                                              inputSchema: ZodObject<(...), (...), (...), (...), (...)>;
                                              outputSchema: ZodOptional<(...)>;
                                          },
                                      >,
                                      { icons: ZodOptional<ZodArray<(...), (...)>> },
                                  >,
                                  ZodTypeAny,
                                  "passthrough",
                              >,
                          >,
                          "many",
                      >;
                  },
              >,
              ZodTypeAny,
              "passthrough",
          >,
      >

    • Parameters

      Returns Promise<{ _meta?: objectOutputType<{}, ZodTypeAny, "passthrough"> }>

    • Parameters

      • params: {
            _meta?: { progressToken?: string | number; [key: string]: unknown };
            uri: string;
            [key: string]: unknown;
        }
        • [key: string]: unknown
        • Optional_meta?: { progressToken?: string | number; [key: string]: unknown }
          • OptionalprogressToken?: string | number

            If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

        • uri: string

          The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.

      • Optionaloptions: RequestOptions

      Returns Promise<
          objectOutputType<
              extendShape<
                  {
                      _meta: ZodOptional<
                          ZodObject<
                              {},
                              "passthrough",
                              ZodTypeAny,
                              objectOutputType<{}, ZodTypeAny, "passthrough">,
                              objectInputType<{}, ZodTypeAny, "passthrough">,
                          >,
                      >;
                  },
                  {
                      contents: ZodArray<
                          ZodUnion<
                              [
                                  ZodObject<
                                      extendShape<
                                          {
                                              _meta: ZodOptional<(...)>;
                                              mimeType: ZodOptional<(...)>;
                                              uri: ZodString;
                                          },
                                          { text: ZodString },
                                      >,
                                      "passthrough",
                                      ZodTypeAny,
                                      objectOutputType<
                                          extendShape<
                                              { _meta: ...; mimeType: ...; uri: ... },
                                              { text: ... },
                                          >,
                                          ZodTypeAny,
                                          "passthrough",
                                      >,
                                      objectInputType<
                                          extendShape<
                                              { _meta: ...; mimeType: ...; uri: ... },
                                              { text: ... },
                                          >,
                                          ZodTypeAny,
                                          "passthrough",
                                      >,
                                  >,
                                  ZodObject<
                                      extendShape<
                                          {
                                              _meta: ZodOptional<(...)>;
                                              mimeType: ZodOptional<(...)>;
                                              uri: ZodString;
                                          },
                                          { blob: ZodEffects<(...), (...), (...)> },
                                      >,
                                      "passthrough",
                                      ZodTypeAny,
                                      objectOutputType<
                                          extendShape<
                                              { _meta: ...; mimeType: ...; uri: ... },
                                              { blob: ... },
                                          >,
                                          ZodTypeAny,
                                          "passthrough",
                                      >,
                                      objectInputType<
                                          extendShape<
                                              { _meta: ...; mimeType: ...; uri: ... },
                                              { blob: ... },
                                          >,
                                          ZodTypeAny,
                                          "passthrough",
                                      >,
                                  >,
                              ],
                          >,
                          "many",
                      >;
                  },
              >,
              ZodTypeAny,
              "passthrough",
          >,
      >

    • Registers new capabilities. This can only be called before connecting to a transport.

      The new capabilities will be merged with any existing capabilities previously given (e.g., at initialization).

      Parameters

      • capabilities: {
            elicitation?: { [key: string]: unknown };
            experimental?: { [key: string]: unknown };
            roots?: { listChanged?: boolean; [key: string]: unknown };
            sampling?: { [key: string]: unknown };
            [key: string]: unknown;
        }
        • [key: string]: unknown
        • Optionalelicitation?: { [key: string]: unknown }

          Present if the client supports eliciting user input.

        • Optionalexperimental?: { [key: string]: unknown }

          Experimental, non-standard capabilities that the client supports.

        • Optionalroots?: { listChanged?: boolean; [key: string]: unknown }

          Present if the client supports listing roots.

          • OptionallistChanged?: boolean

            Whether the client supports issuing notifications for changes to the roots list.

        • Optionalsampling?: { [key: string]: unknown }

          Present if the client supports sampling from an LLM.

      Returns void

    • Registers a handler to invoke when this protocol object receives a notification with the given method.

      Note that this will replace any previous notification handler for the same method.

      Type Parameters

      • T extends ZodObject<
            { method: ZodLiteral<string> },
            UnknownKeysParam,
            ZodTypeAny,
            { method: string },
            { method: string },
        >

      Parameters

      • notificationSchema: T
      • handler: (notification: TypeOf<T>) => void | Promise<void>

      Returns void

    • Registers a handler to invoke when this protocol object receives a request with the given method.

      Note that this will replace any previous request handler for the same method.

      Type Parameters

      • T extends ZodObject<
            { method: ZodLiteral<string> },
            UnknownKeysParam,
            ZodTypeAny,
            { method: string },
            { method: string },
        >

      Parameters

      Returns void

    • Parameters

      • params: {
            _meta?: { progressToken?: string | number; [key: string]: unknown };
            uri: string;
            [key: string]: unknown;
        }
        • [key: string]: unknown
        • Optional_meta?: { progressToken?: string | number; [key: string]: unknown }
          • OptionalprogressToken?: string | number

            If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

        • uri: string

          The URI of the resource to subscribe to. The URI can use any protocol; it is up to the server how to interpret it.

      • Optionaloptions: RequestOptions

      Returns Promise<{ _meta?: objectOutputType<{}, ZodTypeAny, "passthrough"> }>

    • Parameters

      • params: {
            _meta?: { progressToken?: string | number; [key: string]: unknown };
            uri: string;
            [key: string]: unknown;
        }
        • [key: string]: unknown
        • Optional_meta?: { progressToken?: string | number; [key: string]: unknown }
          • OptionalprogressToken?: string | number

            If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.

        • uri: string

          The URI of the resource to unsubscribe from.

      • Optionaloptions: RequestOptions

      Returns Promise<{ _meta?: objectOutputType<{}, ZodTypeAny, "passthrough"> }>