MCP TypeScript SDK (V2)
    Preparing search index...

    Base context provided to all request handlers.

    type BaseContext = {
        http?: { authInfo?: AuthInfo };
        mcpReq: {
            _meta?: RequestMeta;
            id: RequestId;
            method: string;
            notify: (notification: Notification) => Promise<void>;
            send: <U extends AnySchema>(
                request: Request,
                resultSchema: U,
                options?: TaskRequestOptions,
            ) => Promise<SchemaOutput<U>>;
            signal: AbortSignal;
        };
        sessionId?: string;
        task?: TaskContext;
    }
    Index

    Properties

    http?: { authInfo?: AuthInfo }

    HTTP transport information, only available when using an HTTP-based transport.

    Type Declaration

    • OptionalauthInfo?: AuthInfo

      Information about a validated access token, provided to request handlers.

    mcpReq: {
        _meta?: RequestMeta;
        id: RequestId;
        method: string;
        notify: (notification: Notification) => Promise<void>;
        send: <U extends AnySchema>(
            request: Request,
            resultSchema: U,
            options?: TaskRequestOptions,
        ) => Promise<SchemaOutput<U>>;
        signal: AbortSignal;
    }

    Information about the MCP request being handled.

    Type Declaration

    • Optional_meta?: RequestMeta

      Metadata from the original request.

    • id: RequestId

      The JSON-RPC ID of the request being handled.

    • method: string

      The method name of the request (e.g., 'tools/call', 'ping').

    • notify: (notification: Notification) => Promise<void>

      Sends a notification that relates to the current request being handled.

      This is used by certain transports to correctly associate related messages.

    • send: <U extends AnySchema>(
          request: Request,
          resultSchema: U,
          options?: TaskRequestOptions,
      ) => Promise<SchemaOutput<U>>

      Sends a request that relates to the current request being handled.

      This is used by certain transports to correctly associate related messages.

    • signal: AbortSignal

      An abort signal used to communicate if the request was cancelled from the sender's side.

    sessionId?: string

    The session ID from the transport, if available.

    Task context, available when task storage is configured.