MCP TypeScript SDK
    Preparing search index...

    High-level MCP server that provides a simpler API for working with resources, tools, and prompts. For advanced usage (like sending notifications or setting custom request handlers), use the underlying Server instance available via the server property.

    Index

    Constructors

    • Parameters

      • serverInfo: {
            description?: string;
            icons?: {
                mimeType?: string;
                sizes?: string[];
                src: string;
                theme?: "light" | "dark";
            }[];
            name: string;
            title?: string;
            version: string;
            websiteUrl?: string;
        }
        • Optionaldescription?: string

          An optional human-readable description of what this implementation does.

          This can be used by clients or servers to provide context about their purpose and capabilities. For example, a server might describe the types of resources or tools it provides, while a client might describe its intended use case.

        • Optionalicons?: { mimeType?: string; sizes?: string[]; src: string; theme?: "light" | "dark" }[]

          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: ServerOptions

      Returns McpServer

    Properties

    server: Server

    The underlying Server instance, useful for advanced operations like sending notifications.

    Accessors

    Methods

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

      The server 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>

    • Registers a zero-argument prompt name, which will run the given function when the client calls it.

      Parameters

      • name: string
      • cb: (
            extra: RequestHandlerExtra<ServerRequest, ServerNotification>,
        ) =>
            | {
                _meta?: {
                    "io.modelcontextprotocol/related-task"?: { taskId: string };
                    progressToken?: string | number;
                    [key: string]: unknown;
                };
                description?: string;
                messages: {
                    content: | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: (...)[];
                            lastModified?: string;
                            priority?: number;
                        };
                        text: string;
                        type: "text";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: (...)[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "image";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: (...)[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "audio";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: (...)[];
                            lastModified?: string;
                            priority?: number;
                        };
                        resource: | {
                            _meta?: { [key: ...]: ... };
                            mimeType?: string;
                            text: string;
                            uri: string;
                        }
                        | {
                            _meta?: { [key: ...]: ... };
                            blob: string;
                            mimeType?: string;
                            uri: string;
                        };
                        type: "resource";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: (...)[];
                            lastModified?: string;
                            priority?: number;
                        };
                        description?: string;
                        icons?: {
                            mimeType?: (...)
                            | (...);
                            sizes?: (...) | (...);
                            src: string;
                            theme?: (...) | (...) | (...);
                        }[];
                        mimeType?: string;
                        name: string;
                        title?: string;
                        type: "resource_link";
                        uri: string;
                    };
                    role: "user"
                    | "assistant";
                }[];
                [key: string]: unknown;
            }
            | Promise<
                {
                    _meta?: {
                        "io.modelcontextprotocol/related-task"?: { taskId: string };
                        progressToken?: string | number;
                        [key: string]: unknown;
                    };
                    description?: string;
                    messages: {
                        content: | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...) | (...);
                                lastModified?: (...) | (...);
                                priority?: (...) | (...);
                            };
                            text: string;
                            type: "text";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...) | (...);
                                lastModified?: (...) | (...);
                                priority?: (...) | (...);
                            };
                            data: string;
                            mimeType: string;
                            type: "image";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...) | (...);
                                lastModified?: (...) | (...);
                                priority?: (...) | (...);
                            };
                            data: string;
                            mimeType: string;
                            type: "audio";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...) | (...);
                                lastModified?: (...) | (...);
                                priority?: (...) | (...);
                            };
                            resource: | {
                                _meta?: (...)
                                | (...);
                                mimeType?: (...) | (...);
                                text: string;
                                uri: string;
                            }
                            | {
                                _meta?: (...)
                                | (...);
                                blob: string;
                                mimeType?: (...) | (...);
                                uri: string;
                            };
                            type: "resource";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...) | (...);
                                lastModified?: (...) | (...);
                                priority?: (...) | (...);
                            };
                            description?: string;
                            icons?: { mimeType?: ...; sizes?: ...; src: ...; theme?: ... }[];
                            mimeType?: string;
                            name: string;
                            title?: string;
                            type: "resource_link";
                            uri: string;
                        };
                        role: "user"
                        | "assistant";
                    }[];
                    [key: string]: unknown;
                },
            >

      Returns RegisteredPrompt

      Use registerPrompt instead.

    • Registers a zero-argument prompt name (with a description) which will run the given function when the client calls it.

      Parameters

      • name: string
      • description: string
      • cb: (
            extra: RequestHandlerExtra<ServerRequest, ServerNotification>,
        ) =>
            | {
                _meta?: {
                    "io.modelcontextprotocol/related-task"?: { taskId: string };
                    progressToken?: string | number;
                    [key: string]: unknown;
                };
                description?: string;
                messages: {
                    content: | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: (...)[];
                            lastModified?: string;
                            priority?: number;
                        };
                        text: string;
                        type: "text";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: (...)[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "image";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: (...)[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "audio";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: (...)[];
                            lastModified?: string;
                            priority?: number;
                        };
                        resource: | {
                            _meta?: { [key: ...]: ... };
                            mimeType?: string;
                            text: string;
                            uri: string;
                        }
                        | {
                            _meta?: { [key: ...]: ... };
                            blob: string;
                            mimeType?: string;
                            uri: string;
                        };
                        type: "resource";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: (...)[];
                            lastModified?: string;
                            priority?: number;
                        };
                        description?: string;
                        icons?: {
                            mimeType?: (...)
                            | (...);
                            sizes?: (...) | (...);
                            src: string;
                            theme?: (...) | (...) | (...);
                        }[];
                        mimeType?: string;
                        name: string;
                        title?: string;
                        type: "resource_link";
                        uri: string;
                    };
                    role: "user"
                    | "assistant";
                }[];
                [key: string]: unknown;
            }
            | Promise<
                {
                    _meta?: {
                        "io.modelcontextprotocol/related-task"?: { taskId: string };
                        progressToken?: string | number;
                        [key: string]: unknown;
                    };
                    description?: string;
                    messages: {
                        content: | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...) | (...);
                                lastModified?: (...) | (...);
                                priority?: (...) | (...);
                            };
                            text: string;
                            type: "text";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...) | (...);
                                lastModified?: (...) | (...);
                                priority?: (...) | (...);
                            };
                            data: string;
                            mimeType: string;
                            type: "image";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...) | (...);
                                lastModified?: (...) | (...);
                                priority?: (...) | (...);
                            };
                            data: string;
                            mimeType: string;
                            type: "audio";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...) | (...);
                                lastModified?: (...) | (...);
                                priority?: (...) | (...);
                            };
                            resource: | {
                                _meta?: (...)
                                | (...);
                                mimeType?: (...) | (...);
                                text: string;
                                uri: string;
                            }
                            | {
                                _meta?: (...)
                                | (...);
                                blob: string;
                                mimeType?: (...) | (...);
                                uri: string;
                            };
                            type: "resource";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...) | (...);
                                lastModified?: (...) | (...);
                                priority?: (...) | (...);
                            };
                            description?: string;
                            icons?: { mimeType?: ...; sizes?: ...; src: ...; theme?: ... }[];
                            mimeType?: string;
                            name: string;
                            title?: string;
                            type: "resource_link";
                            uri: string;
                        };
                        role: "user"
                        | "assistant";
                    }[];
                    [key: string]: unknown;
                },
            >

      Returns RegisteredPrompt

      Use registerPrompt instead.

    • Registers a prompt name accepting the given arguments, which must be an object containing named properties associated with Zod schemas. When the client calls it, the function will be run with the parsed and validated arguments.

      Type Parameters

      Parameters

      Returns RegisteredPrompt

      Use registerPrompt instead.

    • Registers a prompt name (with a description) accepting the given arguments, which must be an object containing named properties associated with Zod schemas. When the client calls it, the function will be run with the parsed and validated arguments.

      Type Parameters

      Parameters

      Returns RegisteredPrompt

      Use registerPrompt instead.

    • Registers a tool with a config object and callback.

      Type Parameters

      Parameters

      • name: string
      • config: {
            _meta?: Record<string, unknown>;
            annotations?: {
                destructiveHint?: boolean;
                idempotentHint?: boolean;
                openWorldHint?: boolean;
                readOnlyHint?: boolean;
                title?: string;
            };
            description?: string;
            inputSchema?: InputArgs;
            outputSchema?: OutputArgs;
            title?: string;
        }
      • cb: BaseToolCallback<
            {
                _meta?: {
                    "io.modelcontextprotocol/related-task"?: { taskId: string };
                    progressToken?: string | number;
                    [key: string]: unknown;
                };
                content: (
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        text: string;
                        type: "text";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "image";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "audio";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        resource: | {
                            _meta?: { [key: string]: unknown };
                            mimeType?: string;
                            text: string;
                            uri: string;
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            blob: string;
                            mimeType?: string;
                            uri: string;
                        };
                        type: "resource";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        description?: string;
                        icons?: {
                            mimeType?: string;
                            sizes?: string[];
                            src: string;
                            theme?: "light"
                            | "dark";
                        }[];
                        mimeType?: string;
                        name: string;
                        title?: string;
                        type: "resource_link";
                        uri: string;
                    }
                )[];
                isError?: boolean;
                structuredContent?: { [key: string]: unknown };
                [key: string]: unknown;
            },
        >

      Returns RegisteredTool

    • Sends a logging message to the client, if connected. Note: You only need to send the parameters object, not the entire JSON RPC message

      Parameters

      • params: {
            _meta?: {
                "io.modelcontextprotocol/related-task"?: { taskId: string };
                progressToken?: string | number;
                [key: string]: unknown;
            };
            data: unknown;
            level: | "debug"
            | "error"
            | "info"
            | "notice"
            | "warning"
            | "critical"
            | "alert"
            | "emergency";
            logger?: string;
        }
        • Optional_meta?: {
              "io.modelcontextprotocol/related-task"?: { taskId: string };
              progressToken?: string | number;
              [key: string]: unknown;
          }

          See MCP specification for notes on _meta usage.

          • Optionalio.modelcontextprotocol/related-task?: { taskId: string }

            If specified, this request is related to the provided task.

          • 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.

        • data: unknown

          The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.

        • level:
              | "debug"
              | "error"
              | "info"
              | "notice"
              | "warning"
              | "critical"
              | "alert"
              | "emergency"

          The severity of this log message.

        • Optionallogger?: string

          An optional name of the logger issuing this message.

      • OptionalsessionId: string

        optional for stateless and backward compatibility

      Returns Promise<void>

      LoggingMessageNotification

    • Registers a zero-argument tool name, which will run the given function when the client calls it.

      Parameters

      • name: string
      • cb: (
            extra: RequestHandlerExtra,
        ) =>
            | {
                _meta?: {
                    "io.modelcontextprotocol/related-task"?: { taskId: string };
                    progressToken?: string | number;
                    [key: string]: unknown;
                };
                content: (
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ((...) | (...))[];
                            lastModified?: string;
                            priority?: number;
                        };
                        text: string;
                        type: "text";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ((...) | (...))[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "image";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ((...) | (...))[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "audio";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ((...) | (...))[];
                            lastModified?: string;
                            priority?: number;
                        };
                        resource: | {
                            _meta?: { [key: string]: unknown };
                            mimeType?: string;
                            text: string;
                            uri: string;
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            blob: string;
                            mimeType?: string;
                            uri: string;
                        };
                        type: "resource";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ((...) | (...))[];
                            lastModified?: string;
                            priority?: number;
                        };
                        description?: string;
                        icons?: {
                            mimeType?: string;
                            sizes?: (...)[];
                            src: string;
                            theme?: "light" | "dark";
                        }[];
                        mimeType?: string;
                        name: string;
                        title?: string;
                        type: "resource_link";
                        uri: string;
                    }
                )[];
                isError?: boolean;
                structuredContent?: { [key: string]: unknown };
                [key: string]: unknown;
            }
            | Promise<
                {
                    _meta?: {
                        "io.modelcontextprotocol/related-task"?: { taskId: string };
                        progressToken?: string | number;
                        [key: string]: unknown;
                    };
                    content: (
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...)[];
                                lastModified?: string;
                                priority?: number;
                            };
                            text: string;
                            type: "text";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...)[];
                                lastModified?: string;
                                priority?: number;
                            };
                            data: string;
                            mimeType: string;
                            type: "image";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...)[];
                                lastModified?: string;
                                priority?: number;
                            };
                            data: string;
                            mimeType: string;
                            type: "audio";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...)[];
                                lastModified?: string;
                                priority?: number;
                            };
                            resource: | {
                                _meta?: { [key: ...]: ... };
                                mimeType?: string;
                                text: string;
                                uri: string;
                            }
                            | {
                                _meta?: { [key: ...]: ... };
                                blob: string;
                                mimeType?: string;
                                uri: string;
                            };
                            type: "resource";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...)[];
                                lastModified?: string;
                                priority?: number;
                            };
                            description?: string;
                            icons?: {
                                mimeType?: (...)
                                | (...);
                                sizes?: (...) | (...);
                                src: string;
                                theme?: (...) | (...) | (...);
                            }[];
                            mimeType?: string;
                            name: string;
                            title?: string;
                            type: "resource_link";
                            uri: string;
                        }
                    )[];
                    isError?: boolean;
                    structuredContent?: { [key: string]: unknown };
                    [key: string]: unknown;
                },
            >

      Returns RegisteredTool

      Use registerTool instead.

    • Registers a zero-argument tool name (with a description) which will run the given function when the client calls it.

      Parameters

      • name: string
      • description: string
      • cb: (
            extra: RequestHandlerExtra,
        ) =>
            | {
                _meta?: {
                    "io.modelcontextprotocol/related-task"?: { taskId: string };
                    progressToken?: string | number;
                    [key: string]: unknown;
                };
                content: (
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ((...) | (...))[];
                            lastModified?: string;
                            priority?: number;
                        };
                        text: string;
                        type: "text";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ((...) | (...))[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "image";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ((...) | (...))[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "audio";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ((...) | (...))[];
                            lastModified?: string;
                            priority?: number;
                        };
                        resource: | {
                            _meta?: { [key: string]: unknown };
                            mimeType?: string;
                            text: string;
                            uri: string;
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            blob: string;
                            mimeType?: string;
                            uri: string;
                        };
                        type: "resource";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ((...) | (...))[];
                            lastModified?: string;
                            priority?: number;
                        };
                        description?: string;
                        icons?: {
                            mimeType?: string;
                            sizes?: (...)[];
                            src: string;
                            theme?: "light" | "dark";
                        }[];
                        mimeType?: string;
                        name: string;
                        title?: string;
                        type: "resource_link";
                        uri: string;
                    }
                )[];
                isError?: boolean;
                structuredContent?: { [key: string]: unknown };
                [key: string]: unknown;
            }
            | Promise<
                {
                    _meta?: {
                        "io.modelcontextprotocol/related-task"?: { taskId: string };
                        progressToken?: string | number;
                        [key: string]: unknown;
                    };
                    content: (
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...)[];
                                lastModified?: string;
                                priority?: number;
                            };
                            text: string;
                            type: "text";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...)[];
                                lastModified?: string;
                                priority?: number;
                            };
                            data: string;
                            mimeType: string;
                            type: "image";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...)[];
                                lastModified?: string;
                                priority?: number;
                            };
                            data: string;
                            mimeType: string;
                            type: "audio";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...)[];
                                lastModified?: string;
                                priority?: number;
                            };
                            resource: | {
                                _meta?: { [key: ...]: ... };
                                mimeType?: string;
                                text: string;
                                uri: string;
                            }
                            | {
                                _meta?: { [key: ...]: ... };
                                blob: string;
                                mimeType?: string;
                                uri: string;
                            };
                            type: "resource";
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            annotations?: {
                                audience?: (...)[];
                                lastModified?: string;
                                priority?: number;
                            };
                            description?: string;
                            icons?: {
                                mimeType?: (...)
                                | (...);
                                sizes?: (...) | (...);
                                src: string;
                                theme?: (...) | (...) | (...);
                            }[];
                            mimeType?: string;
                            name: string;
                            title?: string;
                            type: "resource_link";
                            uri: string;
                        }
                    )[];
                    isError?: boolean;
                    structuredContent?: { [key: string]: unknown };
                    [key: string]: unknown;
                },
            >

      Returns RegisteredTool

      Use registerTool instead.

    • Registers a tool taking either a parameter schema for validation or annotations for additional metadata. This unified overload handles both tool(name, paramsSchema, cb) and tool(name, annotations, cb) cases.

      Note: We use a union type for the second parameter because TypeScript cannot reliably disambiguate between ToolAnnotations and ZodRawShapeCompat during overload resolution, as both are plain object types.

      Type Parameters

      Parameters

      • name: string
      • paramsSchemaOrAnnotations:
            | {
                destructiveHint?: boolean;
                idempotentHint?: boolean;
                openWorldHint?: boolean;
                readOnlyHint?: boolean;
                title?: string;
            }
            | Args
        • {
              destructiveHint?: boolean;
              idempotentHint?: boolean;
              openWorldHint?: boolean;
              readOnlyHint?: boolean;
              title?: string;
          }
          • OptionaldestructiveHint?: boolean

            If true, the tool may perform destructive updates to its environment. If false, the tool performs only additive updates.

            (This property is meaningful only when readOnlyHint == false)

            Default: true

          • OptionalidempotentHint?: boolean

            If true, calling the tool repeatedly with the same arguments will have no additional effect on the its environment.

            (This property is meaningful only when readOnlyHint == false)

            Default: false

          • OptionalopenWorldHint?: boolean

            If true, this tool may interact with an "open world" of external entities. If false, the tool's domain of interaction is closed. For example, the world of a web search tool is open, whereas that of a memory tool is not.

            Default: true

          • OptionalreadOnlyHint?: boolean

            If true, the tool does not modify its environment.

            Default: false

          • Optionaltitle?: string

            A human-readable title for the tool.

        • Args
      • cb: BaseToolCallback<
            {
                _meta?: {
                    "io.modelcontextprotocol/related-task"?: { taskId: string };
                    progressToken?: string | number;
                    [key: string]: unknown;
                };
                content: (
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        text: string;
                        type: "text";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "image";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "audio";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        resource: | {
                            _meta?: { [key: string]: unknown };
                            mimeType?: string;
                            text: string;
                            uri: string;
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            blob: string;
                            mimeType?: string;
                            uri: string;
                        };
                        type: "resource";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        description?: string;
                        icons?: {
                            mimeType?: string;
                            sizes?: string[];
                            src: string;
                            theme?: "light"
                            | "dark";
                        }[];
                        mimeType?: string;
                        name: string;
                        title?: string;
                        type: "resource_link";
                        uri: string;
                    }
                )[];
                isError?: boolean;
                structuredContent?: { [key: string]: unknown };
                [key: string]: unknown;
            },
        >

      Returns RegisteredTool

      Use registerTool instead.

    • Registers a tool name (with a description) taking either parameter schema or annotations. This unified overload handles both tool(name, description, paramsSchema, cb) and tool(name, description, annotations, cb) cases.

      Note: We use a union type for the third parameter because TypeScript cannot reliably disambiguate between ToolAnnotations and ZodRawShapeCompat during overload resolution, as both are plain object types.

      Type Parameters

      Parameters

      • name: string
      • description: string
      • paramsSchemaOrAnnotations:
            | {
                destructiveHint?: boolean;
                idempotentHint?: boolean;
                openWorldHint?: boolean;
                readOnlyHint?: boolean;
                title?: string;
            }
            | Args
        • {
              destructiveHint?: boolean;
              idempotentHint?: boolean;
              openWorldHint?: boolean;
              readOnlyHint?: boolean;
              title?: string;
          }
          • OptionaldestructiveHint?: boolean

            If true, the tool may perform destructive updates to its environment. If false, the tool performs only additive updates.

            (This property is meaningful only when readOnlyHint == false)

            Default: true

          • OptionalidempotentHint?: boolean

            If true, calling the tool repeatedly with the same arguments will have no additional effect on the its environment.

            (This property is meaningful only when readOnlyHint == false)

            Default: false

          • OptionalopenWorldHint?: boolean

            If true, this tool may interact with an "open world" of external entities. If false, the tool's domain of interaction is closed. For example, the world of a web search tool is open, whereas that of a memory tool is not.

            Default: true

          • OptionalreadOnlyHint?: boolean

            If true, the tool does not modify its environment.

            Default: false

          • Optionaltitle?: string

            A human-readable title for the tool.

        • Args
      • cb: BaseToolCallback<
            {
                _meta?: {
                    "io.modelcontextprotocol/related-task"?: { taskId: string };
                    progressToken?: string | number;
                    [key: string]: unknown;
                };
                content: (
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        text: string;
                        type: "text";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "image";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "audio";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        resource: | {
                            _meta?: { [key: string]: unknown };
                            mimeType?: string;
                            text: string;
                            uri: string;
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            blob: string;
                            mimeType?: string;
                            uri: string;
                        };
                        type: "resource";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        description?: string;
                        icons?: {
                            mimeType?: string;
                            sizes?: string[];
                            src: string;
                            theme?: "light"
                            | "dark";
                        }[];
                        mimeType?: string;
                        name: string;
                        title?: string;
                        type: "resource_link";
                        uri: string;
                    }
                )[];
                isError?: boolean;
                structuredContent?: { [key: string]: unknown };
                [key: string]: unknown;
            },
        >

      Returns RegisteredTool

      Use registerTool instead.

    • Registers a tool with both parameter schema and annotations.

      Type Parameters

      Parameters

      • name: string
      • paramsSchema: Args
      • annotations: {
            destructiveHint?: boolean;
            idempotentHint?: boolean;
            openWorldHint?: boolean;
            readOnlyHint?: boolean;
            title?: string;
        }
        • OptionaldestructiveHint?: boolean

          If true, the tool may perform destructive updates to its environment. If false, the tool performs only additive updates.

          (This property is meaningful only when readOnlyHint == false)

          Default: true

        • OptionalidempotentHint?: boolean

          If true, calling the tool repeatedly with the same arguments will have no additional effect on the its environment.

          (This property is meaningful only when readOnlyHint == false)

          Default: false

        • OptionalopenWorldHint?: boolean

          If true, this tool may interact with an "open world" of external entities. If false, the tool's domain of interaction is closed. For example, the world of a web search tool is open, whereas that of a memory tool is not.

          Default: true

        • OptionalreadOnlyHint?: boolean

          If true, the tool does not modify its environment.

          Default: false

        • Optionaltitle?: string

          A human-readable title for the tool.

      • cb: BaseToolCallback<
            {
                _meta?: {
                    "io.modelcontextprotocol/related-task"?: { taskId: string };
                    progressToken?: string | number;
                    [key: string]: unknown;
                };
                content: (
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        text: string;
                        type: "text";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "image";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "audio";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        resource: | {
                            _meta?: { [key: string]: unknown };
                            mimeType?: string;
                            text: string;
                            uri: string;
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            blob: string;
                            mimeType?: string;
                            uri: string;
                        };
                        type: "resource";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        description?: string;
                        icons?: {
                            mimeType?: string;
                            sizes?: string[];
                            src: string;
                            theme?: "light"
                            | "dark";
                        }[];
                        mimeType?: string;
                        name: string;
                        title?: string;
                        type: "resource_link";
                        uri: string;
                    }
                )[];
                isError?: boolean;
                structuredContent?: { [key: string]: unknown };
                [key: string]: unknown;
            },
        >

      Returns RegisteredTool

      Use registerTool instead.

    • Registers a tool with description, parameter schema, and annotations.

      Type Parameters

      Parameters

      • name: string
      • description: string
      • paramsSchema: Args
      • annotations: {
            destructiveHint?: boolean;
            idempotentHint?: boolean;
            openWorldHint?: boolean;
            readOnlyHint?: boolean;
            title?: string;
        }
        • OptionaldestructiveHint?: boolean

          If true, the tool may perform destructive updates to its environment. If false, the tool performs only additive updates.

          (This property is meaningful only when readOnlyHint == false)

          Default: true

        • OptionalidempotentHint?: boolean

          If true, calling the tool repeatedly with the same arguments will have no additional effect on the its environment.

          (This property is meaningful only when readOnlyHint == false)

          Default: false

        • OptionalopenWorldHint?: boolean

          If true, this tool may interact with an "open world" of external entities. If false, the tool's domain of interaction is closed. For example, the world of a web search tool is open, whereas that of a memory tool is not.

          Default: true

        • OptionalreadOnlyHint?: boolean

          If true, the tool does not modify its environment.

          Default: false

        • Optionaltitle?: string

          A human-readable title for the tool.

      • cb: BaseToolCallback<
            {
                _meta?: {
                    "io.modelcontextprotocol/related-task"?: { taskId: string };
                    progressToken?: string | number;
                    [key: string]: unknown;
                };
                content: (
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        text: string;
                        type: "text";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "image";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        data: string;
                        mimeType: string;
                        type: "audio";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        resource: | {
                            _meta?: { [key: string]: unknown };
                            mimeType?: string;
                            text: string;
                            uri: string;
                        }
                        | {
                            _meta?: { [key: string]: unknown };
                            blob: string;
                            mimeType?: string;
                            uri: string;
                        };
                        type: "resource";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        annotations?: {
                            audience?: ("user" | "assistant")[];
                            lastModified?: string;
                            priority?: number;
                        };
                        description?: string;
                        icons?: {
                            mimeType?: string;
                            sizes?: string[];
                            src: string;
                            theme?: "light"
                            | "dark";
                        }[];
                        mimeType?: string;
                        name: string;
                        title?: string;
                        type: "resource_link";
                        uri: string;
                    }
                )[];
                isError?: boolean;
                structuredContent?: { [key: string]: unknown };
                [key: string]: unknown;
            },
        >

      Returns RegisteredTool

      Use registerTool instead.