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: {
                <M extends RequestMethod>(
                    request: { method: M; params?: Record<string, unknown> },
                    options?: TaskRequestOptions,
                ): Promise<ResultTypeMap[M]>;
                <T extends StandardSchemaV1<unknown, unknown>>(
                    request: {
                        method: string;
                        params?: {
                            _meta?: {
                                "io.modelcontextprotocol/related-task"?: { taskId: string };
                                progressToken?: string | number;
                                [key: string]: unknown;
                            };
                            [key: string]: unknown;
                        };
                    },
                    resultSchema: T,
                    options?: TaskRequestOptions,
                ): Promise<StandardSchemaV1.InferOutput<T>>;
            };
            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: {
            <M extends RequestMethod>(
                request: { method: M; params?: Record<string, unknown> },
                options?: TaskRequestOptions,
            ): Promise<ResultTypeMap[M]>;
            <T extends StandardSchemaV1<unknown, unknown>>(
                request: {
                    method: string;
                    params?: {
                        _meta?: {
                            "io.modelcontextprotocol/related-task"?: { taskId: string };
                            progressToken?: string | number;
                            [key: string]: unknown;
                        };
                        [key: string]: unknown;
                    };
                },
                resultSchema: T,
                options?: TaskRequestOptions,
            ): Promise<StandardSchemaV1.InferOutput<T>>;
        };
        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: {
          <M extends RequestMethod>(
              request: { method: M; params?: Record<string, unknown> },
              options?: TaskRequestOptions,
          ): Promise<ResultTypeMap[M]>;
          <T extends StandardSchemaV1<unknown, unknown>>(
              request: {
                  method: string;
                  params?: {
                      _meta?: {
                          "io.modelcontextprotocol/related-task"?: { taskId: string };
                          progressToken?: string | number;
                          [key: string]: unknown;
                      };
                      [key: string]: unknown;
                  };
              },
              resultSchema: T,
              options?: TaskRequestOptions,
          ): Promise<StandardSchemaV1.InferOutput<T>>;
      }

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

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

      For spec methods the result type is inferred from the method name. For custom (non-spec) methods, pass a result schema as the second argument.

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