Skip to main content

ToolMetadata

Metadata interface for defining MCP tools.
name
string
required
Unique identifier for the tool
description
string
required
Human-readable description
annotations
ToolAnnotations
Optional hints about tool behavior
_meta
object
Metadata for the tool. Supports nested OpenAI metadata and other vendor extensions.
_meta.openai
OpenAIMetadata
OpenAI-specific metadata for tool configuration
_meta.ui
OpenAIMetadata
UI-specific metadata for tool rendering
_meta[key]
unknown
Additional vendor-specific metadata extensions

ToolAnnotations

Hints about tool behavior and characteristics.
title
string
Human-readable title for the tool
readOnlyHint
boolean
If true, the tool does not modify its environment
destructiveHint
boolean
If true, the tool may perform destructive updates
idempotentHint
boolean
If true, repeated calls with same args have no additional effect
openWorldHint
boolean
If true, tool interacts with external entities
[key]
any
Additional custom annotations

ToolSchema

Type definition for tool input schemas.
type ToolSchema = Record<string, CompatibleZodType>
A record mapping parameter names to Zod schema types. Supports both Zod v3 and v4 schemas.

InferSchema

Utility type for inferring TypeScript types from tool schemas.
type InferSchema<T extends Record<string, unknown>> = {
  [K in keyof T]: T[K] extends z.ZodTypeAny
    ? z.infer<T[K]>
    : T[K] extends ZodTypeV4<unknown>
      ? inferV4<T[K]>
      : never;
}
Automatically infers the TypeScript type from a ToolSchema definition, supporting both Zod v3 and v4 schemas.

ToolExtraArguments

Extra arguments passed to MCP tool functions.
signal
AbortSignal
required
An abort signal used to communicate if the request was cancelled from the sender’s side
authInfo
object
Information about a validated access token, provided to request handlers
authInfo.token
string
required
The access token
authInfo.clientId
string
required
The client ID associated with this token
authInfo.scopes
string[]
required
Scopes associated with this token
authInfo.expiresAt
number
When the token expires (in seconds since epoch)
authInfo.resource
URL
The RFC 8707 resource server identifier for which this token is valid
authInfo.extra
Record<string, unknown>
Additional data associated with the token
sessionId
string
The session ID from the transport, if available
_meta
object
Metadata from the original request
_meta.progressToken
string | number
Progress token for tracking long-running operations
requestId
string | number
required
The JSON-RPC ID of the request being handled
requestInfo
object
The original HTTP request information
requestInfo.headers
Record<string, string | string[] | undefined>
required
The headers of the request
sendNotification
(notification: any) => Promise<void>
required
Sends a notification that relates to the current request being handled
sendRequest
function
required
Sends a request that relates to the current request being handledSignature:
<U extends z.ZodType<object>>(
  request: any,
  resultSchema: U,
  options?: {
    onprogress?: (progress: any) => void;
    signal?: AbortSignal;
    timeout?: number;
    resetTimeoutOnProgress?: boolean;
    maxTotalTimeout?: number;
    [key: string]: unknown;
  }
) => Promise<z.infer<U>>
options.onprogress
(progress: any) => void
Progress notification callback
options.signal
AbortSignal
Abort signal for cancelling the request
options.timeout
number
Request timeout in milliseconds
options.resetTimeoutOnProgress
boolean
Whether receiving progress notifications resets the timeout
options.maxTotalTimeout
number
Maximum total time to wait for a response
options[key]
unknown
Additional transport-specific options

Build docs developers (and LLMs) love