UNPKG

muppet

Version:

Toolkit for building MCPs on Honojs

783 lines (758 loc) 28.8 kB
import { Transport } from '@modelcontextprotocol/sdk/shared/transport.js'; import { StandardSchemaV1 } from '@standard-schema/spec'; // ================================================================================================== // JSON Schema Draft 07 // ================================================================================================== // https://tools.ietf.org/html/draft-handrews-json-schema-validation-01 // -------------------------------------------------------------------------------------------------- /** * Primitive type * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1 */ type JSONSchema7TypeName = | "string" // | "number" | "integer" | "boolean" | "object" | "array" | "null"; /** * Primitive type * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1.1 */ type JSONSchema7Type = | string // | number | boolean | JSONSchema7Object | JSONSchema7Array | null; // Workaround for infinite type recursion interface JSONSchema7Object { [key: string]: JSONSchema7Type; } // Workaround for infinite type recursion // https://github.com/Microsoft/TypeScript/issues/3496#issuecomment-128553540 interface JSONSchema7Array extends Array<JSONSchema7Type> {} /** * Meta schema * * Recommended values: * - 'http://json-schema.org/schema#' * - 'http://json-schema.org/hyper-schema#' * - 'http://json-schema.org/draft-07/schema#' * - 'http://json-schema.org/draft-07/hyper-schema#' * * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-5 */ type JSONSchema7Version = string; /** * JSON Schema v7 * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01 */ type JSONSchema7Definition = JSONSchema7 | boolean; interface JSONSchema7 { $id?: string | undefined; $ref?: string | undefined; $schema?: JSONSchema7Version | undefined; $comment?: string | undefined; /** * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.4 * @see https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#appendix-A */ $defs?: { [key: string]: JSONSchema7Definition; } | undefined; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.1 */ type?: JSONSchema7TypeName | JSONSchema7TypeName[] | undefined; enum?: JSONSchema7Type[] | undefined; const?: JSONSchema7Type | undefined; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.2 */ multipleOf?: number | undefined; maximum?: number | undefined; exclusiveMaximum?: number | undefined; minimum?: number | undefined; exclusiveMinimum?: number | undefined; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.3 */ maxLength?: number | undefined; minLength?: number | undefined; pattern?: string | undefined; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.4 */ items?: JSONSchema7Definition | JSONSchema7Definition[] | undefined; additionalItems?: JSONSchema7Definition | undefined; maxItems?: number | undefined; minItems?: number | undefined; uniqueItems?: boolean | undefined; contains?: JSONSchema7Definition | undefined; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.5 */ maxProperties?: number | undefined; minProperties?: number | undefined; required?: string[] | undefined; properties?: { [key: string]: JSONSchema7Definition; } | undefined; patternProperties?: { [key: string]: JSONSchema7Definition; } | undefined; additionalProperties?: JSONSchema7Definition | undefined; dependencies?: { [key: string]: JSONSchema7Definition | string[]; } | undefined; propertyNames?: JSONSchema7Definition | undefined; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6 */ if?: JSONSchema7Definition | undefined; then?: JSONSchema7Definition | undefined; else?: JSONSchema7Definition | undefined; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.7 */ allOf?: JSONSchema7Definition[] | undefined; anyOf?: JSONSchema7Definition[] | undefined; oneOf?: JSONSchema7Definition[] | undefined; not?: JSONSchema7Definition | undefined; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-7 */ format?: string | undefined; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-8 */ contentMediaType?: string | undefined; contentEncoding?: string | undefined; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-9 */ definitions?: { [key: string]: JSONSchema7Definition; } | undefined; /** * @see https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-10 */ title?: string | undefined; description?: string | undefined; default?: JSONSchema7Type | undefined; readOnly?: boolean | undefined; writeOnly?: boolean | undefined; examples?: JSONSchema7Type | undefined; } type PromiseOr<T> = T | Promise<T>; type Variables = object; type BlankEnv = {}; type Env = { Variables?: Variables; }; type ErrorHandler<E extends Env = any> = (err: Error, c: Context<E>) => void | Promise<void>; type NotFoundHandler<E extends Env = any> = (c: Context<E>) => void | Promise<void>; type Next = () => Promise<void>; type BaseHandler<E extends Env, M extends ClientRequest, R extends ServerResult> = (c: Context<E, M, R>, next: Next) => PromiseOr<R>; type BaseMiddlewareHandler<E extends Env, M extends ClientRequest, R extends ServerResult> = (c: Context<E, M, R>, next: Next) => Promise<R | void>; type ToolOptions<I extends StandardSchemaV1 = StandardSchemaV1, O extends StandardSchemaV1 = StandardSchemaV1> = Omit<Tool, "inputSchema" | "outputSchema"> & { inputSchema?: I; outputSchema?: O; }; type SanitizedToolOptions = ToolOptions & { type: "tool"; disabled?: boolean; }; type ToolHandler<E extends Env, I extends StandardSchemaV1 = StandardSchemaV1, O extends StandardSchemaV1 = StandardSchemaV1> = BaseHandler<E, CallToolRequest<I>, CallToolResult<O>>; type ToolMiddlewareHandler<E extends Env, I extends StandardSchemaV1 = StandardSchemaV1, O extends StandardSchemaV1 = StandardSchemaV1> = BaseMiddlewareHandler<E, CallToolRequest<I>, CallToolResult<O>>; type CompletionFn<E extends Env, I extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, K extends keyof I = keyof I> = (value: StandardSchemaV1.InferOutput<I[K]>, context: Context<E, GetPromptRequest<I>, GetPromptResult>) => PromiseOr<StandardSchemaV1.InferOutput<I[K]>[] | (Omit<CompleteResult["completion"], "values"> & { values: StandardSchemaV1.InferOutput<I[K]>[]; })>; type PromptArgumentWithCompletion<E extends Env = Env, I extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>, K extends keyof I = keyof I> = { validation: I[K]; completion?: CompletionFn<E, I, K>; }; type PromptOptions<E extends Env = Env, I extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>> = Omit<Prompt, "arguments"> & { arguments?: { [K in keyof I]: PromptArgumentWithCompletion<E, I, K>; }; }; type SanitizedPromptOptions = PromptOptions & { type: "prompt"; disabled?: boolean; }; type PromptHandler<E extends Env, I extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>> = BaseHandler<E, GetPromptRequest<I>, GetPromptResult>; type PromptMiddlewareHandler<E extends Env, I extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>> = BaseMiddlewareHandler<E, GetPromptRequest<I>, GetPromptResult>; type ResourceTemplateOptions<E extends Env = Env, I extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>> = ResourceTemplate & { arguments?: { [K in keyof I]: PromptArgumentWithCompletion<E, I, K>; }; }; type ResourceOptions<E extends Env = Env, I extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>> = Resource | ResourceTemplateOptions<E, I>; type SanitizedSimpleResourceOptions = { type: "resource"; disabled?: boolean; } & Resource; type SanitizedResourceTemplateOptions = { type: "resource-template"; disabled?: boolean; } & ResourceTemplateOptions; type SanitizedResourceOptions = SanitizedSimpleResourceOptions | SanitizedResourceTemplateOptions; type ResourceHandler<E extends Env, I extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>> = BaseHandler<E, ReadResourceRequest<I>, ReadResourceResult>; type ResourceMiddlewareHandler<E extends Env, I extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>> = BaseMiddlewareHandler<E, ReadResourceRequest<I>, ReadResourceResult>; type H<E extends Env> = ToolHandler<E> | ToolMiddlewareHandler<E> | PromptHandler<E> | PromptMiddlewareHandler<E> | ResourceHandler<E> | ResourceMiddlewareHandler<E>; type MiddlewareOptions<E extends Env = any> = { type: "middleware"; name: string; handler: H<E>; }; type RouterRoute = (SanitizedToolOptions | SanitizedPromptOptions | SanitizedResourceOptions | MiddlewareOptions)[]; type BaseRequestParams = { _meta?: Record<string, unknown>; }; type BaseResult = { _meta?: Record<string, unknown>; }; type BasePaginatedResult = BaseResult & { nextCursor?: string; }; type BaseMetadata = { name: string; title?: string; }; type Progress = { progress: number; total?: number; message?: string; }; type ProgressCallback = (progress: Progress) => void; type RequestOptions = { onprogress?: ProgressCallback; signal?: AbortSignal; timeout?: number; maxTotalTimeout?: number; resetTimeoutOnProgress?: boolean; }; type MCPError = { code: number; message: string; data?: unknown; }; type ClientCapabilitiesSchema = { experimental?: Record<string, unknown>; sampling?: Record<string, unknown>; elicitation?: Record<string, unknown>; roots?: { listChanged?: boolean; }; }; type ImplementationSchema = BaseMetadata & { version: string; }; type InitializeRequest = { method: "initialize"; params: BaseRequestParams & { protocolVersion: string; capabilities: ClientCapabilitiesSchema; clientInfo: ImplementationSchema; }; }; type ServerCapabilities = { experimental?: Record<string, unknown>; logging?: Record<string, unknown>; completion?: Record<string, unknown>; prompts?: { listChanged?: boolean; }; resources?: { subscribe?: boolean; listChanged?: boolean; }; tools?: { listChanged?: boolean; }; }; type InitializeResult = { protocolVersion: string; capabilities: ServerCapabilities; serverInfo: ImplementationSchema; instructions?: string; }; type ResourceContents = { uri: string; mimeType?: string; _meta?: Record<string, unknown>; }; type TextResourceContents = ResourceContents & { text: string; }; type BlobResourceContents = ResourceContents & { blob: string; }; type TextContent = { type: "text"; text: string; _meta?: Record<string, unknown>; }; type ImageContent = { type: "image"; data: string; mimeType: string; _meta?: Record<string, unknown>; }; type AudioContent = { type: "audio"; data: string; mimeType: string; _meta?: Record<string, unknown>; }; type EmbeddedResource = { type: "resource"; resource: TextResourceContents | BlobResourceContents; _meta?: Record<string, unknown>; }; type ResourceLink = ResourceContents & { type: "resource_link"; }; type ContentBlock = TextContent | ImageContent | AudioContent | EmbeddedResource | ResourceLink; type ListToolsRequest = { method: "tools/list"; params: BaseRequestParams & { cursor?: string; }; }; type ToolAnnotation = { title?: string; readOnlyHint?: boolean; destructiveHint?: boolean; idempotentHint?: boolean; openWorldHint?: boolean; }; type Tool = BaseMetadata & { description?: string; inputSchema: { type: "object"; properties: Record<string, unknown>; required?: string[]; } | JSONSchema7; outputSchema?: { type: "object"; properties: Record<string, unknown>; required?: string[]; } | JSONSchema7; annotations?: ToolAnnotation; }; type ListToolsResult = BasePaginatedResult & { tools: Tool[]; }; type CallToolRequest<T extends StandardSchemaV1 = StandardSchemaV1> = { method: "tools/call"; params: BaseRequestParams & { name: string; arguments: StandardSchemaV1.InferOutput<T>; }; }; type CallToolResult<T extends StandardSchemaV1 = StandardSchemaV1> = BaseResult & { content: ContentBlock[]; structuredContent?: StandardSchemaV1.InferOutput<T> | Record<string, unknown>; isError?: boolean; }; type PromptArgument = { name: string; description?: string; required?: boolean; }; type Prompt = BaseMetadata & { description?: string; arguments?: PromptArgument[]; _meta?: Record<string, unknown>; }; type ListPromptsRequest = { method: "prompts/list"; params: BaseRequestParams & { cursor?: string; }; }; type ListPromptsResult = BasePaginatedResult & { prompts: Prompt[]; }; type GetPromptRequest<I extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>> = { method: "prompts/get"; params: BaseRequestParams & { name: string; arguments: { [K in keyof I]: StandardSchemaV1.InferOutput<I[K]>; }; }; }; type PromptMessage = { role: "user" | "assistant"; content: ContentBlock; }; type GetPromptResult = BaseResult & { description?: string; messages: PromptMessage[]; }; type ListResourcesRequest = { method: "resources/list"; params: BaseRequestParams & { cursor?: string; }; }; type Resource = BaseMetadata & { uri: string; description?: string; mimeType?: string; _meta?: Record<string, unknown>; }; type ListResourcesResult = BasePaginatedResult & { resources: Resource[]; }; type ListResourceTemplatesRequest = { method: "resources/templates/list"; params: BaseRequestParams & { cursor?: string; }; }; type ResourceTemplate = BaseMetadata & { uriTemplate: string; description?: string; mimeType?: string; _meta?: Record<string, unknown>; }; type ListResourceTemplatesResult = BasePaginatedResult & { resourceTemplates: ResourceTemplate[]; }; type ReadResourceRequest<I extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>> = { method: "resources/read"; params: BaseRequestParams & { uri: string; arguments?: { [K in keyof I]: StandardSchemaV1.InferOutput<I[K]>; }; }; }; type ReadResourceResult = BaseResult & { contents: (TextResourceContents | BlobResourceContents)[]; }; type SubscribeRequest = { method: "resources/subscribe"; params: BaseRequestParams & { uri: string; }; }; type UnsubscribeRequest = { method: "resources/unsubscribe"; params: BaseRequestParams & { uri: string; }; }; type LoggingLevel = "debug" | "info" | "notice" | "warning" | "error" | "critical" | "alert" | "emergency"; type SetLevelRequest = { method: "logging/setLevel"; params: BaseRequestParams & { level: LoggingLevel; }; }; type ModelHint = { name?: string; }; type ModelPreferences = { hints?: ModelHint[]; costPriority?: number; speedPriority?: number; intelligencePriority?: number; }; type SamplingMessage = { role: "user" | "assistant"; content: TextContent | ImageContent | AudioContent; }; type CreateMessageRequest = { method: "sampling/createMessage"; params: BaseRequestParams & { messages: SamplingMessage[]; systemPrompt?: string; includeContext?: "none" | "thisServer" | "allServers"; temperature?: number; maxTokens: number; stopSequences?: string[]; metadata?: Record<string, unknown>; modelPreferences?: ModelPreferences; }; }; type CreateMessageResult = BaseResult & { model: string; stopReason: "endTurn" | "stopSequence" | "maxTokens" | string; role: "user" | "assistant"; content: Omit<TextContent, "type"> | Omit<ImageContent, "type"> | Omit<AudioContent, "type">; }; type BooleanSchema = { type: "boolean"; title?: string; description?: string; default?: boolean; }; type StringSchema = { type: "string"; title?: string; description?: string; minLength?: number; maxLength?: number; format?: "email" | "uri" | "date" | "date-time"; }; type NumberSchema = { type: "number"; title?: string; description?: string; minimum?: number; maximum?: number; }; type EnumSchema = { type: "string"; title?: string; description?: string; enum: string[]; enumNames?: string[]; }; type PrimitiveSchemaDefinition = BooleanSchema | StringSchema | NumberSchema | EnumSchema; type ElicitRequest = { method: "elicitation/create"; params: BaseRequestParams & { message: string; requestedSchema: { type: "object"; properties: Record<string, PrimitiveSchemaDefinition>; required?: string[]; }; }; }; type ElicitRequestOptions<I extends StandardSchemaV1 = StandardSchemaV1> = Omit<ElicitRequest["params"], "requestedSchema"> & { requestedSchema: I; }; type ElicitResult<I extends StandardSchemaV1 = StandardSchemaV1> = BaseResult & { action: "accept" | "decline" | "cancel"; content?: StandardSchemaV1.InferOutput<I>; }; type ResourceTemplateReference = { type: "ref/resource"; uri: string; }; type PromptReference = { type: "ref/prompt"; name: string; }; type CompleteRequest = { method: "completion/complete"; params: BaseRequestParams & { ref: ResourceTemplateReference | PromptReference; argument: { name: string; value: string; }; context?: { arguments?: Record<string, string>; }; }; }; type CompleteResult = BaseResult & { completion: { values: string[]; total?: number; hasMore?: boolean; }; }; type ListRootsRequest = { method: "roots/list"; params?: BaseRequestParams; }; type Root = { uri: string; name?: string; _meta?: Record<string, unknown>; }; type ListRootsResult = BaseResult & { roots: Root[]; }; type PingRequest = { method: "ping"; }; type InitializedNotification = { method: "notifications/initialized"; params?: BaseRequestParams; }; type CancelledNotification = { method: "notifications/cancelled"; params: BaseRequestParams & { requestId: string | number; reason?: string; }; }; type ProgressNotification = { method: "notifications/progress"; params: BaseRequestParams & { progress: number; total?: number; message?: string; progressToken: string | number; }; }; type ResourceListChangedNotification = { method: "notifications/resources/list_changed"; params?: BaseRequestParams; }; type ResourceUpdatedNotification = { method: "notifications/resources/updated"; params: BaseRequestParams & { uri: string; }; }; type PromptListChangedNotification = { method: "notifications/prompts/list_changed"; params?: BaseRequestParams; }; type ToolListChangedNotification = { method: "notifications/tools/list_changed"; params?: BaseRequestParams; }; type LoggingMessageNotification = { method: "notifications/message"; params: BaseRequestParams & { level: LoggingLevel; logger?: string; data: unknown; }; }; type RootsListChangedNotification = { method: "notifications/roots/list_changed"; params?: BaseRequestParams; }; type ClientRequest = PingRequest | InitializeRequest | CompleteRequest | SetLevelRequest | GetPromptRequest | ListPromptsRequest | ListResourcesRequest | ListResourceTemplatesRequest | ReadResourceRequest | SubscribeRequest | UnsubscribeRequest | CallToolRequest | ListToolsRequest; type ClientNotification = CancelledNotification | ProgressNotification | InitializedNotification | RootsListChangedNotification; type ClientResult = BaseResult | CreateMessageResult | ElicitResult | ListRootsResult; type ServerRequest = PingRequest | CreateMessageRequest | ElicitRequest | ListRootsRequest; type ServerNotification = CancelledNotification | ProgressNotification | LoggingMessageNotification | ResourceUpdatedNotification | ResourceListChangedNotification | ToolListChangedNotification | PromptListChangedNotification; type ServerResult = BaseResult | InitializeResult | CompleteResult | ListToolsResult | CallToolResult | ListPromptsResult | GetPromptResult | ListResourcesResult | ListResourceTemplatesResult | ReadResourceResult; type JSONRPCRequest = { jsonrpc: "2.0"; id: string | number; }; /** * Interface for getting context variables. * * @template E - Environment type. */ type Get<E extends Env> = <Key extends keyof E["Variables"]>(key: Key) => E["Variables"][Key]; /** * Interface for setting context variables. * * @template E - Environment type. */ type Set<E extends Env> = <Key extends keyof E["Variables"]>(key: Key, value: E["Variables"][Key]) => void; declare class Context<E extends Env, M extends ClientRequest = ClientRequest, R extends ServerResult = ServerResult> { #private; message: M; finalized: boolean; error: MCPError | undefined; server: ContextServer; constructor(message: M, options: { env?: E; transport: Transport; }); get result(): R | undefined; set result(_result: R | undefined); set: Set<E>; get: Get<E>; get var(): Readonly<any>; } declare class ContextServer { #private; transport: Transport; constructor(messageId: string | number, transport: Transport); ping(): Promise<BaseResult>; createMessage(params: CreateMessageRequest["params"], options?: RequestOptions): Promise<CreateMessageResult>; elicitInput<I extends StandardSchemaV1 = StandardSchemaV1>(params: ElicitRequestOptions<I>, options?: RequestOptions): Promise<ElicitResult<I>>; listRoots(params?: ListRootsRequest["params"], options?: RequestOptions): Promise<ListRootsResult>; sendLoggingMessage(params: LoggingMessageNotification["params"]): Promise<void>; sendResourceUpdated(params: ResourceUpdatedNotification["params"]): Promise<void>; sendResourceListChanged(): Promise<void>; sendToolListChanged(): Promise<void>; sendPromptListChanged(): Promise<void>; request<T extends ClientResult = ClientResult, U extends ServerRequest = ServerRequest>(request: U, options?: RequestOptions): Promise<T>; notification(notification: ServerNotification, _options?: NotificationOptions): Promise<void>; } declare function textContent(content: string, options?: { _meta?: Record<string, unknown>; }): { type: string; text: string; _meta: Record<string, unknown> | undefined; }; declare function resourceContent(embed: TextResourceContents | BlobResourceContents, options?: { _meta?: Record<string, unknown>; }): { type: string; resource: TextResourceContents | BlobResourceContents; _meta: Record<string, unknown> | undefined; }; declare function resourceLink(uri: string, options?: { mimeType?: string; _meta?: Record<string, unknown>; }): { type: string; uri: string; mimeType: string | undefined; _meta: Record<string, unknown> | undefined; }; type ContentOptions = { url: string; } | { buffer: Buffer; } | { path: string; }; declare function imageContent(content: ContentOptions, options?: { _meta?: Record<string, unknown>; }): Promise<ImageContent>; declare function audioContent(content: ContentOptions, options?: { _meta?: Record<string, unknown>; }): Promise<AudioContent>; type MuppetOptions = { name: string; version: string; prefix: string; }; declare class Muppet<E extends Env = BlankEnv> { #private; name?: string; version?: string; routes: RouterRoute; transport?: Transport; constructor(options?: Partial<MuppetOptions>); onError: (handler: ErrorHandler<E>) => this; notFound: (handler: NotFoundHandler<E>) => this; merge(app: Muppet): this; tool<I extends StandardSchemaV1 = StandardSchemaV1, O extends StandardSchemaV1 = StandardSchemaV1>(args1: ToolOptions<I, O> | ToolHandler<E, I, O> | ToolMiddlewareHandler<E, I, O>, ...args: (ToolHandler<E, I, O> | ToolMiddlewareHandler<E, I, O>)[]): this; prompt<I extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>>(args1: PromptOptions<E, I> | PromptHandler<E, I> | PromptMiddlewareHandler<E, I>, ...args: (PromptHandler<E, I> | PromptMiddlewareHandler<E, I>)[]): this; resource<I extends Record<string, StandardSchemaV1> = Record<string, StandardSchemaV1>>(args1: ResourceOptions<E, I> | ResourceHandler<E, I> | ResourceMiddlewareHandler<E, I>, ...args: (ResourceHandler<E, I> | ResourceMiddlewareHandler<E, I>)[]): this; enable(name: string): this; disable(name: string): this; onNotification(method: ClientNotification["method"], handler: (message: ClientNotification) => void): this; dispatch(message: ClientRequest | ClientNotification, options: { context: Context<E, ClientRequest, ServerResult>; }): Promise<ServerResult | void>; request(message: JSONRPCRequest & ClientRequest, options?: { env?: E; }): Promise<(JSONRPCRequest & { error: MCPError; }) | (JSONRPCRequest & { result: ServerResult; }) | undefined>; connect(transport: Transport, options?: { env?: E; }): Promise<void>; } export { type AudioContent, type BaseMetadata, type BasePaginatedResult, type BaseRequestParams, type BaseResult, type BlankEnv, type BlobResourceContents, type BooleanSchema, type CallToolRequest, type CallToolResult, type ClientCapabilitiesSchema, type ClientNotification, type ClientRequest, type ClientResult, type CompleteRequest, type CompleteResult, type CompletionFn, type ContentBlock, type ContentOptions, Context, type CreateMessageRequest, type CreateMessageResult, type ElicitRequest, type ElicitRequestOptions, type ElicitResult, type EmbeddedResource, type EnumSchema, type Env, type ErrorHandler, type GetPromptRequest, type GetPromptResult, type H, type ImageContent, type ImplementationSchema, type InitializeRequest, type InitializeResult, type JSONRPCRequest, type ListPromptsRequest, type ListPromptsResult, type ListResourceTemplatesRequest, type ListResourceTemplatesResult, type ListResourcesRequest, type ListResourcesResult, type ListRootsRequest, type ListRootsResult, type ListToolsRequest, type ListToolsResult, type LoggingMessageNotification, type MCPError, type MiddlewareOptions, type ModelHint, type ModelPreferences, Muppet, type Next, type NotFoundHandler, type NumberSchema, type PingRequest, type PrimitiveSchemaDefinition, type Progress, type ProgressCallback, type PromiseOr, type Prompt, type PromptArgument, type PromptArgumentWithCompletion, type PromptHandler, type PromptMessage, type PromptMiddlewareHandler, type PromptOptions, type ReadResourceRequest, type ReadResourceResult, type RequestOptions, type Resource, type ResourceContents, type ResourceHandler, type ResourceLink, type ResourceMiddlewareHandler, type ResourceOptions, type ResourceTemplate, type ResourceTemplateOptions, type ResourceUpdatedNotification, type Root, type RouterRoute, type SamplingMessage, type SanitizedPromptOptions, type SanitizedResourceOptions, type SanitizedResourceTemplateOptions, type SanitizedSimpleResourceOptions, type SanitizedToolOptions, type ServerCapabilities, type ServerNotification, type ServerRequest, type ServerResult, type StringSchema, type SubscribeRequest, type TextContent, type TextResourceContents, type Tool, type ToolAnnotation, type ToolHandler, type ToolMiddlewareHandler, type ToolOptions, type UnsubscribeRequest, type Variables, audioContent, imageContent, resourceContent, resourceLink, textContent };