MCP TypeScript SDK
    Preparing search index...

    Interface CreateMessageRequestParamsWithTools

    CreateMessageRequestParams with required tools - for tool-enabled overload.

    interface CreateMessageRequestParamsWithTools {
        _meta?: {
            "io.modelcontextprotocol/related-task"?: { taskId: string };
            progressToken?: string | number;
            [key: string]: unknown;
        };
        includeContext?: "none"
        | "thisServer"
        | "allServers";
        maxTokens: number;
        messages: {
            _meta?: { [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 };
                    id: string;
                    input: { [key: string]: unknown };
                    name: string;
                    type: "tool_use";
                }
                | {
                    _meta?: { [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;
                            };
                            description?: string;
                            icons?: {
                                mimeType?: (...)
                                | (...);
                                sizes?: (...) | (...);
                                src: string;
                                theme?: (...) | (...) | (...);
                            }[];
                            mimeType?: string;
                            name: string;
                            title?: string;
                            type: "resource_link";
                            uri: string;
                        }
                        | {
                            _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";
                        }
                    )[];
                    isError?: boolean;
                    structuredContent?: { [key: string]: unknown };
                    toolUseId: string;
                    type: "tool_result";
                }
                | (
                    | {
                        _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 };
                        id: string;
                        input: { [key: string]: unknown };
                        name: string;
                        type: "tool_use";
                    }
                    | {
                        _meta?: { [key: string]: unknown };
                        content: (
                            | {
                                _meta?: { [key: ...]: ... };
                                annotations?: { audience?: ...; lastModified?: ...; priority?: ... };
                                text: string;
                                type: "text";
                            }
                            | {
                                _meta?: { [key: ...]: ... };
                                annotations?: { audience?: ...; lastModified?: ...; priority?: ... };
                                data: string;
                                mimeType: string;
                                type: "image";
                            }
                            | {
                                _meta?: { [key: ...]: ... };
                                annotations?: { audience?: ...; lastModified?: ...; priority?: ... };
                                data: string;
                                mimeType: string;
                                type: "audio";
                            }
                            | {
                                _meta?: { [key: ...]: ... };
                                annotations?: { audience?: ...; lastModified?: ...; priority?: ... };
                                description?: string;
                                icons?: (...)[];
                                mimeType?: string;
                                name: string;
                                title?: string;
                                type: "resource_link";
                                uri: string;
                            }
                            | {
                                _meta?: { [key: ...]: ... };
                                annotations?: { audience?: ...; lastModified?: ...; priority?: ... };
                                resource:
                                    | { _meta?: ...; mimeType?: ...; text: ...; uri: ... }
                                    | { _meta?: ...; blob: ...; mimeType?: ...; uri: ... };
                                type: "resource";
                            }
                        )[];
                        isError?: boolean;
                        structuredContent?: { [key: string]: unknown };
                        toolUseId: string;
                        type: "tool_result";
                    }
                )[];
            role: "user"
            | "assistant";
        }[];
        metadata?: object;
        modelPreferences?: {
            costPriority?: number;
            hints?: { name?: string }[];
            intelligencePriority?: number;
            speedPriority?: number;
        };
        stopSequences?: string[];
        systemPrompt?: string;
        task?: { ttl?: number };
        temperature?: number;
        toolChoice?: { mode?: "required" | "none" | "auto" };
        tools: {
            _meta?: { [key: string]: unknown };
            annotations?: {
                destructiveHint?: boolean;
                idempotentHint?: boolean;
                openWorldHint?: boolean;
                readOnlyHint?: boolean;
                title?: string;
            };
            description?: string;
            execution?: { taskSupport?: "optional"
            | "required"
            | "forbidden" };
            icons?: {
                mimeType?: string;
                sizes?: string[];
                src: string;
                theme?: "light" | "dark";
            }[];
            inputSchema: {
                properties?: { [key: string]: object };
                required?: string[];
                type: "object";
                [key: string]: unknown;
            };
            name: string;
            outputSchema?: {
                properties?: { [key: string]: object };
                required?: string[];
                type: "object";
                [key: string]: unknown;
            };
            title?: string;
        }[];
    }

    Hierarchy (View Summary)

    Index

    Properties

    _meta?: {
        "io.modelcontextprotocol/related-task"?: { taskId: string };
        progressToken?: string | number;
        [key: string]: unknown;
    } = ...

    See General fields: _meta for notes on _meta usage.

    Type Declaration

    • [key: string]: unknown
    • 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.

    includeContext?: "none" | "thisServer" | "allServers" = ...

    A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.

    Default is "none". Values "thisServer" and "allServers" are soft-deprecated. Servers SHOULD only use these values if the client declares ClientCapabilities.sampling.context. These values may be removed in future spec releases.

    maxTokens: number = ...

    The requested maximum number of tokens to sample (to prevent runaway completions).

    The client MAY choose to sample fewer tokens than the requested maximum.

    messages: {
        _meta?: { [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 };
                id: string;
                input: { [key: string]: unknown };
                name: string;
                type: "tool_use";
            }
            | {
                _meta?: { [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;
                        };
                        description?: string;
                        icons?: {
                            mimeType?: (...)
                            | (...);
                            sizes?: (...) | (...);
                            src: string;
                            theme?: (...) | (...) | (...);
                        }[];
                        mimeType?: string;
                        name: string;
                        title?: string;
                        type: "resource_link";
                        uri: string;
                    }
                    | {
                        _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";
                    }
                )[];
                isError?: boolean;
                structuredContent?: { [key: string]: unknown };
                toolUseId: string;
                type: "tool_result";
            }
            | (
                | {
                    _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 };
                    id: string;
                    input: { [key: string]: unknown };
                    name: string;
                    type: "tool_use";
                }
                | {
                    _meta?: { [key: string]: unknown };
                    content: (
                        | {
                            _meta?: { [key: ...]: ... };
                            annotations?: { audience?: ...; lastModified?: ...; priority?: ... };
                            text: string;
                            type: "text";
                        }
                        | {
                            _meta?: { [key: ...]: ... };
                            annotations?: { audience?: ...; lastModified?: ...; priority?: ... };
                            data: string;
                            mimeType: string;
                            type: "image";
                        }
                        | {
                            _meta?: { [key: ...]: ... };
                            annotations?: { audience?: ...; lastModified?: ...; priority?: ... };
                            data: string;
                            mimeType: string;
                            type: "audio";
                        }
                        | {
                            _meta?: { [key: ...]: ... };
                            annotations?: { audience?: ...; lastModified?: ...; priority?: ... };
                            description?: string;
                            icons?: (...)[];
                            mimeType?: string;
                            name: string;
                            title?: string;
                            type: "resource_link";
                            uri: string;
                        }
                        | {
                            _meta?: { [key: ...]: ... };
                            annotations?: { audience?: ...; lastModified?: ...; priority?: ... };
                            resource:
                                | { _meta?: ...; mimeType?: ...; text: ...; uri: ... }
                                | { _meta?: ...; blob: ...; mimeType?: ...; uri: ... };
                            type: "resource";
                        }
                    )[];
                    isError?: boolean;
                    structuredContent?: { [key: string]: unknown };
                    toolUseId: string;
                    type: "tool_result";
                }
            )[];
        role: "user"
        | "assistant";
    }[] = ...

    Type Declaration

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

      See MCP specification for notes on _meta usage.

    • 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 };
              id: string;
              input: { [key: string]: unknown };
              name: string;
              type: "tool_use";
          }
          | {
              _meta?: { [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;
                      };
                      description?: string;
                      icons?: {
                          mimeType?: (...)
                          | (...);
                          sizes?: (...) | (...);
                          src: string;
                          theme?: (...) | (...) | (...);
                      }[];
                      mimeType?: string;
                      name: string;
                      title?: string;
                      type: "resource_link";
                      uri: string;
                  }
                  | {
                      _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";
                  }
              )[];
              isError?: boolean;
              structuredContent?: { [key: string]: unknown };
              toolUseId: string;
              type: "tool_result";
          }
          | (
              | {
                  _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 };
                  id: string;
                  input: { [key: string]: unknown };
                  name: string;
                  type: "tool_use";
              }
              | {
                  _meta?: { [key: string]: unknown };
                  content: (
                      | {
                          _meta?: { [key: ...]: ... };
                          annotations?: { audience?: ...; lastModified?: ...; priority?: ... };
                          text: string;
                          type: "text";
                      }
                      | {
                          _meta?: { [key: ...]: ... };
                          annotations?: { audience?: ...; lastModified?: ...; priority?: ... };
                          data: string;
                          mimeType: string;
                          type: "image";
                      }
                      | {
                          _meta?: { [key: ...]: ... };
                          annotations?: { audience?: ...; lastModified?: ...; priority?: ... };
                          data: string;
                          mimeType: string;
                          type: "audio";
                      }
                      | {
                          _meta?: { [key: ...]: ... };
                          annotations?: { audience?: ...; lastModified?: ...; priority?: ... };
                          description?: string;
                          icons?: (...)[];
                          mimeType?: string;
                          name: string;
                          title?: string;
                          type: "resource_link";
                          uri: string;
                      }
                      | {
                          _meta?: { [key: ...]: ... };
                          annotations?: { audience?: ...; lastModified?: ...; priority?: ... };
                          resource:
                              | { _meta?: ...; mimeType?: ...; text: ...; uri: ... }
                              | { _meta?: ...; blob: ...; mimeType?: ...; uri: ... };
                          type: "resource";
                      }
                  )[];
                  isError?: boolean;
                  structuredContent?: { [key: string]: unknown };
                  toolUseId: string;
                  type: "tool_result";
              }
          )[]
    • role: "user" | "assistant"
    metadata?: object = ...

    Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.

    modelPreferences?: {
        costPriority?: number;
        hints?: { name?: string }[];
        intelligencePriority?: number;
        speedPriority?: number;
    } = ...

    The server's preferences for which model to select. The client MAY modify or omit this request.

    Type Declaration

    • OptionalcostPriority?: number

      How much to prioritize cost when selecting a model.

    • Optionalhints?: { name?: string }[]

      Optional hints to use for model selection.

    • OptionalintelligencePriority?: number

      How much to prioritize intelligence and capabilities when selecting a model.

    • OptionalspeedPriority?: number

      How much to prioritize sampling speed (latency) when selecting a model.

    stopSequences?: string[] = ...
    systemPrompt?: string = ...

    An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.

    task?: { ttl?: number } = ...

    If specified, the caller is requesting task-augmented execution for this request. The request will return a CreateTaskResult immediately, and the actual result can be retrieved later via tasks/result.

    Task augmentation is subject to capability negotiation - receivers MUST declare support for task augmentation of specific request types in their capabilities.

    temperature?: number = ...
    toolChoice?: { mode?: "required" | "none" | "auto" } = ...

    Controls how the model uses tools. The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared. Default is { mode: "auto" }.

    Type Declaration

    • Optionalmode?: "required" | "none" | "auto"

      Controls when tools are used:

      • "auto": Model decides whether to use tools (default)
      • "required": Model MUST use at least one tool before completing
      • "none": Model MUST NOT use any tools
    tools: {
        _meta?: { [key: string]: unknown };
        annotations?: {
            destructiveHint?: boolean;
            idempotentHint?: boolean;
            openWorldHint?: boolean;
            readOnlyHint?: boolean;
            title?: string;
        };
        description?: string;
        execution?: { taskSupport?: "optional"
        | "required"
        | "forbidden" };
        icons?: {
            mimeType?: string;
            sizes?: string[];
            src: string;
            theme?: "light" | "dark";
        }[];
        inputSchema: {
            properties?: { [key: string]: object };
            required?: string[];
            type: "object";
            [key: string]: unknown;
        };
        name: string;
        outputSchema?: {
            properties?: { [key: string]: object };
            required?: string[];
            type: "object";
            [key: string]: unknown;
        };
        title?: string;
    }[]

    Tools that the model may use during generation. The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.

    Type Declaration

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

      See MCP specification for notes on _meta usage.

    • Optionalannotations?: {
          destructiveHint?: boolean;
          idempotentHint?: boolean;
          openWorldHint?: boolean;
          readOnlyHint?: boolean;
          title?: string;
      }

      Optional additional tool information.

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

    • Optionaldescription?: string

      A human-readable description of the tool.

    • Optionalexecution?: { taskSupport?: "optional" | "required" | "forbidden" }

      Execution-related properties for this tool.

      • OptionaltaskSupport?: "optional" | "required" | "forbidden"

        Indicates the tool's preference for task-augmented execution.

        • "required": Clients MUST invoke the tool as a task
        • "optional": Clients MAY invoke the tool as a task or normal request
        • "forbidden": Clients MUST NOT attempt to invoke the tool as a task

        If not present, defaults to "forbidden".

    • 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)
    • inputSchema: {
          properties?: { [key: string]: object };
          required?: string[];
          type: "object";
          [key: string]: unknown;
      }

      A JSON Schema 2020-12 object defining the expected parameters for the tool. Must have type: 'object' at the root level per MCP spec.

    • name: string

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

    • OptionaloutputSchema?: {
          properties?: { [key: string]: object };
          required?: string[];
          type: "object";
          [key: string]: unknown;
      }

      An optional JSON Schema 2020-12 object defining the structure of the tool's output returned in the structuredContent field of a CallToolResult. Must have type: 'object' at the root level per MCP spec.

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