PageSourceSearch

https://manufact.com/_next/static/immutable/chunks/2dr8kmbwm2a2d.js

js manufact.com collected 2026-09-25 20:20:39 UTC 242,996 bytes, 14 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e._posthogReleaseId=e._posthogReleaseId||"01a0a586-0c81-0000-f937-3ebdf34f6c62";var n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="bafe9a9f-9f0e-52be-8a95-8049c9a9e0b1")}catch(e){}}();(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,178610,146980,958176,342146,518553,887224,921156,109086,330288,585549,884104,101116,699461,613952,363501,964812,85573,e=>{"use strict";let t,o,r,i,n,a,s,l,c;var u=e.i(668557),d=Object.create,p=Object.defineProperty,h=Object.getOwnPropertyDescriptor,m=Object.getOwnPropertyNames,f=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty;let S=new Set(["https://json-schema.org/draft/2020-12/schema","http://json-schema.org/draft/2020-12/schema"]),v=new Set(["https://json-schema.org/draft/2019-09/schema","http://json-schema.org/draft/2019-09/schema"]),b=new Set(["https://json-schema.org/draft-07/schema","http://json-schema.org/draft-07/schema"]),y=new Set(["https://json-schema.org/draft-06/schema","http://json-schema.org/draft-06/schema"]);var _=e.i(30558);e.s(["default",0,_],701274),e.s(["default",0,_],223272),e.i(223272),e.i(701274),e.s(["$brand",()=>_.$brand,"$input",()=>_.$input,"$output",()=>_.$output,"NEVER",()=>_.NEVER,"TimePrecision",()=>_.TimePrecision,"ZodAny",()=>_.ZodAny,"ZodArray",()=>_.ZodArray,"ZodBase64",()=>_.ZodBase64,"ZodBase64URL",()=>_.ZodBase64URL,"ZodBigInt",()=>_.ZodBigInt,"ZodBigIntFormat",()=>_.ZodBigIntFormat,"ZodBoolean",()=>_.ZodBoolean,"ZodCIDRv4",()=>_.ZodCIDRv4,"ZodCIDRv6",()=>_.ZodCIDRv6,"ZodCUID",()=>_.ZodCUID,"ZodCUID2",()=>_.ZodCUID2,"ZodCatch",()=>_.ZodCatch,"ZodCodec",()=>_.ZodCodec,"ZodCustom",()=>_.ZodCustom,"ZodCustomStringFormat",()=>_.ZodCustomStringFormat,"ZodDate",()=>_.ZodDate,"ZodDefault",()=>_.ZodDefault,"ZodDiscriminatedUnion",()=>_.ZodDiscriminatedUnion,"ZodE164",()=>_.ZodE164,"ZodEmail",()=>_.ZodEmail,"ZodEmoji",()=>_.ZodEmoji,"ZodEnum",()=>_.ZodEnum,"ZodError",()=>_.ZodError,"ZodExactOptional",()=>_.ZodExactOptional,"ZodFile",()=>_.ZodFile,"ZodFirstPartyTypeKind",()=>_.ZodFirstPartyTypeKind,"ZodFunction",()=>
1_.ZodFunction,"ZodGUID",()=>_.ZodGUID,"ZodIPv4",()=>_.ZodIPv4,"ZodIPv6",()=>_.ZodIPv6,"ZodISODate",()=>_.ZodISODate,"ZodISODateTime",()=>_.ZodISODateTime,"ZodISODuration",()=>_.ZodISODuration,"ZodISOTime",()=>_.ZodISOTime,"ZodIntersection",()=>_.ZodIntersection,"ZodIssueCode",()=>_.ZodIssueCode,"ZodJWT",()=>_.ZodJWT,"ZodKSUID",()=>_.ZodKSUID,"ZodLazy",()=>_.ZodLazy,"ZodLiteral",()=>_.ZodLiteral,"ZodMAC",()=>_.ZodMAC,"ZodMap",()=>_.ZodMap,"ZodNaN",()=>_.ZodNaN,"ZodNanoID",()=>_.ZodNanoID,"ZodNever",()=>_.ZodNever,"ZodNonOptional",()=>_.ZodNonOptional,"ZodNull",()=>_.ZodNull,"ZodNullable",()=>_.ZodNullable,"ZodNumber",()=>_.ZodNumber,"ZodNumberFormat",()=>_.ZodNumberFormat,"ZodObject",()=>_.ZodObject,"ZodOptional",()=>_.ZodOptional,"ZodPipe",()=>_.ZodPipe,"ZodPrefault",()=>_.ZodPrefault,"ZodPreprocess",()=>_.ZodPreprocess,"ZodPromise",()=>_.ZodPromise,"ZodReadonly",()=>_.ZodReadonly,"ZodRealError",()=>_.ZodRealError,"ZodRecord",()=>_.ZodRecord,"ZodSet",()=>_.ZodSet,"ZodString",()=>_.ZodString,"ZodStringFormat",()=>_.ZodStringFormat,"ZodSuccess",()=>_.ZodSuccess,"ZodSymbol",()=>_.ZodSymbol,"ZodTemplateLiteral",()=>_.ZodTemplateLiteral,"ZodTransform",()=>_.ZodTransform,"ZodTuple",()=>_.ZodTuple,"ZodType",()=>_.ZodType,"ZodULID",()=>_.ZodULID,"ZodURL",()=>_.ZodURL,"ZodUUID",()=>_.ZodUUID,"ZodUndefined",()=>_.ZodUndefined,"ZodUnion",()=>_.ZodUnion,"ZodUnknown",()=>_.ZodUnknown,"ZodVoid",()=>_.ZodVoid,"ZodXID",()=>_.ZodXID,"ZodXor",()=>_.ZodXor,"_ZodString",()=>_._ZodString,"_default",()=>_._default,"_function",()=>_._function,"any",()=>_.any,"array",()=>_.array,"base64",()=>_.base64,"base64url",()=>_.base64url,"bigint",()=>_.bigint,"boolean",()=>_.boolean,"catch",()=>_.catch,"check",()=>_.check,"cidrv4",()=>_.cidrv4,"cidrv6",()=>_.cidrv6,"clone",()=>_.clone,"codec",()=>_.codec,"coerce",()=>_.coerce,"config",()=>_.config,"core",()=>_.core,"cuid",()=>_.cuid,"cuid2",()=>_.cuid2,"custom",()=>_.custom,"date",()=>_.date,"decode",()=>_.decode,"decodeAsync",()=>_.decodeAsync,"default",0,_,"describe",()=>_.describe,"discriminatedUnion",()=>_.discriminatedUnion,"e164",()=>_.e164,"email",()=>_.email,"emoji",()=>_.emoji,"encode",()=>_.encode,"encodeAsync",()=>_.encodeAsync,"endsWith",()=>_.endsWith,"enum",()=>_.enum,"exactOptional",()=>_.exactOptional,"file",()=>_.file,"flattenError",()=>_.flattenError,"float32",()=>_.float32,"float64",()=>_.float64,"formatError",()=>_.formatError,"fromJSONSchema",()=>_.fromJSONSchema,"function",()=>_.function,"getErrorMap",()=>_.getErrorMap,"globalRegistry",()=>_.globalRegistry,"gt",()=>_.gt,"gte",()=>_.gte,"guid",()=>_.guid,"hash",()=>_.hash,"hex",()=>_.hex,"hostname",()=>_.hostname,"httpUrl",()=>_.httpUrl,"includes",()=>_.includes,"instanceof",()=>_.instanceof,"int",()=>_.int,"int32",()=>_.int32,"int64",()=>_.int64,"intersection",()=>_.intersection,"invertCodec",()=>_.invertCodec,"ipv4",()=>_.ipv4,"ipv6",()=>_.ipv6,"iso",()=>_.iso,"json",()=>_.json,"jwt",()=>_.jwt,"keyof",()=>_.keyof,"ksuid",()=>_.ksuid,"lazy",()=>_.lazy,"length",()=>_.length,"literal",()=>_.literal,"locales",()=>_.locales,"looseObject",()=>_.looseObject,"looseRecord",()=>_.looseRecord,"lowercase",()=>_.lowercase,"lt",()=>_.lt,"lte",()=>_.lte,"mac",()=>_.mac,"map",()=>_.map,"maxLength",()=>_.maxLength,"maxSize",()=>_.maxSize,"meta",()=>_.meta,"mime",()=>_.mime,"minLength",()=>_.minLength,"minSize",()=>_.minSize,"multipleOf",()=>_.multipleOf,"nan",()=>_.nan,"nanoid",()=>_.nanoid,"nativeEnum",()=>_.nativeEnum,"negative",()=>_.negative,"never",()=>_.never,"nonnegative",()=>_.nonnegative,"nonoptional",()=>_.nonoptional,"nonpositive",()=>_.nonpositive,"normalize",()=>_.normalize,"null",()=>_.null,"nullable",()=>_.nullable,"nullish",()=>_.nullish,"number",()=>_.number,"object",()=>_.object,"optional",()=>_.optional,"overwrite",()=>_.overwrite,"parse",()=>_.parse,"parseAsync",()=>_.parseAsync,"partialRecord",()=>_.partialRecord,"pipe",()=>_.pipe,"positive",()=>_.positive,"prefault",()=>_.prefault,"preprocess",()=>_.preprocess,"prettifyError",()=>_.prettifyError,"promise",()=>_.promise,"property",()=>_.property,"readonly",()=>_.readonly,"record",()=>_.record,"refine",()=>_.refine,"regex",()=>_.regex,"regexes",()=>_.regexes,"registry",()=>_.registry,"safeDecode",()=>_.safeDecode,"safeDecodeAsync",()=>_.safeDecodeAsync,"safeEncode",()=>_.safeEncode,"safeEncodeAsync",()=>_.safeEncodeAsync,"safeParse",()=>_.safeParse,"safeParseAsync",()=>_.safeParseAsync,"set",()=>_.set,"setErrorMap",()=>_.setErrorMap,"size",()=>_.size,"slugify",()=>_.slugify,"startsWith",()=>_.startsWith,"strictObject",()=>_.strictObject,"string",()=>
1_.string,"stringFormat",()=>_.stringFormat,"stringbool",()=>_.stringbool,"success",()=>_.success,"superRefine",()=>_.superRefine,"symbol",()=>_.symbol,"templateLiteral",()=>_.templateLiteral,"toJSONSchema",()=>_.toJSONSchema,"toLowerCase",()=>_.toLowerCase,"toUpperCase",()=>_.toUpperCase,"transform",()=>_.transform,"treeifyError",()=>_.treeifyError,"trim",()=>_.trim,"tuple",()=>_.tuple,"uint32",()=>_.uint32,"uint64",()=>_.uint64,"ulid",()=>_.ulid,"undefined",()=>_.undefined,"union",()=>_.union,"unknown",()=>_.unknown,"uppercase",()=>_.uppercase,"url",()=>_.url,"util",()=>_.util,"uuid",()=>_.uuid,"uuidv4",()=>_.uuidv4,"uuidv6",()=>_.uuidv6,"uuidv7",()=>_.uuidv7,"void",()=>_.void,"xid",()=>_.xid,"xor",()=>_.xor,"z",0,_],827371),e.i(827371),e.s(["$brand",()=>_.$brand,"$input",()=>_.$input,"$output",()=>_.$output,"NEVER",()=>_.NEVER,"TimePrecision",()=>_.TimePrecision,"ZodAny",()=>_.ZodAny,"ZodArray",()=>_.ZodArray,"ZodBase64",()=>_.ZodBase64,"ZodBase64URL",()=>_.ZodBase64URL,"ZodBigInt",()=>_.ZodBigInt,"ZodBigIntFormat",()=>_.ZodBigIntFormat,"ZodBoolean",()=>_.ZodBoolean,"ZodCIDRv4",()=>_.ZodCIDRv4,"ZodCIDRv6",()=>_.ZodCIDRv6,"ZodCUID",()=>_.ZodCUID,"ZodCUID2",()=>_.ZodCUID2,"ZodCatch",()=>_.ZodCatch,"ZodCodec",()=>_.ZodCodec,"ZodCustom",()=>_.ZodCustom,"ZodCustomStringFormat",()=>_.ZodCustomStringFormat,"ZodDate",()=>_.ZodDate,"ZodDefault",()=>_.ZodDefault,"ZodDiscriminatedUnion",()=>_.ZodDiscriminatedUnion,"ZodE164",()=>_.ZodE164,"ZodEmail",()=>_.ZodEmail,"ZodEmoji",()=>_.ZodEmoji,"ZodEnum",()=>_.ZodEnum,"ZodError",()=>_.ZodError,"ZodExactOptional",()=>_.ZodExactOptional,"ZodFile",()=>_.ZodFile,"ZodFirstPartyTypeKind",()=>_.ZodFirstPartyTypeKind,"ZodFunction",()=>
1_.ZodFunction,"ZodGUID",()=>_.ZodGUID,"ZodIPv4",()=>_.ZodIPv4,"ZodIPv6",()=>_.ZodIPv6,"ZodISODate",()=>_.ZodISODate,"ZodISODateTime",()=>_.ZodISODateTime,"ZodISODuration",()=>_.ZodISODuration,"ZodISOTime",()=>_.ZodISOTime,"ZodIntersection",()=>_.ZodIntersection,"ZodIssueCode",()=>_.ZodIssueCode,"ZodJWT",()=>_.ZodJWT,"ZodKSUID",()=>_.ZodKSUID,"ZodLazy",()=>_.ZodLazy,"ZodLiteral",()=>_.ZodLiteral,"ZodMAC",()=>_.ZodMAC,"ZodMap",()=>_.ZodMap,"ZodNaN",()=>_.ZodNaN,"ZodNanoID",()=>_.ZodNanoID,"ZodNever",()=>_.ZodNever,"ZodNonOptional",()=>_.ZodNonOptional,"ZodNull",()=>_.ZodNull,"ZodNullable",()=>_.ZodNullable,"ZodNumber",()=>_.ZodNumber,"ZodNumberFormat",()=>_.ZodNumberFormat,"ZodObject",()=>_.ZodObject,"ZodOptional",()=>_.ZodOptional,"ZodPipe",()=>_.ZodPipe,"ZodPrefault",()=>_.ZodPrefault,"ZodPreprocess",()=>_.ZodPreprocess,"ZodPromise",()=>_.ZodPromise,"ZodReadonly",()=>_.ZodReadonly,"ZodRealError",()=>_.ZodRealError,"ZodRecord",()=>_.ZodRecord,"ZodSet",()=>_.ZodSet,"ZodString",()=>_.ZodString,"ZodStringFormat",()=>_.ZodStringFormat,"ZodSuccess",()=>_.ZodSuccess,"ZodSymbol",()=>_.ZodSymbol,"ZodTemplateLiteral",()=>_.ZodTemplateLiteral,"ZodTransform",()=>_.ZodTransform,"ZodTuple",()=>_.ZodTuple,"ZodType",()=>_.ZodType,"ZodULID",()=>_.ZodULID,"ZodURL",()=>_.ZodURL,"ZodUUID",()=>_.ZodUUID,"ZodUndefined",()=>_.ZodUndefined,"ZodUnion",()=>_.ZodUnion,"ZodUnknown",()=>_.ZodUnknown,"ZodVoid",()=>_.ZodVoid,"ZodXID",()=>_.ZodXID,"ZodXor",()=>_.ZodXor,"_ZodString",()=>_._ZodString,"_default",()=>_._default,"_function",()=>_._function,"any",()=>_.any,"array",()=>_.array,"base64",()=>_.base64,"base64url",()=>_.base64url,"bigint",()=>_.bigint,"boolean",()=>_.boolean,"catch",()=>_.catch,"check",()=>_.check,"cidrv4",()=>_.cidrv4,"cidrv6",()=>_.cidrv6,"clone",()=>_.clone,"codec",()=>_.codec,"coerce",()=>_.coerce,"config",()=>_.config,"core",()=>_.core,"cuid",()=>_.cuid,"cuid2",()=>_.cuid2,"custom",()=>_.custom,"date",()=>_.date,"decode",()=>_.decode,"decodeAsync",()=>_.decodeAsync,"default",0,_,"describe",()=>_.describe,"discriminatedUnion",()=>_.discriminatedUnion,"e164",()=>_.e164,"email",()=>_.email,"emoji",()=>_.emoji,"encode",()=>_.encode,"encodeAsync",()=>_.encodeAsync,"endsWith",()=>_.endsWith,"enum",()=>_.enum,"exactOptional",()=>_.exactOptional,"file",()=>_.file,"flattenError",()=>_.flattenError,"float32",()=>_.float32,"float64",()=>_.float64,"formatError",()=>_.formatError,"fromJSONSchema",()=>_.fromJSONSchema,"function",()=>_.function,"getErrorMap",()=>_.getErrorMap,"globalRegistry",()=>_.globalRegistry,"gt",()=>_.gt,"gte",()=>_.gte,"guid",()=>_.guid,"hash",()=>_.hash,"hex",()=>_.hex,"hostname",()=>_.hostname,"httpUrl",()=>_.httpUrl,"includes",()=>_.includes,"instanceof",()=>_.instanceof,"int",()=>_.int,"int32",()=>_.int32,"int64",()=>_.int64,"intersection",()=>_.intersection,"invertCodec",()=>_.invertCodec,"ipv4",()=>_.ipv4,"ipv6",()=>_.ipv6,"iso",()=>_.iso,"json",()=>_.json,"jwt",()=>_.jwt,"keyof",()=>_.keyof,"ksuid",()=>_.ksuid,"lazy",()=>_.lazy,"length",()=>_.length,"literal",()=>_.literal,"locales",()=>_.locales,"looseObject",()=>_.looseObject,"looseRecord",()=>_.looseRecord,"lowercase",()=>_.lowercase,"lt",()=>_.lt,"lte",()=>_.lte,"mac",()=>_.mac,"map",()=>_.map,"maxLength",()=>_.maxLength,"maxSize",()=>_.maxSize,"meta",()=>_.meta,"mime",()=>_.mime,"minLength",()=>_.minLength,"minSize",()=>_.minSize,"multipleOf",()=>_.multipleOf,"nan",()=>_.nan,"nanoid",()=>_.nanoid,"nativeEnum",()=>_.nativeEnum,"negative",()=>_.negative,"never",()=>_.never,"nonnegative",()=>_.nonnegative,"nonoptional",()=>_.nonoptional,"nonpositive",()=>_.nonpositive,"normalize",()=>_.normalize,"null",()=>_.null,"nullable",()=>_.nullable,"nullish",()=>_.nullish,"number",()=>_.number,"object",()=>_.object,"optional",()=>_.optional,"overwrite",()=>_.overwrite,"parse",()=>_.parse,"parseAsync",()=>_.parseAsync,"partialRecord",()=>_.partialRecord,"pipe",()=>_.pipe,"positive",()=>_.positive,"prefault",()=>_.prefault,"preprocess",()=>_.preprocess,"prettifyError",()=>_.prettifyError,"promise",()=>_.promise,"property",()=>_.property,"readonly",()=>_.readonly,"record",()=>_.record,"refine",()=>_.refine,"regex",()=>_.regex,"regexes",()=>_.regexes,"registry",()=>_.registry,"safeDecode",()=>_.safeDecode,"safeDecodeAsync",()=>_.safeDecodeAsync,"safeEncode",()=>_.safeEncode,"safeEncodeAsync",()=>_.safeEncodeAsync,"safeParse",()=>_.safeParse,"safeParseAsync",()=>_.safeParseAsync,"set",()=>_.set,"setErrorMap",()=>_.setErrorMap,"size",()=>_.size,"slugify",()=>_.slugify,"startsWith",()=>_.startsWith,"strictObject",()=>_.strictObject,"string",()=>
1_.string,"stringFormat",()=>_.stringFormat,"stringbool",()=>_.stringbool,"success",()=>_.success,"superRefine",()=>_.superRefine,"symbol",()=>_.symbol,"templateLiteral",()=>_.templateLiteral,"toJSONSchema",()=>_.toJSONSchema,"toLowerCase",()=>_.toLowerCase,"toUpperCase",()=>_.toUpperCase,"transform",()=>_.transform,"treeifyError",()=>_.treeifyError,"trim",()=>_.trim,"tuple",()=>_.tuple,"uint32",()=>_.uint32,"uint64",()=>_.uint64,"ulid",()=>_.ulid,"undefined",()=>_.undefined,"union",()=>_.union,"unknown",()=>_.unknown,"uppercase",()=>_.uppercase,"url",()=>_.url,"util",()=>_.util,"uuid",()=>_.uuid,"uuidv4",()=>_.uuidv4,"uuidv6",()=>_.uuidv6,"uuidv7",()=>_.uuidv7,"void",()=>_.void,"xid",()=>_.xid,"xor",()=>_.xor,"z",()=>_],756834),e.i(756834);var w=e.i(703573),R=e.i(549648),R=R,C=e.i(614126),k=e.i(2108),x=e.i(946056),x=x;let T="2025-11-25",E=[T,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],I="io.modelcontextprotocol/related-task",P="io.modelcontextprotocol/protocolVersion",q="io.modelcontextprotocol/clientInfo",j="io.modelcontextprotocol/serverInfo",O="io.modelcontextprotocol/clientCapabilities",$="io.modelcontextprotocol/subscriptionId",M="io.modelcontextprotocol/logLevel",N=w.lazy(()=>w.union([w.string(),w.number(),w.boolean(),w.null(),w.record(w.string(),N),w.array(N)])),L=w.record(w.string(),N),A=w.array(N),Z=w.union([w.string(),w.number().int()]),U=w.string(),z=w.object({ttl:w.number().optional()}),D=w.object({taskId:w.string()}),V=w.looseObject({progressToken:Z.optional(),[I]:D.optional()}),H=w.object({_meta:V.optional()}),F=H.extend({task:z.optional()}),W=w.object({method:w.string(),params:H.loose().optional()}),B=w.object({_meta:V.optional()}),J=w.object({method:w.string(),params:B.loose().optional()}),G=w.looseObject({get[j](){return eu.optional().catch(void 0)}}),K=w.looseObject({_meta:G.optional()}),X=w.union([w.string(),w.number().int()]),Y=w.object({jsonrpc:w.literal("2.0"),id:X,...W.shape}).strict(),Q=w.object({jsonrpc:w.literal("2.0"),...J.shape}).strict(),ee=w.object({jsonrpc:w.literal("2.0"),id:X,result:K}).strict(),et=w.object({jsonrpc:w.literal("2.0"),id:X.optional(),error:w.object({code:w.number().int(),message:w.string(),data:w.unknown().optional()})}).strict(),eo=w.union([Y,Q,ee,et]),er=w.union([ee,et]),ei=K.strict(),en=B.extend({requestId:X.optional(),reason:w.string().optional()}),ea=J.extend({method:w.literal("notifications/cancelled"),params:en}),es=w.object({src:w.string(),mimeType:w.string().optional(),sizes:w.array(w.string()).optional(),theme:w.enum(["light","dark"]).optional()}),el=w.object({icons:w.array(es).optional()}),ec=w.object({name:w.string(),title:w.string().optional()}),eu=ec.extend({...ec.shape,...el.shape,version:w.string(),websiteUrl:w.string().optional(),description:w.string().optional()}),ed=w.intersection(w.object({applyDefaults:w.boolean().optional()}),L),ep=w.preprocess(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,w.intersection(w.object({form:ed.optional(),url:L.optional()}),L.optional())),eh=w.looseObject({list:L.optional(),cancel:L.optional(),requests:w.looseObject({sampling:w.looseObject({createMessage:L.optional()}).optional(),elicitation:w.looseObject({create:L.optional()}).optional()}).optional()}),em=w.looseObject({list:L.optional(),cancel:L.optional(),requests:w.looseObject({tools:w.looseObject({call:L.optional()}).optional()}).optional()}),ef=w.object({experimental:w.record(w.string(),L).optional(),sampling:w.object({context:L.optional(),tools:L.optional()}).optional(),elicitation:ep.optional(),roots:w.object({listChanged:w.boolean().optional()}).optional(),tasks:eh.optional(),extensions:w.record(w.string(),L).optional()}),eg=H.extend({protocolVersion:w.string(),capabilities:ef,clientInfo:eu}),eS=W.extend({method:w.literal("initialize"),params:eg}),ev=w.object({experimental:w.record(w.string(),L).optional(),logging:L.optional(),completions:L.optional(),prompts:w.object({listChanged:w.boolean().optional()}).optional(),resources:w.object({subscribe:w.boolean().optional(),listChanged:w.boolean().optional()}).optional(),tools:w.object({listChanged:w.boolean().optional()}).optional(),tasks:em.optional(),extensions:w.record(w.string(),L).optional()}),eb=K.extend({protocolVersion:w.string(),capabilities:ev,serverInfo:eu,instructions:w.string().optional()}),ey=J.extend({method:w.literal("notifications/initialized"),params:B.optional()}),e_=W.extend({method:w.literal("server/discover"),params:H.optional()}),ew=K.extend({supportedVersions:w.array(w.string()),capabilities:ev,instructions:w.string().optional()}),eR=W.extend({method:w.literal("ping"),params:H.optional()}),eC=w.object({progress:w.number(),total:w.optional(w.number()),message:w.optional(w.string())}),ek=w.object({...B.shape,...eC.shape,progressToken:Z}),ex=J.extend({method:w.literal("notifications/progress"),params:ek}
1),eT=H.extend({cursor:U.optional()}),eE=W.extend({params:eT.optional()}),eI=K.extend({nextCursor:U.optional()}),eP=w.object({uri:w.string(),mimeType:w.optional(w.string()),_meta:w.record(w.string(),w.unknown()).optional()}),eq=eP.extend({text:w.string()}),ej=w.string().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),eO=eP.extend({blob:ej}),e$=w.enum(["user","assistant"]),eM=w.object({audience:w.array(e$).optional(),priority:w.number().min(0).max(1).optional(),lastModified:R.datetime({offset:!0}).optional()}),eN=w.object({...ec.shape,...el.shape,uri:w.string(),description:w.optional(w.string()),mimeType:w.optional(w.string()),size:w.optional(w.number()),annotations:eM.optional(),_meta:w.optional(w.looseObject({}))}),eL=w.object({...ec.shape,...el.shape,uriTemplate:w.string(),description:w.optional(w.string()),mimeType:w.optional(w.string()),annotations:eM.optional(),_meta:w.optional(w.looseObject({}))}),eA=eE.extend({method:w.literal("resources/list")}),eZ=eI.extend({resources:w.array(eN)}),eU=eE.extend({method:w.literal("resources/templates/list")}),ez=eI.extend({resourceTemplates:w.array(eL)}),eD=H.extend({uri:w.string()}),eV=W.extend({method:w.literal("resources/read"),params:eD}),eH=K.extend({contents:w.array(w.union([eq,eO]))}),eF=J.extend({method:w.literal("notifications/resources/list_changed"),params:B.optional()}),eW=W.extend({method:w.literal("resources/subscribe"),params:eD}),eB=W.extend({method:w.literal("resources/unsubscribe"),params:eD}),eJ=w.object({toolsListChanged:w.boolean().optional(),promptsListChanged:w.boolean().optional(),resourcesListChanged:w.boolean().optional(),resourceSubscriptions:w.array(w.string()).optional()}),eG=H.extend({notifications:eJ}),eK=W.extend({method:w.literal("subscriptions/listen"),params:eG}),eX=B.extend({notifications:eJ}),eY=J.extend({method:w.literal("notifications/subscriptions/acknowledged"),params:eX}),eQ=G.extend({[$]:X}),e0=K.extend({_meta:eQ}),e1=B.extend({uri:w.string()}),e2=J.extend({method:w.literal("notifications/resources/updated"),params:e1}),e4=w.object({name:w.string(),description:w.optional(w.string()),required:w.optional(w.boolean())}),e9=w.object({...ec.shape,...el.shape,description:w.optional(w.string()),arguments:w.optional(w.array(e4)),_meta:w.optional(w.looseObject({}))}),e6=eE.extend({method:w.literal("prompts/list")}),e3=eI.extend({prompts:w.array(e9)}),e5=H.extend({name:w.string(),arguments:w.record(w.string(),w.string()).optional()}),e8=W.extend({method:w.literal("prompts/get"),params:e5}),e7=w.object({type:w.literal("text"),text:w.string(),annotations:eM.optional(),_meta:w.record(w.string(),w.unknown()).optional()}),te=w.object({type:w.literal("image"),data:ej,mimeType:w.string(),annotations:eM.optional(),_meta:w.record(w.string(),w.unknown()).optional()}),tt=w.object({type:w.literal("audio"),data:ej,mimeType:w.string(),annotations:eM.optional(),_meta:w.record(w.string(),w.unknown()).optional()}),to=w.object({type:w.literal("tool_use"),name:w.string(),id:w.string(),input:w.record(w.string(),w.unknown()),_meta:w.record(w.string(),w.unknown()).optional()}),tr=w.object({type:w.literal("resource"),resource:w.union([eq,eO]),annotations:eM.optional(),_meta:w.record(w.string(),w.unknown()).optional()}),ti=eN.extend({type:w.literal("resource_link")}),tn=w.union([e7,te,tt,ti,tr]),ta=w.object({role:e$,content:tn}),ts=K.extend({description:w.string().optional(),messages:w.array(ta)}),tl=J.extend({method:w.literal("notifications/prompts/list_changed"),params:B.optional()}),tc=w.object({title:w.string().optional(),readOnlyHint:w.boolean().optional(),destructiveHint:w.boolean().optional(),idempotentHint:w.boolean().optional(),openWorldHint:w.boolean().optional()}),tu=w.object({taskSupport:w.enum(["required","optional","forbidden"]).optional()}),td=w.object({...ec.shape,...el.shape,description:w.string().optional(),inputSchema:w.object({type:w.literal("object"),properties:w.record(w.string(),N).optional(),required:w.array(w.string()).optional()}).catchall(w.unknown()),outputSchema:w.looseObject({$schema:w.string().optional()}).optional(),annotations:tc.optional(),execution:tu.optional(),_meta:w.record(w.string(),w.unknown()).optional()}),tp=eE.extend({method:w.literal("tools/list")}),th=eI.extend({tools:w.array(td)}),tm=K.extend({content:w.array(tn).default([]),structuredContent:w.unknown().optional(),isError:w.boolean().optional()}),tf=tm.or(K.extend({toolResult:w.unknown()})),tg=F.extend({name:w.string(),arguments:w.record(w.string(),w.unknown()).optional()}),tS=W.extend({method:w.literal("tools/call"),params:tg}),tv=J.extend({method:w.literal("notifications/tools/list_changed"),params:B.optional()}),tb=w.object({autoRefresh:w.boolean().default(!0),debounceMs:w.number().int().nonnegative().default(300)}),ty=w.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),t_=H.extend({level:ty}),tw=W.extend({method:w.literal("logging/setLevel"),params:t_}),tR=B.extend({level:ty,logger:w.string().optional(),data:w.unknown()}),tC=J.extend({method:w.literal("notifications/message"),params:tR}),tk=w.object({name:w.string().optional()}),tx=w.object({hints:w.array(tk).optional(),costPriority:w.number().min(0).max(1).optional(),speedPriority:w.number().min(0).max(1).optional(),intelligencePriority:w.number().min(0).max(1).optional()}),tT=w.object({mode:w.enum(["auto","required","none"]).optional()}),tE=w.object({type:w.literal("tool_result"),toolUseId:w.string().describe("The unique identifier for the corresponding tool call."),content:w.array(tn),structuredContent:w.unknown().optional(),isError:w.boolean().optional(),_meta:w.record(w.string(),w.unknown()).optional()}),tI=w.discriminatedUnion("type",[e7,te,tt]),tP=w.discriminatedUnion("type",[e7,te,tt,to,tE]),tq=w.object({role:e$,content:w.union([tP,w.array(tP)]),_meta:w.record(w.string(),w.unknown()).optional()}),tj=F.extend({messages:w.array(tq),modelPreferences:tx.optional(),systemPrompt:w.string().optional(),includeContext:w.enum(["none","thisServer","allServers"]).optional(),temperature:w.number().optional(),maxTokens:w.number().int(),stopSequences:w.array(w.string()).optional(),metadata:L.optional(),tools:w.array(td).optional(),toolChoice:tT.o
1ptional()}),tO=W.extend({method:w.literal("sampling/createMessage"),params:tj}),t$=K.extend({model:w.string(),stopReason:w.optional(w.enum(["endTurn","stopSequence","maxTokens"]).or(w.string())),role:e$,content:tI}),tM=K.extend({model:w.string(),stopReason:w.optional(w.enum(["endTurn","stopSequence","maxTokens","toolUse"]).or(w.string())),role:e$,content:w.union([tP,w.array(tP)])}),tN=w.object({type:w.literal("boolean"),title:w.string().optional(),description:w.string().optional(),default:w.boolean().optional()}),tL=w.object({type:w.literal("string"),title:w.string().optional(),description:w.string().optional(),minLength:w.number().optional(),maxLength:w.number().optional(),format:w.enum(["email","uri","date","date-time"]).optional(),default:w.string().optional()}),tA=w.object({type:w.enum(["number","integer"]),title:w.string().optional(),description:w.string().optional(),minimum:w.number().optional(),maximum:w.number().optional(),default:w.number().optional()}),tZ=w.object({type:w.literal("string"),title:w.string().optional(),description:w.string().optional(),enum:w.array(w.string()),default:w.string().optional()}),tU=w.object({type:w.literal("string"),title:w.string().optional(),description:w.string().optional(),oneOf:w.array(w.object({const:w.string(),title:w.string()})),default:w.string().optional()}),tz=w.object({type:w.literal("string"),title:w.string().optional(),description:w.string().optional(),enum:w.array(w.string()),enumNames:w.array(w.string()).optional(),default:w.string().optional()}),tD=w.union([tZ,tU]),tV=w.object({type:w.literal("array"),title:w.string().optional(),description:w.string().optional(),minItems:w.number().optional(),maxItems:w.number().optional(),items:w.object({type:w.literal("string"),enum:w.array(w.string())}),default:w.array(w.string()).optional()}),tH=w.object({type:w.literal("array"),title:w.string().optional(),description:w.string().optional(),minItems:w.number().optional(),maxItems:w.number().optional(),items:w.object({anyOf:w.array(w.object({const:w.string(),title:w.string()}))}),default:w.array(w.string()).optional()}),tF=w.union([tV,tH]),tW=w.union([tz,tD,tF]),tB=w.union([tW,tN,tL,tA]),tJ=F.extend({mode:w.literal("form").optional(),message:w.string(),requestedSchema:w.object({type:w.literal("object"),properties:w.record(w.string(),tB),required:w.array(w.string()).optional()}).catchall(w.unknown())}),tG=F.extend({mode:w.literal("url"),message:w.string(),elicitationId:w.string(),url:w.string().url()}),tK=w.union([tJ,tG]),tX=W.extend({method:w.literal("elicitation/create"),params:tK}),tY=B.extend({elicitationId:w.string()}),tQ=J.extend({method:w.literal("notifications/elicitation/complete"),params:tY}),t0=K.extend({action:w.enum(["accept","decline","cancel"]),content:w.preprocess(e=>null===e?void 0:e,w.record(w.string(),w.union([w.string(),w.number(),w.boolean(),w.array(w.string())])).optional())}),t1=w.object({type:w.literal("ref/resource"),uri:w.string()}),t2=w.object({type:w.literal("ref/prompt"),name:w.string()}),t4=H.extend({ref:w.union([t2,t1]),argument:w.object({name:w.string(),value:w.string()}),context:w.object({arguments:w.record(w.string(),w.string()).optional()}).optional()}),t9=W.extend({method:w.literal("completion/complete"),params:t4}),t6=K.extend({completion:w.looseObject({values:w.array(w.string()).max(100),total:w.optional(w.number().int()),hasMore:w.optional(w.boolean())})}),t3=w.object({uri:w.string().startsWith("file://"),name:w.string().optional(),_meta:w.record(w.string(),w.unknown()).optional()}),t5=W.extend({method:w.literal("roots/list"),params:H.optional()}),t8=K.extend({roots:w.array(t3)}),t7=J.extend({method:w.literal("notifications/roots/list_changed"),params:B.optional()}),oe=w.looseObject({ttl:w.number().optional(),pollInterval:w.number().optional()}),ot=w.enum(["working","input_required","completed","failed","cancelled"]),oo=w.object({taskId:w.string(),status:ot,ttl:w.union([w.number(),w.null()]),createdAt:w.string(),lastUpdatedAt:w.string(),pollInterval:w.optional(w.number()),statusMessage:w.optional(w.string())}),or=K.extend({task:oo}),oi=B.merge(oo),on=J.extend({method:w.literal("notifications/tasks/status"),params:oi}),oa=W.extend({method:w.literal("tasks/get"),params:H.extend({taskId:w.string()})}
1),os=K.merge(oo),ol=W.extend({method:w.literal("tasks/result"),params:H.extend({taskId:w.string()})}),oc=K.loose(),ou=eE.extend({method:w.literal("tasks/list")}),od=eI.extend({tasks:w.array(oo)}),op=W.extend({method:w.literal("tasks/cancel"),params:H.extend({taskId:w.string()})}),oh=K.merge(oo),om=w.union([eR,eS,e_,t9,tw,e8,e6,eA,eU,eV,eW,eB,eK,tS,tp]),of=w.union([ea,ex,ey,t7]),og=w.union([ei,t$,tM,t0,t8]),oS=w.union([eR,tO,tX,t5]),ov=w.union([ea,ex,tC,e2,eF,tv,tl,eY,tQ]),ob=w.union([ei,eb,ew,t6,ts,e3,eZ,ez,eH,tm,th,e0]),oy=w.url().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:C.ZodIssueCode.custom,message:"URL must be parseable",fatal:!0}),k.NEVER}).refine(e=>{let t=new URL(e);return"javascript:"!==t.protocol&&"data:"!==t.protocol&&"vbscript:"!==t.protocol},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),o_=w.looseObject({resource:w.string().url(),authorization_servers:w.array(oy).optional(),jwks_uri:w.string().url().optional(),scopes_supported:w.array(w.string()).optional(),bearer_methods_supported:w.array(w.string()).optional(),resource_signing_alg_values_supported:w.array(w.string()).optional(),resource_name:w.string().optional(),resource_documentation:w.string().optional(),resource_policy_uri:w.string().url().optional(),resource_tos_uri:w.string().url().optional(),tls_client_certificate_bound_access_tokens:w.boolean().optional(),authorization_details_types_supported:w.array(w.string()).optional(),dpop_signing_alg_values_supported:w.array(w.string()).optional(),dpop_bound_access_tokens_required:w.boolean().optional()}),ow=w.looseObject({issuer:w.string(),authorization_endpoint:oy,token_endpoint:oy,registration_endpoint:oy.optional(),scopes_supported:w.array(w.string()).optional(),response_types_supported:w.array(w.string()),response_modes_supported:w.array(w.string()).optional(),grant_types_supported:w.array(w.string()).optional(),token_endpoint_auth_methods_supported:w.array(w.string()).optional(),token_endpoint_auth_signing_alg_values_supported:w.array(w.string()).optional(),service_documentation:oy.optional(),revocation_endpoint:oy.optional(),revocation_endpoint_auth_methods_supported:w.array(w.string()).optional(),revocation_endpoint_auth_signing_alg_values_supported:w.array(w.string()).optional(),introspection_endpoint:w.string().optional(),introspection_endpoint_auth_methods_supported:w.array(w.string()).optional(),introspection_endpoint_auth_signing_alg_values_supported:w.array(w.string()).optional(),code_challenge_methods_supported:w.array(w.string()).optional(),client_id_metadata_document_supported:w.boolean().optional(),authorization_response_iss_parameter_supported:w.boolean().optional().catch(void 0)}),oR=w.looseObject({issuer:w.string(),authorization_endpoint:oy,token_endpoint:oy,userinfo_endpoint:oy.optional(),jwks_uri:oy,registration_endpoint:oy.optional(),scopes_supported:w.array(w.string()).optional(),response_types_supported:w.array(w.string()),response_modes_supported:w.array(w.string()).optional(),grant_types_supported:w.array(w.string()).optional(),acr_values_supported:w.array(w.string()).optional(),subject_types_supported:w.array(w.string()),id_token_signing_alg_values_supported:w.array(w.string()),id_token_encryption_alg_values_supported:w.array(w.string()).optional(),id_token_encryption_enc_values_supported:w.array(w.string()).optional(),userinfo_signing_alg_values_supported:w.array(w.string()).optional(),userinfo_encryption_alg_values_supported:w.array(w.string()).optional(),userinfo_encryption_enc_values_supported:w.array(w.string()).optional(),request_object_signing_alg_values_supported:w.array(w.string()).optional(),request_object_encryption_alg_values_supported:w.array(w.string()).optional(),request_object_encryption_enc_values_supported:w.array(w.string()).optional(),token_endpoint_auth_methods_supported:w.array(w.string()).optional(),token_endpoint_auth_signing_alg_values_supported:w.array(w.string()).optional(),display_values_supported:w.array(w.string()).optional(),claim_types_supported:w.array(w.string()).optional(),claims_supported:w.array(w.string()).optional(),service_documentation:w.string().optional(),claims_locales_supported:w.array(w.string()).optional(),ui_locales_supported:w.array(w.string()).optional(),claims_parameter_supported:w.boolean().optional(),request_parameter_supported:w.boolean().optional(),request_uri_parameter_supported:w.boolean().optional(),require_request_uri_registration:w.boolean().optional(),op_policy_uri:oy.optional(),op_tos_uri:oy.optional(),client_id_metadata_document_supported:w.boolean().optional(),authorization_response_iss_parameter_supported:w.boolean().optional().catch(void 0)}),oC=w.object({...oR.shape,...ow.pick({code_challenge_methods_supported:!0}
1).shape}),ok=w.object({access_token:w.string(),id_token:w.string().optional(),token_type:w.string(),expires_in:x.number().optional(),scope:w.string().optional(),refresh_token:w.string().optional()}).strip(),ox=w.object({issued_token_type:w.literal("urn:ietf:params:oauth:token-type:id-jag"),access_token:w.string(),token_type:w.string().optional(),expires_in:w.number().optional(),scope:w.string().optional()}).strip(),oT=w.object({error:w.string(),error_description:w.string().optional(),error_uri:w.string().optional()}),oE=oy.optional().or(w.literal("").transform(()=>void 0)),oI=w.object({redirect_uris:w.array(oy),token_endpoint_auth_method:w.string().optional(),grant_types:w.array(w.string()).optional(),response_types:w.array(w.string()).optional(),application_type:w.string().optional(),client_name:w.string().optional(),client_uri:oy.optional(),logo_uri:oE,scope:w.string().optional(),contacts:w.array(w.string()).optional(),tos_uri:oE,policy_uri:w.string().optional(),jwks_uri:oy.optional(),jwks:w.any().optional(),software_id:w.string().optional(),software_version:w.string().optional(),software_statement:w.string().optional()}).strip(),oP=w.object({client_id:w.string(),client_secret:w.string().optional(),client_id_issued_at:w.number().optional(),client_secret_expires_at:w.number().optional()}).strip(),oq=oI.merge(oP),oj=w.object({error:w.string(),error_description:w.string().optional()}).strip(),oO=w.object({token:w.string(),token_type_hint:w.string().optional()}).strip();e.s(["$",0,tr,"$n",0,z,"$t",0,tB,"A",0,om,"An",0,tI,"Ar",0,-32700,"At",0,eU,"B",0,t$,"Bn",0,tD,"Bt",0,ty,"C",0,tm,"Cn",0,e1,"Cr",0,-32603,"Ct",0,er,"D",0,ea,"Dn",0,e$,"Dr",0,T,"Dt",0,tb,"E",0,en,"En",0,K,"Er",0,"2.0","Et",0,tz,"F",0,t9,"Fn",0,oS,"Fr",0,E,"Ft",0,t8,"G",0,ew,"Gn",0,eX,"Gt",0,tF,"H",0,or,"Hn",0,eD,"Ht",0,tC,"I",0,t6,"In",0,ob,"Ir",0,"traceparent","It",0,ou,"J",0,tX,"Jn",0,eK,"Jt",0,tA,"K",0,tJ,"Kn",0,eY,"Kt",0,J,"L",0,tn,"Ln",0,em,"Lr",0,"tracestate","Lt",0,od,"M",0,eh,"Mn",0,tq,"Mr",0,I,"Mt",0,eA,"N",0,tf,"Nn",0,ev,"Nr",0,j,"Nt",0,eZ,"O",0,ef,"On",0,t3,"Or",0,M,"Ot",0,e6,"P",0,t4,"Pn",0,ov,"Pr",0,$,"Pt",0,t5,"Q",0,tQ,"Qn",0,oe,"Qt",0,eR,"R",0,tj,"Rn",0,t_,"Rt",0,tp,"S",0,tS,"Sn",0,eL,"Sr",0,"2025-03-26","St",0,Y,"T",0,oh,"Tn",0,G,"Tr",0,-32600,"Tt",0,N,"U",0,U,"Un",0,eW,"Ut",0,tk,"V",0,tM,"Vn",0,tL,"Vt",0,tR,"W",0,e_,"Wn",0,eJ,"Wt",0,tx,"X",0,t0,"Xn",0,e0,"Xt",0,eE,"Y",0,tG,"Yn",0,eQ,"Yt",0,eT,"Z",0,tY,"Zn",0,F,"Zt",0,eI,"_",0,ec,"_n",0,ti,"_r",0,tV,"_t",0,A,"a",0,oj,"an",0,tl,"ar",0,eq,"at",0,ol,"b",0,tN,"bn",0,eN,"br",0,O,"bt",0,eo,"c",0,o_,"cn",0,e9,"cr",0,tc,"ct",0,os,"d",0,oC,"dn",0,eH,"dr",0,tv,"dt",0,te,"en",0,ek,"er",0,oo,"et",0,ei,"f",0,oR,"fn",0,D,"fr",0,tE,"ft",0,eu,"g",0,tt,"gn",0,eP,"gr",0,eB,"gt",0,ey,"h",0,eM,"hn",0,W,"hr",0,eD,"ht",0,eb,"i",0,oI,"in",0,e4,"ir",0,e7,"it",0,ts,"j",0,og,"jn",0,tP,"jr",0,P,"jt",0,ez,"k",0,of,"kn",0,t7,"kr",0,-32601,"kt",0,e3,"l",0,oO,"ln",0,eD,"lr",0,tT,"lt",0,es,"m",0,oy,"mn",0,V,"mr",0,to,"mt",0,eS,"n",0,oq,"nn",0,eC,"nr",0,on,"nt",0,e5,"o",0,oT,"on",0,ta,"or",0,tH,"ot",0,oc,"p",0,oE,"pn",0,X,"pr",0,td,"pt",0,eg,"q",0,tK,"qn",0,eG,"qt",0,B,"r",0,oP,"rn",0,Z,"rr",0,ot,"rt",0,e8,"s",0,ow,"sn",0,t2,"sr",0,tU,"st",0,oa,"t",0,ox,"tn",0,ex,"tr",0,oi,"tt",0,tW,"u",0,ok,"un",0,eV,"ur",0,tu,"ut",0,el,"v",0,H,"vn",0,eF,"vr",0,tZ,"vt",0,L,"w",0,op,"wn",0,e2,"wr",0,-32602,"wt",0,ee,"x",0,tg,"xn",0,t1,"xr",0,q,"xt",0,Q,"y",0,eO,"yn",0,eD,"yr",0,"baggage","yt",0,et,"z",0,tO,"zn",0,tw,"zt",0,th],146980),e.s(["CallToolResultSchema",0,tm],958176),e.s(["ContentBlockSchema",0,tn],342146),e.s(["EmbeddedResourceSchema",0,tr],518553),e.s(["EmptyResultSchema",0,ei],887224),e.s(["ImplementationSchema",0,eu],921156),e.s(["JSONRPCMessageSchema",0,eo],109086),e.s(["LoggingMessageNotificationSchema",0,tC],330288),e.s(["RequestIdSchema",0,X],585549),e.s(["ResourceLinkSchema",0,ti],884104),e.s(["ToolSchema",0,td],101116);var R=R,o$=e.i(696859),oM=e.i(232428);let oN=Symbol.for("mcp.sdk.errorBrands");function oL(e,t){let o=new Set,r=t;for(;"function"==typeof r;){let e=r.mcpBrand;Object.prototype.hasOwnProperty.call(r,"mcpBrand")&&"string"==typeof e&&o.add(e),r=Object.getPrototypeOf(r)}
10!==o.size&&Object.defineProperty(e,oN,{value:o,enumerable:!1,configurable:!0})}function oA(e,t){try{if("object"==typeof t&&null!==t&&Object.prototype.hasOwnProperty.call(e,"mcpBrand")&&"string"==typeof e.mcpBrand&&Object.prototype.hasOwnProperty.call(t,oN)){let o=t[oN];if(o&&"function"==typeof o.has&&o.has(e.mcpBrand))return!0}}catch{}return Function.prototype[Symbol.hasInstance].call(e,t)}let oZ=((no={}).InvalidRequest="invalid_request",no.InvalidClient="invalid_client",no.InvalidGrant="invalid_grant",no.UnauthorizedClient="unauthorized_client",no.UnsupportedGrantType="unsupported_grant_type",no.InvalidScope="invalid_scope",no.AccessDenied="access_denied",no.ServerError="server_error",no.TemporarilyUnavailable="temporarily_unavailable",no.UnsupportedResponseType="unsupported_response_type",no.UnsupportedTokenType="unsupported_token_type",no.InvalidToken="invalid_token",no.MethodNotAllowed="method_not_allowed",no.TooManyRequests="too_many_requests",no.InvalidClientMetadata="invalid_client_metadata",no.InvalidRedirectUri="invalid_redirect_uri",no.InsufficientScope="insufficient_scope",no.InvalidTarget="invalid_target",no);var oU=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthError"})}static[Symbol.hasInstance](e){return oA(this,e)}static isInstance(e){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return oA(this,e)}constructor(e,t,o){super(t),this.code=e,this.errorUri=o,this.name="OAuthError",oL(this,new.target)}toResponseObject(){let e={error:this.code,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}static fromResponse(t){return new e(t.error,t.error_description??t.error,t.error_uri)}};let oz=((nr={}).NotConnected="NOT_CONNECTED",nr.AlreadyConnected="ALREADY_CONNECTED",nr.NotInitialized="NOT_INITIALIZED",nr.CapabilityNotSupported="CAPABILITY_NOT_SUPPORTED",nr.RequestTimeout="REQUEST_TIMEOUT",nr.ConnectionClosed="CONNECTION_CLOSED",nr.SendFailed="SEND_FAILED",nr.InvalidResult="INVALID_RESULT",nr.UnsupportedResultType="UNSUPPORTED_RESULT_TYPE",nr.InputRequiredRoundsExceeded="INPUT_REQUIRED_ROUNDS_EXCEEDED",nr.ListPaginationExceeded="LIST_PAGINATION_EXCEEDED",nr.MethodNotSupportedByProtocolVersion="METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION",nr.EraNegotiationFailed="ERA_NEGOTIATION_FAILED",nr.ClientHttpNotImplemented="CLIENT_HTTP_NOT_IMPLEMENTED",nr.ClientHttpAuthentication="CLIENT_HTTP_AUTHENTICATION",nr.ClientHttpForbidden="CLIENT_HTTP_FORBIDDEN",nr.ClientHttpUnexpectedContent="CLIENT_HTTP_UNEXPECTED_CONTENT",nr.ClientHttpFailedToOpenStream="CLIENT_HTTP_FAILED_TO_OPEN_STREAM",nr.ClientHttpFailedToTerminateSession="CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION",nr);var oD=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkError"})}static[Symbol.hasInstance](e){return oA(this,e)}static isInstance(e){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return oA(this,e)}constructor(e,t,o){super(t),this.code=e,this.data=o,this.name="SdkError",oL(this,new.target)}},oV=class extends oD{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SdkHttpError"})}constructor(e,t,o){super(e,t,o),this.name="SdkHttpError"}get status(){return this.data.status}get statusText(){return this.data.statusText}};function oH(e){let t=new URL("string"==typeof e?e:e.href);return t.hash="",t}function oF({requestedResource:e,configuredResource:t}){let o=new URL("string"==typeof e?e:e.href),r=new URL("string"==typeof t?t:t.href);if(o.origin!==r.origin||o.pathname.length<r.pathname.length)return!1;let i=o.pathname.endsWith("/")?o.pathname:o.pathname+"/",n=r.pathname.endsWith("/")?r.pathname:r.pathname+"/";return i.startsWith(n)}let oW="2026-07-28",oB=[oW];function oJ(e){return e>=oW}function oG(e){return e.filter(e=>!oJ(e))}function oK(e){return e.filter(e=>oJ(e))}function oX(e){let t=e.structuredContent;return void 0===t||!("object"!=typeof t||null===t||Array.isArray(t))||e.content?.some(e=>"text"===e.type)?e:{...e,content:[...e.content??[],{type:"text",text:JSON.stringify(t)}]}}let oY=["task","inputRequests","requestState"];function oQ(e){return null===e||"object"!=typeof e||Array.isArray(e)||void 0!==e.content||oY.some(t=>t in e)?e:{...e,content:[]}}function o0(){let e,o,r,i,n,a,s,l,c,u,d,p,h,m,f,g,S,v,b,y,_,C,k,x,T,E,I,P,q,j,O,$,M,N,L,A,Z,U,z,D,V,H,F,W,B,J,G,K,X,Y,Q,ee,et,eo,er,ei,en,ea,es,el,ec,eu,ed,ep,eh,em,ef,eg,eS,ev,eb,ey,e_,ew,eR,eC,ek,ex,eT,eE,eI,eP,eq,ej,eO,e$,eM,eN,eL,eA,eZ,eU,ez,eD,eV,eH,eF,eW,eB,eJ,eG,eK,eX,eY,eQ,e0,e1,e2,e4,e9,e6,e3,e5,e8,e7,te,tt,to,tr,ti,tn,ta,ts,tl,tc,tu,td,tp,th,tm,tf,tg,tS,tv,tb,ty,t_,tw,tR,tC;return t??=(e=w.lazy(()=>w.union([w.string(),w.number(),w.boolean(),w.null(),w.record(w.string(),e),w.array(e)])),o=w.record(w.string(),e),r=w.union([w.string(),w.number().int()]),i=w.string(),n=w.object({ttl:w.number().optional()}),a=w.object({taskId:w.string()}),s=w.looseObject({progressToken:r.optional(),"io.modelcontextprotocol/related-task":a.optional()}),c=(l=w.object({_meta:s.optional()})).extend({task:n.optional()}),u=w.object({method:w.string(),params:l.loose().optional()}),d=w.object({_meta:s.optional()}),p=w.object({method:w.string(),params:d.loose().optional()}),h=w.looseObject({_meta:s.optional()}),m=w.union([w.string(),w.number().int()]),f=h.strict(),g=d.extend({requestId:m.optional(),reason:w.string().optional()}),S=p.extend({method:w.literal("notifications/cancelled"),params:g}),v=w.object({src:w.string(),mimeType:w.string().optional(),sizes:w.array(w.string()).optional(),theme:w.enum(["light","dark"]).optional()}),b=w.object({icons:w.array(v).optional()}),_=(y=w.object({name:w.string(),title:w.string().optional()})).extend({...y.shape,...b.shape,version:w.string(),websiteUrl:w.string().optional(),description:w.string().optional()}),C=w.intersection(w.object({applyDefaults:w.boolean().optional()}),o),k=w.preprocess(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,w.intersection(w.object({form:C.optional(),url:o.optional()}),o.optional())),x=w.looseObject({list:o.optional(),cancel:o.optional(),requests:w.looseObject({sampling:w.looseObject({createMessage:o.optional()}).optional(),elicitation:w.looseObject({create:o.optional()}).optional()}).optional()}),T=w.looseObject({list:o.optional(),cancel:o.optional(),requests:w.looseObject({tools:w.looseObject({call:o.optional()}).optional()}).optional()}),E=w.object({experimental:w.record(w.string(),o).optional(),sampling:w.object({context:o.optional(),tools:o.optional()}).optional(),elicitation:k.optional(),roots:w.object({listChanged:w.boolean().optional()}).optional(),tasks:x.optional(),extensions:w.record(w.string(),o).optional()}),I=l.extend({protocolVersion:w.string(),capabilities:E,clientInfo:_}),P=u.extend({method:w.literal("initialize"),params:I}),q=w.object({experimental:w.record(w.string(),o).optional(),logging:o.optional(),completions:o.optional(),prompts:w.object({listChanged:w.boolean().optional()}).optional(),resources:w.object({subscribe:w.boolean().optional(),listChanged:w.boolean().optional()}).optional(),tools:w.object({listChanged:w.boolean().optional()}).optional(),tasks:T.optional(),extensions:w.record(w.string(),o).optional()}),j=h.extend({protocolVersion:w.string(),capabilities:q,serverInfo:_,instructions:w.string().optional()}),O=p.extend({method:w.literal("notifications/initialized"),params:d.optional()}),$=u.extend({method:w.literal("ping"),params:l.optional()}),M=w.object({progress:w.number(),total:w.optional(w.number()),message:w.optional(w.string())}),N=w.object({...d.shape,...M.shape,progressToken:r}),L=p.extend({method:w.literal("notifications/progress"),params:N}
1),A=l.extend({cursor:i.optional()}),Z=u.extend({params:A.optional()}),U=h.extend({nextCursor:i.optional()}),D=(z=w.object({uri:w.string(),mimeType:w.optional(w.string()),_meta:w.record(w.string(),w.unknown()).optional()})).extend({text:w.string()}),V=w.string().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),H=z.extend({blob:V}),F=w.enum(["user","assistant"]),W=w.object({audience:w.array(F).optional(),priority:w.number().min(0).max(1).optional(),lastModified:R.datetime({offset:!0}).optional()}),B=w.object({...y.shape,...b.shape,uri:w.string(),description:w.optional(w.string()),mimeType:w.optional(w.string()),size:w.optional(w.number()),annotations:W.optional(),_meta:w.optional(w.looseObject({}))}),J=w.object({...y.shape,...b.shape,uriTemplate:w.string(),description:w.optional(w.string()),mimeType:w.optional(w.string()),annotations:W.optional(),_meta:w.optional(w.looseObject({}))}),G=Z.extend({method:w.literal("resources/list")}),K=U.extend({resources:w.array(B)}),X=Z.extend({method:w.literal("resources/templates/list")}),Y=U.extend({resourceTemplates:w.array(J)}),Q=l.extend({uri:w.string()}),ee=u.extend({method:w.literal("resources/read"),params:Q}),et=h.extend({contents:w.array(w.union([D,H]))}),eo=p.extend({method:w.literal("notifications/resources/list_changed"),params:d.optional()}),er=u.extend({method:w.literal("resources/subscribe"),params:Q}),ei=u.extend({method:w.literal("resources/unsubscribe"),params:Q}),en=d.extend({uri:w.string()}),ea=p.extend({method:w.literal("notifications/resources/updated"),params:en}),es=w.object({name:w.string(),description:w.optional(w.string()),required:w.optional(w.boolean())}),el=w.object({...y.shape,...b.shape,description:w.optional(w.string()),arguments:w.optional(w.array(es)),_meta:w.optional(w.looseObject({}))}),ec=Z.extend({method:w.literal("prompts/list")}),eu=U.extend({prompts:w.array(el)}),ed=l.extend({name:w.string(),arguments:w.record(w.string(),w.string()).optional()}),ep=u.extend({method:w.literal("prompts/get"),params:ed}),eh=w.object({type:w.literal("text"),text:w.string(),annotations:W.optional(),_meta:w.record(w.string(),w.unknown()).optional()}),em=w.object({type:w.literal("image"),data:V,mimeType:w.string(),annotations:W.optional(),_meta:w.record(w.string(),w.unknown()).optional()}),ef=w.object({type:w.literal("audio"),data:V,mimeType:w.string(),annotations:W.optional(),_meta:w.record(w.string(),w.unknown()).optional()}),eg=w.object({type:w.literal("tool_use"),name:w.string(),id:w.string(),input:w.record(w.string(),w.unknown()),_meta:w.record(w.string(),w.unknown()).optional()}),eS=w.object({type:w.literal("resource"),resource:w.union([D,H]),annotations:W.optional(),_meta:w.record(w.string(),w.unknown()).optional()}),ev=B.extend({type:w.literal("resource_link")}),eb=w.union([eh,em,ef,ev,eS]),ey=w.object({role:F,content:eb}),e_=h.extend({description:w.string().optional(),messages:w.array(ey)}),ew=p.extend({method:w.literal("notifications/prompts/list_changed"),params:d.optional()}),eR=w.object({title:w.string().optional(),readOnlyHint:w.boolean().optional(),destructiveHint:w.boolean().optional(),idempotentHint:w.boolean().optional(),openWorldHint:w.boolean().optional()}),eC=w.object({taskSupport:w.enum(["required","optional","forbidden"]).optional()}),ek=w.object({...y.shape,...b.shape,description:w.string().optional(),inputSchema:w.object({type:w.literal("object"),properties:w.record(w.string(),e).optional(),required:w.array(w.string()).optional()}).catchall(w.unknown()),outputSchema:w.object({type:w.literal("object"),properties:w.record(w.string(),e).optional(),required:w.array(w.string()).optional()}).catchall(w.unknown()).optional(),annotations:eR.optional(),execution:eC.optional(),_meta:w.record(w.string(),w.unknown()).optional()}),ex=Z.extend({method:w.literal("tools/list")}),eT=U.extend({tools:w.array(ek)}),eE=h.extend({content:w.array(eb),structuredContent:w.record(w.string(),w.unknown()).optional(),isError:w.boolean().optional()}),eI=c.extend({name:w.string(),arguments:w.record(w.string(),w.unknown()).optional()}),eP=u.extend({method:w.literal("tools/call"),params:eI}),eq=p.extend({method:w.literal("notifications/tools/list_changed"),params:d.optional()}),ej=w.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),eO=l.extend({level:ej}),e$=u.extend({method:w.literal("logging/setLevel"),params:eO}),eM=d.extend({level:ej,logger:w.string().optional(),data:w.unknown()}),eN=p.extend({method:w.literal("notifications/message"),params:eM}),eL=w.object({name:w.string().optional()}),eA=w.object({hints:w.array(eL).optional(),costPriority:w.number().min(0).max(1).optional(),speedPriority:w.number().min(0).max(1).optional(),intelligencePriority:w.number().min(0).max(1).optional()}),eZ=w.object({mode:w.enum(["auto","required","none"]).optional()}),eU=w.object({type:w.literal("tool_result"),toolUseId:w.string().describe("The unique identifier for the corresponding tool call."),content:w.array(eb),structuredContent:w.object({}).loose().optional(),isError:w.boolean().optional(),_meta:w.record(w.string(),w.unknown()).optional()}),ez=w.discriminatedUnion("type",[eh,em,ef]),eD=w.discriminatedUnion("type",[eh,em,ef,eg,eU]),eV=w.object({role:F,content:w.union([eD,w.array(eD)]),_meta:w.record(w.string(),w.unknown()).optional()}),eH=c.extend({messages:w.array(eV),modelPreferences:eA.optional(),systemPrompt:w.string().optional(),includeContext:w.enum(["none","thisServer","allServers"]).optional(),temperature:w.number().optional(),maxTokens:w.number().int(),stopSequences:w.array(w.string()).optional(),metadata:o.optional(),tools:w.array(ek).optional(),toolChoice:eZ.optional()}),eF=u.extend({method:w.literal("sampling/createMessage"),params:eH}),eW=h.extend({model:w.string(),stopReason:w.optional(w.enum(["endTurn","stopSequence","maxTokens"]).or(w.string())),role:F,content:ez}),eB=h.extend({model:w.string(),stopReason:w.optional(w.enum(["endTurn","stopSequence","maxTokens","toolUse"]).or(w.string())),role:F,content:w.union([eD,w.array(eD)])}),eJ=w.object({type:w.literal("boolean"),title:w.string().optional(),description:w.string().optional(),default:w.boolean().optional()}),eG=w.object({type:w.literal("string"),title:w.string().optional(),description:w.string().optional(),minLength:w.number().optional(),maxLength:w.number().optional(),format:w.enum(["email","uri","date","date-time"]).optional(),default:w.string().optional()}),eK=w.object({type:w.enum(["number","integer"]),title:w.string().optional(),description:w.string().optional(),minimum:w.number().optional(),maximum:w.number().optional(),default:w.number().optional()}),eX=w.object({type:w.literal("string"),title:w.string().optional(),description:w.string().optional(),enum:w.array(w.string()),default:w.string().optional()}),eY=w.object({type:w.literal("string"),title:w.string().optional(),description:w.string().optional(),oneOf:w.array(w.object({const:w.string(),title:w.string()})),default:w.string().optional()}),eQ=w.object({type:w.literal("string"),title:w.string().optional(),description:w.string().optional(),enum:w.array(w.string()),enumNames:w.array(w.string()).optional(),default:w.string().optional()}),e0=w.union([eX,eY]),e1=w.object({type:w.literal("array"),title:w.string().optional(),description:w.string().optional(),minItems:w.number().optional(),maxItems:w.number().optional(),items:w.object({type:w.literal("string"),enum:w.array(w.string())}),default:w.array(w.string()).optional()}),e2=w.object({type:w.literal("array"),title:w.string().optional(),description:w.string().optional(),minItems:w.number().optional(),maxItems:w.number().optional(),items:w.object({anyOf:w.array(w.object({const:w.string(),title:w.string()}))}),default:w.array(w.string()).optional()}),e4=w.union([e1,e2]),e9=w.union([eQ,e0,e4]),e6=w.union([e9,eJ,eG,eK]),e3=c.extend({mode:w.literal("form").optional(),message:w.string(),requestedSchema:w.object({type:w.literal("object"),properties:w.record(w.string(),e6),required:w.array(w.string()).optional()}).catchall(w.unknown())}),e5=c.extend({mode:w.literal("url"),message:w.string(),elicitationId:w.string(),url:w.string().url()}),e8=w.union([e3,e5]),e7=u.extend({method:w.literal("elicitation/create"),params:e8}),te=d.extend({elicitationId:w.string()}),tt=p.extend({method:w.literal("notifications/elicitation/complete"),params:te}),to=h.extend({action:w.enum(["accept","decline","cancel"]),content:w.preprocess(e=>null===e?void 0:e,w.record(w.string(),w.union([w.string(),w.number(),w.boolean(),w.array(w.string())])).optional())}),tr=w.object({type:w.literal("ref/resource"),uri:w.string()}),ti=w.object({type:w.literal("ref/prompt"),name:w.string()}),tn=l.extend({ref:w.union([ti,tr]),argument:w.object({name:w.string(),value:w.string()}),context:w.object({arguments:w.record(w.string(),w.string()).optional()}).optional()}),ta=u.extend({method:w.literal("completion/complete"),params:tn}),ts=h.extend({completion:w.looseObject({values:w.array(w.string()).max(100),total:w.optional(w.number().int()),hasMore:w.optional(w.boolean())})}),tl=w.object({uri:w.string().startsWith("file://"),name:w.string().optional(),_meta:w.record(w.string(),w.unknown()).optional()}),tc=u.extend({method:w.literal("roots/list"),params:l.optional()}),tu=h.extend({roots:w.array(tl)}),td=p.extend({method:w.literal("notifications/roots/list_changed"),params:d.optional()}),tp=w.looseObject({ttl:w.number().optional(),pollInterval:w.number().optional()}),th=w.enum(["working","input_required","completed","failed","cancelled"]),tm=w.object({taskId:w.string(),status:th,ttl:w.union([w.number(),w.null()]),createdAt:w.string(),lastUpdatedAt:w.string(),pollInterval:w.optional(w.number()),statusMessage:w.optional(w.string())}),tf=h.extend({task:tm}),tg=d.merge(tm),tS=p.extend({method:w.literal("notifications/tasks/status"),params:tg}),tv=u.extend({method:w.literal("tasks/get"),params:l.extend({taskId:w.string()})}),tb=h.merge(tm),ty=u.extend({method:w.literal("tasks/result"),params:l.extend({taskId:w.string()})}),t_=h.loose(),tw=Z.extend({method:w.literal("tasks/list")}),tR=U.extend({tasks:w.array(tm)}),tC=u.extend({method:w.literal("tasks/cancel"),params:l.extend({taskId:w.string()})}),{JSONValueSchema:e,JSONObjectSchema:o,ProgressTokenSchema:r,CursorSchema:i,TaskMetadataSchema:n,RelatedTaskMetadataSchema:a,RequestMetaSchema:s,BaseRequestParam
1sSchema:l,TaskAugmentedRequestParamsSchema:c,RequestSchema:u,NotificationsParamsSchema:d,NotificationSchema:p,ResultSchema:h,RequestIdSchema:m,EmptyResultSchema:f,CancelledNotificationParamsSchema:g,CancelledNotificationSchema:S,IconSchema:v,IconsSchema:b,BaseMetadataSchema:y,ImplementationSchema:_,ClientTasksCapabilitySchema:x,ServerTasksCapabilitySchema:T,ClientCapabilitiesSchema:E,InitializeRequestParamsSchema:I,InitializeRequestSchema:P,ServerCapabilitiesSchema:q,InitializeResultSchema:j,InitializedNotificationSchema:O,PingRequestSchema:$,ProgressSchema:M,ProgressNotificationParamsSchema:N,ProgressNotificationSchema:L,PaginatedRequestParamsSchema:A,PaginatedRequestSchema:Z,PaginatedResultSchema:U,ResourceContentsSchema:z,TextResourceContentsSchema:D,BlobResourceContentsSchema:H,RoleSchema:F,AnnotationsSchema:W,ResourceSchema:B,ResourceTemplateSchema:J,ListResourcesRequestSchema:G,ListResourcesResultSchema:K,ListResourceTemplatesRequestSchema:X,ListResourceTemplatesResultSchema:Y,ResourceRequestParamsSchema:Q,ReadResourceRequestParam
1sSchema:Q,ReadResourceRequestSchema:ee,ReadResourceResultSchema:et,ResourceListChangedNotificationSchema:eo,SubscribeRequestParamsSchema:Q,SubscribeRequestSchema:er,UnsubscribeRequestParamsSchema:Q,UnsubscribeRequestSchema:ei,ResourceUpdatedNotificationParamsSchema:en,ResourceUpdatedNotificationSchema:ea,PromptArgumentSchema:es,PromptSchema:el,ListPromptsRequestSchema:ec,ListPromptsResultSchema:eu,GetPromptRequestParamsSchema:ed,GetPromptRequestSchema:ep,TextContentSchema:eh,ImageContentSchema:em,AudioContentSchema:ef,ToolUseContentSchema:eg,EmbeddedResourceSchema:eS,ResourceLinkSchema:ev,ContentBlockSchema:eb,PromptMessageSchema:ey,GetPromptResultSchema:e_,PromptListChangedNotificationSchema:ew,ToolAnnotationsSchema:eR,ToolExecutionSchema:eC,ToolSchema:ek,ListToolsRequestSchema:ex,ListToolsResultSchema:eT,CallToolResultSchema:eE,CallToolRequestParamsSchema:eI,CallToolRequestSchema:eP,ToolListChangedNotificationSchema:eq,LoggingLevelSchema:ej,SetLevelRequestParamsSchema:eO,SetLevelRequestSchema:e$,LoggingMessageNotificationParamsSchema:eM,LoggingMessageNotificationSchema:eN,ModelHintSchema:eL,ModelPreferencesSchema:eA,ToolChoiceSchema:eZ,ToolResultContentSchema:eU,SamplingContentSchema:ez,SamplingMessageContentBlockSchema:eD,SamplingMessageSchema:eV,CreateMessageRequestParam
1sSchema:eH,CreateMessageRequestSchema:eF,CreateMessageResultSchema:eW,CreateMessageResultWithToolsSchema:eB,BooleanSchemaSchema:eJ,StringSchemaSchema:eG,NumberSchemaSchema:eK,UntitledSingleSelectEnumSchemaSchema:eX,TitledSingleSelectEnumSchemaSchema:eY,LegacyTitledEnumSchemaSchema:eQ,SingleSelectEnumSchemaSchema:e0,UntitledMultiSelectEnumSchemaSchema:e1,TitledMultiSelectEnumSchemaSchema:e2,MultiSelectEnumSchemaSchema:e4,EnumSchemaSchema:e9,PrimitiveSchemaDefinitionSchema:e6,ElicitRequestFormParamsSchema:e3,ElicitRequestURLParamsSchema:e5,ElicitRequestParamsSchema:e8,ElicitRequestSchema:e7,ElicitationCompleteNotificationParamsSchema:te,ElicitationCompleteNotificationSchema:tt,ElicitResultSchema:to,ResourceTemplateReferenceSchema:tr,PromptReferenceSchema:ti,CompleteRequestParamsSchema:tn,CompleteRequestSchema:ta,CompleteResultSchema:ts,RootSchema:tl,ListRootsRequestSchema:tc,ListRootsResultSchema:tu,RootsListChangedNotificationSchema:td,TaskCreationParamsSchema:tp,TaskStatusSchema:th,TaskSchema:tm,CreateTaskResultSchema:tf,TaskStatusNotificationParamsSchema:tg,TaskStatusNotificationSchema:tS,GetTaskRequestSchema:tv,GetTaskResultSchema:tb,GetTaskPayloadRequestSchema:ty,GetTaskPayloadResultSchema:t_,ListTasksRequestSchema:tw,ListTasksResultSchema:tR,CancelTaskRequestSchema:tC,CancelTaskResultSchema:h.merge(tm),ClientRequestSchema:w.union([$,P,ta,e$,ep,ec,G,X,ee,er,ei,eP,ex,tv,ty,tw,tC]),ClientNotificationSchema:w.union([S,L,O,td,tS]),ClientResultSchema:w.union([f,eW,eB,to,tu,tb,tR,tf]),ServerRequestSchema:w.union([$,eF,e7,tc,tv,ty,tw,tC]),ServerNotificationSchema:w.union([S,L,eN,ea,eo,eq,ew,tS,tt]),ServerResultSchema:w.union([f,j,ts,e_,eu,K,Y,et,eE,eT,tb,tR,tf]),CallToolResultWireSchema:w.unknown().superRefine((e,t)=>{if(!("object"!=typeof e||null===e||Array.isArray(e))&&void 0===e.content){for(let o of oY)if(o in e)return void t.addIssue({code:"custom",message:`content is required when the body carries '${o}' — another result family cannot default into an empty tools/call success`})}}).transform(oQ).pipe(eE)})}function o1(e){return"object"!==e.type}let o2=new Set(["const","enum","default","examples"]),o4=new Set(["properties","patternProperties","$defs","definitions","dependentSchemas","dependencies"]);function o9(e){return void 0!==e&&!("string"==typeof e&&e.startsWith("#"))}let o6={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"tasks/get":null,"tasks/result":null,"tasks/list":null,"tasks/cancel":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null},o3={"notifications/cancelled":null,"notifications/progress":null,"notifications/initialized":null,"notifications/roots/list_changed":null,"notifications/tasks/status":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/elicitation/complete":null},o5={ping:null,initialize:null,"completion/complete":null,"logging/setLevel":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"resources/subscribe":null,"resources/unsubscribe":null,"tools/call":null,"tools/list":null,"sampling/createMessage":null,"elicitation/create":null,"roots/list":null};function o8(){if(o)return o;let e=o0();return o={requestSchemas:{ping:e.PingRequestSchema,initialize:e.InitializeRequestSchema,"completion/complete":e.CompleteRequestSchema,"logging/setLevel":e.SetLevelRequestSchema,"prompts/get":e.GetPromptRequestSchema,"prompts/list":e.ListPromptsRequestSchema,"resources/list":e.ListResourcesRequestSchema,"resources/templates/list":e.ListResourceTemplatesRequestSchema,"resources/read":e.ReadResourceRequestSchema,"resources/subscribe":e.SubscribeRequestSchema,"resources/unsubscribe":e.UnsubscribeRequestSchema,"tools/call":e.CallToolRequestSchema,"tools/list":e.ListToolsRequestSchema,"tasks/get":e.GetTaskRequestSchema,"tasks/result":e.GetTaskPayloadRequestSchema,"tasks/list":e.ListTasksRequestSchema,"tasks/cancel":e.CancelTaskRequestSchema,"sampling/createMessage":e.CreateMessageRequestSchema,"elicitation/create":e.ElicitRequestSchema,"roots/list":e.ListRootsRequestSchema},notificationSchemas:{"notifications/cancelled":e.CancelledNotificationSchema,"notifications/progress":e.ProgressNotificationSchema,"notifications/initialized":e.InitializedNotificationSchema,"notifications/roots/list_changed":e.RootsListChangedNotificationSchema,"notifications/tasks/status":e.TaskStatusNotificationSchema,"notifications/message":e.LoggingMessageNotificationSchema,"notifications/resources/updated":e.ResourceUpdatedNotificationSchema,"notifications/resources/list_changed":e.ResourceListChangedNotificationSchema,"notifications/tools/list_changed":e.ToolListChangedNotificationSchema,"notifications/prompts/list_changed":e.PromptListChangedNotificationSchema,"notifications/elicitation/complete":e.ElicitationCompleteNotificationSchema},resultSchemas:{ping:e.EmptyResultSchema,initialize:e.InitializeResultSchema,"completion/complete":e.CompleteResultSchema,"logging/setLevel":e.EmptyResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"resources/sub
1scribe":e.EmptyResultSchema,"resources/unsubscribe":e.EmptyResultSchema,"tools/call":e.CallToolResultWireSchema,"tools/list":e.ListToolsResultSchema,"sampling/createMessage":e.CreateMessageResultWithToolsSchema,"elicitation/create":e.ElicitResultSchema,"roots/list":e.ListRootsResultSchema}}}function o7(e){return Object.prototype.hasOwnProperty.call(o6,e)}function re(e){return Object.prototype.hasOwnProperty.call(o3,e)}function rt(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function ro(e,t){if(void 0===e)return{ok:!1,reason:"not-in-era"};let o=e.safeParse(t);return o.success?{ok:!0,value:o.data}:{ok:!1,reason:"invalid",message:String(o.error)}}Object.keys(o6),Object.keys(o3);let rr={ok:!1,reason:"not-in-era"};function ri(e){return rt(e)&&rt(e.outputSchema)&&o1(e.outputSchema)}let rn={era:"2025-11-25",hasRequestMethod:o7,hasNotificationMethod:re,validateRequest:(e,t)=>ro(o7(e)?o8().requestSchemas[e]:void 0,t),validateResult:(e,t)=>ro(Object.prototype.hasOwnProperty.call(o5,e)?o8().resultSchemas[e]:void 0,t),validateNotification:(e,t)=>ro(re(e)?o8().notificationSchemas[e]:void 0,t),hasInputRequestMethod:()=>!1,validateInputRequest:()=>rr,validateInputResponse:()=>rr,samplingResultVariant:(e,t)=>{let o=o0();return ro(e?o.CreateMessageResultWithToolsSchema:o.CreateMessageResultSchema,t)},outboundEnvelope:e=>void 0,validateEnvelopeMeta:e=>[],projectCallToolResult(e,t){let o=oX(e),r=o.structuredContent;if(void 0===r)return o;let i="object"!=typeof r||null===r||Array.isArray(r),n=void 0!==t&&o1(t);return i||n?{...o,structuredContent:{result:r}}:o},decodeResult(e,t){if(rt(t)&&"resultType"in t){let e={...t};return delete e.resultType,{kind:"complete",result:e}}return{kind:"complete",result:t}},encodeResult(e,t){if("tools/list"!==e)return t;let o=t.tools;return Array.isArray(o)&&o.some(e=>ri(e))?{...t,tools:o.map(e=>ri(e)?{...e,outputSchema:function(e){var t;let o="string"==typeof e.$schema?e.$schema:void 0;if(o9(e.$id))return{...void 0!==o&&{$schema:o},type:"object",properties:{result:e},required:["result"]};let r="string"==typeof(t=e.$schema)&&v.has(t.replace(/#$/,""))&&!0!==e.$recursiveAnchor,i=(e,t)=>{if(Array.isArray(e))return e.map(e=>i(e,!1));if(null===e||"object"!=typeof e||!t&&o9(e.$id))return e;let o={},n=!1;for(let[a,s]of Object.entries(e))t?o[a]=i(s,!1):("$ref"===a||"$dynamicRef"===a)&&"string"==typeof s?o[a]="#"===s?"#/properties/result":s.startsWith("#/")?`#/properties/result${s.slice(1)}`:s:"$recursiveRef"===a&&"#"===s&&r?n=!0:o2.has(a)?o[a]=s:o4.has(a)?o[a]=i(s,!0):o[a]=i(s,!1);return n&&("$ref"in o?o.allOf=[...Array.isArray(o.allOf)?o.allOf:[],{$ref:"#/properties/result"}]:o.$ref="#/properties/result"),o};return{...void 0!==o&&{$schema:o},type:"object",properties:{result:i(e,!1)},required:["result"]}}(e.outputSchema)}:e)}:t},encodeErrorCode:e=>-32002===e?-32602:e,checkInboundEnvelope:e=>void 0};function ra(){return r??=function(){let e=w.lazy(()=>w.union([w.string(),w.number(),w.boolean(),w.null(),w.record(w.string(),e),w.array(e)])),t=w.record(w.string(),e),o=w.union([w.string(),w.number().int()]),r=w.string(),i=w.union([w.string(),w.number().int()]),n=w.enum(["user","assistant"]),a=w.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),s=w.string().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),l=w.object({ttl:w.number().optional()}),c=w.object({taskId:w.string()}),u=w.looseObject({progressToken:o.optional(),"io.modelcontextprotocol/related-task":c.optional()}),d=w.object({_meta:u.optional()}),p=d.extend({task:l.optional()}),h=w.object({_meta:u.optional()}),m=w.object({method:w.string(),params:h.loose().optional()}),f=w.object({src:w.string(),mimeType:w.string().optional(),sizes:w.array(w.string()).optional(),theme:w.enum(["light","dark"]).optional()}),g=w.object({icons:w.array(f).optional()}),S=w.object({name:w.string(),title:w.string().optional()}),v=S.extend({...S.shape,...g.shape,version:w.string(),websiteUrl:w.string().optional(),description:w.string().optional()}),b=w.intersection(w.object({applyDefaults:w.boolean().optional()}),t),y=w.preprocess(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,w.intersection(w.object({form:b.optional(),url:t.optional()}),t.optional())),_=w.looseObject({list:t.optional(),cancel:t.optional(),requests:w.looseObject({sampling:w.looseObject({createMessage:t.optional()}).optional(),elicitation:w.looseObject({create:t.optional()}).optional()}).optional()}),C=w.looseObject({list:t.optional(),cancel:t.optional(),requests:w.looseObject({tools:w.looseObject({call:t.optional()}).optional()}).optional()}),k=w.object({experimental:w.record(w.string(),t).optional(),sampling:w.object({context:t.optional(),tools:t.optional()}).optional(),elicitation:y.optional(),roots:w.object({listChanged:w.boolean().optional()}).optional(),tasks:_.optional(),extensions:w.record(w.string(),t).optional()}),x=w.object({experimental:w.record(w.string(),t).optional(),logging:t.optional(),completions:t.optional(),prompts:w.object({listChanged:w.boolean().optional()}).optional(),resources:w.object({subscribe:w.boolean().optional(),listChanged:w.boolean().optional()}).optional(),tools:w.object({listChanged:w.boolean().optional()}).optional(),tasks:C.optional(),extensions:w.record(w.string(),t).optional()}),T=w.object({progress:w.number(),total:w.optional(w.number()),message:w.optional(w.string())}),E=w.object({...h.shape,...T.shape,progressToken:o}),I=m.extend({method:w.literal("notifications/progress"),params:E}),$=h.extend({level:a,logger:w.string().optional(),data:w.unknown()}),N=m.extend({method:w.literal("notifications/message"),params:$}),L=w.object({uri:w.string(),mimeType:w.optional(w.string()),_meta:w.record(w.string(),w.unknown()).optional()}),A=L.extend({text:w.string()}),Z=L.extend({blob:s}
1),U=w.object({audience:w.array(n).optional(),priority:w.number().min(0).max(1).optional(),lastModified:R.datetime({offset:!0}).optional()}),z=w.object({...S.shape,...g.shape,uri:w.string(),description:w.optional(w.string()),mimeType:w.optional(w.string()),size:w.optional(w.number()),annotations:U.optional(),_meta:w.optional(w.looseObject({}))}),D=w.object({...S.shape,...g.shape,uriTemplate:w.string(),description:w.optional(w.string()),mimeType:w.optional(w.string()),annotations:U.optional(),_meta:w.optional(w.looseObject({}))}),V=m.extend({method:w.literal("notifications/resources/list_changed"),params:h.optional()}),H=h.extend({uri:w.string()}),F=m.extend({method:w.literal("notifications/resources/updated"),params:H}),W=w.object({name:w.string(),description:w.optional(w.string()),required:w.optional(w.boolean())}),B=w.object({...S.shape,...g.shape,description:w.optional(w.string()),arguments:w.optional(w.array(W)),_meta:w.optional(w.looseObject({}))}),J=m.extend({method:w.literal("notifications/prompts/list_changed"),params:h.optional()}),G=w.object({type:w.literal("text"),text:w.string(),annotations:U.optional(),_meta:w.record(w.string(),w.unknown()).optional()}),K=w.object({type:w.literal("image"),data:s,mimeType:w.string(),annotations:U.optional(),_meta:w.record(w.string(),w.unknown()).optional()}),X=w.object({type:w.literal("audio"),data:s,mimeType:w.string(),annotations:U.optional(),_meta:w.record(w.string(),w.unknown()).optional()}),Y=w.object({type:w.literal("tool_use"),name:w.string(),id:w.string(),input:w.record(w.string(),w.unknown()),_meta:w.record(w.string(),w.unknown()).optional()}),Q=w.object({type:w.literal("resource"),resource:w.union([A,Z]),annotations:U.optional(),_meta:w.record(w.string(),w.unknown()).optional()}),ee=z.extend({type:w.literal("resource_link")}),et=w.union([G,K,X,ee,Q]),eo=w.object({role:n,content:et}),er=w.object({title:w.string().optional(),readOnlyHint:w.boolean().optional(),destructiveHint:w.boolean().optional(),idempotentHint:w.boolean().optional(),openWorldHint:w.boolean().optional()}),ei=m.extend({method:w.literal("notifications/tools/list_changed"),params:h.optional()}),en=w.object({name:w.string().optional()}),ea=w.object({hints:w.array(en).optional(),costPriority:w.number().min(0).max(1).optional(),speedPriority:w.number().min(0).max(1).optional(),intelligencePriority:w.number().min(0).max(1).optional()}),es=w.object({mode:w.enum(["auto","required","none"]).optional()}),el=w.object({type:w.literal("boolean"),title:w.string().optional(),description:w.string().optional(),default:w.boolean().optional()}),ec=w.object({type:w.literal("string"),title:w.string().optional(),description:w.string().optional(),minLength:w.number().optional(),maxLength:w.number().optional(),format:w.enum(["email","uri","date","date-time"]).optional(),default:w.string().optional()}),eu=w.object({type:w.enum(["number","integer"]),title:w.string().optional(),description:w.string().optional(),minimum:w.number().optional(),maximum:w.number().optional(),default:w.number().optional()}),ed=w.object({type:w.literal("string"),title:w.string().optional(),description:w.string().optional(),enum:w.array(w.string()),default:w.string().optional()}),ep=w.object({type:w.literal("string"),title:w.string().optional(),description:w.string().optional(),oneOf:w.array(w.object({const:w.string(),title:w.string()})),default:w.string().optional()}),eh=w.object({type:w.literal("string"),title:w.string().optional(),description:w.string().optional(),enum:w.array(w.string()),enumNames:w.array(w.string()).optional(),default:w.string().optional()}),em=w.union([ed,ep]),ef=w.object({type:w.literal("array"),title:w.string().optional(),description:w.string().optional(),minItems:w.number().optional(),maxItems:w.number().optional(),items:w.object({type:w.literal("string"),enum:w.array(w.string())}),default:w.array(w.string()).optional()}),eg=w.object({type:w.literal("array"),title:w.string().optional(),description:w.string().optional(),minItems:w.number().optional(),maxItems:w.number().optional(),items:w.object({anyOf:w.array(w.object({const:w.string(),title:w.string()}))}),default:w.array(w.string()).optional()}),eS=w.union([ef,eg]),ev=w.union([eh,em,eS]),eb=w.union([ev,el,ec,eu]),ey=p.extend({mode:w.literal("form").optional(),message:w.string(),requestedSchema:w.object({type:w.literal("object"),properties:w.record(w.string(),eb),required:w.array(w.string()).optional()}).catchall(w.unknown())}),e_=w.object({type:w.literal("ref/resource"),uri:w.string()}),ew=w.object({type:w.literal("ref/prompt"),name:w.string()}),eR=w.object({uri:w.string().startsWith("file://"),name:w.string().optional(),_meta:w.record(w.string(),w.unknown()).optional()}),eC=k.shape,ek=w.object({experimental:eC.experimental,sampling:eC.sampling,elicitation:eC.elicitation,roots:eC.roots,extensions:eC.extensions}),ex=x.shape,eT=w.object({experimental:ex.experimental,logging:ex.logging,completions:ex.completions,prompts:ex.prompts,resources:ex.resources,tools:ex.tools,extensions:ex.extensions}),eE=w.looseObject({progressToken:o.optional(),[P]:w.string(),[q]:v.optional(),[O]:ek,[M]:a.optional()}),eI=w.object({...S.shape,...g.shape,description:w.string().optional(),inputSchema:w.looseObject({$schema:w.string().optional(),type:w.literal("object")}
1),outputSchema:w.looseObject({$schema:w.string().optional()}).optional(),annotations:er.optional(),_meta:w.record(w.string(),w.unknown()).optional()}),eP=w.object({type:w.literal("tool_result"),toolUseId:w.string(),content:w.array(et),structuredContent:w.unknown().optional(),isError:w.boolean().optional(),_meta:w.record(w.string(),w.unknown()).optional()}),eq=w.union([G,K,X,Y,eP]),ej=w.object({role:n,content:w.union([eq,w.array(eq)]),_meta:w.record(w.string(),w.unknown()).optional()}),eO=w.string(),e$=w.looseObject({[j]:v.optional().catch(void 0)}),eM=e$.optional();function eN(e){return w.looseObject({_meta:eM,resultType:eO.default("complete"),...e})}let eL=eN({}),eA=eN({nextCursor:r.optional()}),eZ=eN({content:w.array(et),structuredContent:w.unknown().optional(),isError:w.boolean().optional()}),eU=eN({ttlMs:w.number().int().min(0),cacheScope:w.enum(["public","private"]),tools:w.array(eI),nextCursor:r.optional()}),ez=eN({ttlMs:w.number().int().min(0),cacheScope:w.enum(["public","private"]),prompts:w.array(B),nextCursor:r.optional()}),eD=eN({description:w.string().optional(),messages:w.array(eo)}),eV=eN({ttlMs:w.number().int().min(0),cacheScope:w.enum(["public","private"]),resources:w.array(z),nextCursor:r.optional()}),eH=eN({ttlMs:w.number().int().min(0),cacheScope:w.enum(["public","private"]),resourceTemplates:w.array(D),nextCursor:r.optional()}),eF=eN({ttlMs:w.number().int().min(0),cacheScope:w.enum(["public","private"]),contents:w.array(w.union([A,Z]))}),eW=eN({completion:w.object({values:w.array(w.string()).max(100),total:w.number().int().optional(),hasMore:w.boolean().optional()}).loose()}),eB=eN({ttlMs:w.number().int().min(0),cacheScope:w.enum(["public","private"])}),eJ=eN({ttlMs:w.number().int().min(0).catch(0),cacheScope:w.enum(["public","private"]).catch("private"),supportedVersions:w.array(w.string()),capabilities:eT,instructions:w.string().optional()}),eG=w.object({messages:w.array(ej),modelPreferences:ea.optional(),systemPrompt:w.string().optional(),includeContext:w.enum(["none","thisServer","allServers"]).optional(),temperature:w.number().optional(),maxTokens:w.number().int(),stopSequences:w.array(w.string()).optional(),metadata:t.optional(),tools:w.array(eI).optional(),toolChoice:es.optional()}),eK=w.object({method:w.literal("sampling/createMessage"),params:eG}),eX=w.object({method:w.literal("roots/list"),params:w.object({_meta:w.record(w.string(),w.unknown()).optional()}).optional()}),eY=w.object({...ej.shape,model:w.string(),stopReason:w.string().optional()}),eQ=w.object({roots:w.array(eR)}),e0=w.object({action:w.enum(["accept","decline","cancel"]),content:w.record(w.string(),w.union([w.string(),w.number(),w.boolean(),w.array(w.string())])).optional()}),e1=w.object({mode:w.literal("url"),message:w.string(),url:w.string().url()}),e2=w.union([ey,e1]),e4=w.object({method:w.literal("elicitation/create"),params:e2}),e9=w.union([eK,eX,e4]),e6=w.union([eY,eQ,e0]),e3=w.record(w.string(),e9),e5=w.record(w.string(),e6),e8=eN({inputRequests:e3.optional(),requestState:w.string().optional()}),e7={inputResponses:e5.optional(),requestState:w.string().optional()},te=w.object({_meta:eE,...e7}),tt=w.looseObject({progressToken:o.optional()});function to(e,t){return w.object({method:w.literal(e),params:w.object({_meta:eE,...t})})}function tr(e,t){return w.object({method:w.literal(e),params:w.object({_meta:tt.optional(),...t}).optional()})}let ti={name:w.string(),arguments:w.record(w.string(),w.unknown()).optional(),...e7},tn={cursor:r.optional()},ta=to("tools/call",ti),ts=to("tools/list",tn),tl=to("prompts/list",tn),tc=to("prompts/get",{name:w.string(),arguments:w.record(w.string(),w.string()).optional(),...e7}),tu=to("resources/list",tn),td=to("resources/templates/list",tn),tp=to("resources/read",{uri:w.string(),...e7}),th={ref:w.union([ew,e_]),argument:w.object({name:w.string(),value:w.string()}),context:w.object({arguments:w.record(w.string(),w.string()).optional()}).optional()},tm=to("completion/complete",th),tf=to("server/discover",{}),tg=w.object({toolsListChanged:w.boolean().optional(),promptsListChanged:w.boolean().optional(),resourcesListChanged:w.boolean().optional(),resourceSubscriptions:w.array(w.string()).optional()}),tS={notifications:tg},tv=to("subscriptions/listen",tS),tb=e$.extend({"io.modelcontextprotocol/subscriptionId":i}
1),ty=w.looseObject({_meta:tb,resultType:eO.default("complete")}),t_={"tools/call":tr("tools/call",ti),"tools/list":tr("tools/list",tn),"prompts/get":tr("prompts/get",{name:w.string(),arguments:w.record(w.string(),w.string()).optional()}),"prompts/list":tr("prompts/list",tn),"resources/list":tr("resources/list",tn),"resources/templates/list":tr("resources/templates/list",tn),"resources/read":tr("resources/read",{uri:w.string()}),"completion/complete":tr("completion/complete",th),"server/discover":tr("server/discover",{}),"subscriptions/listen":tr("subscriptions/listen",tS)};function tw(e){return w.looseObject({_meta:eM,...e})}let tR={"tools/call":tw({content:w.array(et),structuredContent:w.unknown().optional(),isError:w.boolean().optional()}),"tools/list":tw({ttlMs:w.number().int().min(0),cacheScope:w.enum(["public","private"]),tools:w.array(eI),nextCursor:r.optional()}),"prompts/get":tw({description:w.string().optional(),messages:w.array(eo)}),"prompts/list":tw({ttlMs:w.number().int().min(0),cacheScope:w.enum(["public","private"]),prompts:w.array(B),nextCursor:r.optional()}),"resources/list":tw({ttlMs:w.number().int().min(0),cacheScope:w.enum(["public","private"]),resources:w.array(z),nextCursor:r.optional()}),"resources/templates/list":tw({ttlMs:w.number().int().min(0),cacheScope:w.enum(["public","private"]),resourceTemplates:w.array(D),nextCursor:r.optional()}),"resources/read":tw({ttlMs:w.number().int().min(0),cacheScope:w.enum(["public","private"]),contents:w.array(w.union([A,Z]))}),"completion/complete":tw({completion:w.object({values:w.array(w.string()).max(100),total:w.number().int().optional(),hasMore:w.boolean().optional()}).loose()}),"server/discover":tw({ttlMs:w.number().int().min(0).catch(0),cacheScope:w.enum(["public","private"]).catch("private"),supportedVersions:w.array(w.string()),capabilities:eT,instructions:w.string().optional()}),"subscriptions/listen":tw({})},tC=w.looseObject({"io.modelcontextprotocol/subscriptionId":i.optional()}),tk=w.object({method:w.literal("notifications/subscriptions/acknowledged"),params:w.object({_meta:tC.optional(),notifications:tg})}),tx=w.object({_meta:tC.optional(),requestId:i,reason:w.string().optional()}),tT=w.object({method:w.literal("notifications/cancelled"),params:tx}),tE=e=>w.object({jsonrpc:w.literal("2.0"),id:w.union([w.string(),w.number().int()]),result:e}).strict();return{JSONValueSchema:e,JSONObjectSchema:t,ProgressTokenSchema:o,CursorSchema:r,RequestIdSchema:i,RoleSchema:n,LoggingLevelSchema:a,TaskMetadataSchema:l,RelatedTaskMetadataSchema:c,RequestMetaSchema:u,BaseRequestParam
1sSchema:d,TaskAugmentedRequestParamsSchema:p,NotificationsParamsSchema:h,NotificationSchema:m,IconSchema:f,IconsSchema:g,BaseMetadataSchema:S,ImplementationSchema:v,ClientTasksCapabilitySchema:_,ServerTasksCapabilitySchema:C,ClientCapabilitiesSchema:k,ServerCapabilitiesSchema:x,ProgressSchema:T,ProgressNotificationParamsSchema:E,ProgressNotificationSchema:I,LoggingMessageNotificationParamsSchema:$,LoggingMessageNotificationSchema:N,ResourceContentsSchema:L,TextResourceContentsSchema:A,BlobResourceContentsSchema:Z,AnnotationsSchema:U,ResourceSchema:z,ResourceTemplateSchema:D,ResourceListChangedNotificationSchema:V,ResourceUpdatedNotificationParamsSchema:H,ResourceUpdatedNotificationSchema:F,PromptArgumentSchema:W,PromptSchema:B,PromptListChangedNotificationSchema:J,TextContentSchema:G,ImageContentSchema:K,AudioContentSchema:X,ToolUseContentSchema:Y,EmbeddedResourceSchema:Q,ResourceLinkSchema:ee,ContentBlockSchema:et,PromptMessageSchema:eo,ToolAnnotationsSchema:er,ToolListChangedNotificationSchema:ei,ModelHintSchema:en,ModelPreferencesSchema:ea,ToolChoiceSchema:es,BooleanSchemaSchema:el,StringSchemaSchema:ec,NumberSchemaSchema:eu,UntitledSingleSelectEnumSchemaSchema:ed,TitledSingleSelectEnumSchemaSchema:ep,LegacyTitledEnumSchemaSchema:eh,SingleSelectEnumSchemaSchema:em,UntitledMultiSelectEnumSchemaSchema:ef,TitledMultiSelectEnumSchemaSchema:eg,MultiSelectEnumSchemaSchema:eS,EnumSchemaSchema:ev,PrimitiveSchemaDefinitionSchema:eb,ElicitRequestFormParamsSchema:ey,ResourceTemplateReferenceSchema:e_,PromptReferenceSchema:ew,RootSchema:eR,ClientCapabilities2026Schema:ek,ServerCapabilities2026Schema:eT,RequestMetaEnvelopeSchema:eE,ToolSchema:eI,ToolResultContentSchema:eP,SamplingMessageContentBlockSchema:eq,SamplingMessageSchema:ej,ResultTypeSchema:eO,ResultMetaSchema:e$,ResultSchema:eL,PaginatedResultSchema:eA,CallToolResultSchema:eZ,ListToolsResultSchema:eU,ListPromptsResultSchema:ez,GetPromptResultSchema:eD,ListResourcesResultSchema:eV,ListResourceTemplatesResultSchema:eH,ReadResourceResultSchema:eF,CompleteResultSchema:eW,CacheableResultSchema:eB,DiscoverResultSchema:eJ,CreateMessageRequestParam
1sSchema:eG,CreateMessageRequestSchema:eK,ListRootsRequestSchema:eX,CreateMessageResultSchema:eY,ListRootsResultSchema:eQ,ElicitResultSchema:e0,ElicitRequestURLParamsSchema:e1,ElicitRequestParamsSchema:e2,ElicitRequestSchema:e4,InputRequestSchema:e9,InputResponseSchema:e6,InputRequestsSchema:e3,InputResponsesSchema:e5,InputRequiredResultSchema:e8,InputResponseRequestParamsSchema:te,CallToolRequestSchema:ta,ListToolsRequestSchema:ts,ListPromptsRequestSchema:tl,GetPromptRequestSchema:tc,ListResourcesRequestSchema:tu,ListResourceTemplatesRequestSchema:td,ReadResourceRequestSchema:tp,CompleteRequestSchema:tm,DiscoverRequestSchema:tf,SubscriptionFilterSchema:tg,SubscriptionsListenRequestSchema:tv,SubscriptionsListenResultMetaSchema:tb,SubscriptionsListenResultSchema:ty,dispatchRequestSchemas:t_,dispatchResultSchemas:tR,NotificationMetaSchema:tC,SubscriptionsAcknowledgedNotificationSchema:tk,CancelledNotificationParamsSchema:tx,CancelledNotificationSchema:tT,notificationSchemas2026:{"notifications/cancelled":tT,"notifications/progress":I,"notifications/message":N,"notifications/resources/updated":F,"notifications/resources/list_changed":V,"notifications/tools/list_changed":ei,"notifications/prompts/list_changed":J,"notifications/subscriptions/acknowledged":tk},JSONRPCResultResponseSchema:tE(eL),CallToolResultResponseSchema:tE(w.union([eZ,e8])),ListToolsResultResponseSchema:tE(eU),ListPromptsResultResponseSchema:tE(ez),GetPromptResultResponseSchema:tE(w.union([eD,e8])),ListResourcesResultResponseSchema:tE(eV),ListResourceTemplatesResultResponseSchema:tE(eH),ReadResourceResultResponseSchema:tE(w.union([eF,e8])),CompleteResultResponseSchema:tE(eW),DiscoverResultResponseSchema:tE(eJ)}}()}let rs=["tools/list","prompts/list","resources/list","resources/templates/list","resources/read","server/discover"],rl=Symbol("modelcontextprotocol.resultCacheHintFallback");function rc(e){return"number"==typeof e&&Number.isSafeInteger(e)&&e>=0}function ru(e){return"public"===e||"private"===e}let rd=((ni={})[ni.ParseError=-32700]="ParseError",ni[ni.InvalidRequest=-32600]="InvalidRequest",ni[ni.MethodNotFound=-32601]="MethodNotFound",ni[ni.InvalidParams=-32602]="InvalidParams",ni[ni.InternalError=-32603]="InternalError",ni[ni.ResourceNotFound=-32002]="ResourceNotFound",ni[ni.MissingRequiredClientCapability=-32021]="MissingRequiredClientCapability",ni[ni.UnsupportedProtocolVersion=-32022]="UnsupportedProtocolVersion",ni[ni.UrlElicitationRequired=-32042]="UrlElicitationRequired",ni);var rp=class e extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ProtocolError"})}static[Symbol.hasInstance](e){return oA(this,e)}static isInstance(e){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return oA(this,e)}constructor(e,t,o){super(t),this.code=e,this.data=o,this.name="ProtocolError",oL(this,new.target)}static fromError(t,o,r){return t===rd.UrlElicitationRequired&&r&&r.elicitations?new rm(r.elicitations,o):t===rd.UnsupportedProtocolVersion&&r&&Array.isArray(r.supported)&&"string"==typeof r.requested?new rf({supported:r.supported,requested:r.requested},o):(t===rd.InvalidParams||t===rd.ResourceNotFound)&&"string"==typeof r?.uri&&(t===rd.ResourceNotFound||1===Object.keys(r).length)?new rh(r.uri,o):t===rd.MissingRequiredClientCapability&&r&&null!==r.requiredCapabilities&&"object"==typeof r.requiredCapabilities&&!Array.isArray(r.requiredCapabilities)?new rg({requiredCapabilities:r.requiredCapabilities},o):new e(t,o,r)}},rh=class extends rp{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.ResourceNotFoundError"})}constructor(e,t=`Resource not found: ${e}`){super(rd.InvalidParams,t,{uri:e})}get uri(){return this.data.uri}},rm=class extends rp{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UrlElicitationRequiredError"})}constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(rd.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}},rf=class extends rp{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnsupportedProtocolVersionError"})}constructor(e,t=`Unsupported protocol version: ${e.requested}`){super(rd.UnsupportedProtocolVersion,t,e)}get supported(){return this.data.supported}get requested(){return this.data.requested}},rg=class extends rp{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.MissingRequiredClientCapabilityError"})}constructor(e,t=`Missing required client capabilities: ${Object.keys(e.requiredCapabilities).join(", ")}`){super(rd.MissingRequiredClientCapability,t,e)}get requiredCapabilities(){return this.data.requiredCapabilities}};let rS=["tools/call","prompts/get","resources/read"],rv=["elicitation/create","sampling/createMessage","roots/list"];function rb(){if(i)return i;let e=ra();return i={request:{"elicitation/create":w.object({method:w.literal("elicitation/create"),params:e.ElicitRequestParam
1sSchema}),"sampling/createMessage":w.object({method:w.literal("sampling/createMessage"),params:e.CreateMessageRequestParamsSchema}),"roots/list":w.object({method:w.literal("roots/list"),params:w.looseObject({}).optional()})},response:{"elicitation/create":e.ElicitResultSchema,"sampling/createMessage":e.CreateMessageResultSchema,"roots/list":e.ListRootsResultSchema}}}function ry(e){return rv.includes(e)}function r_(e){return ry(e)?rb().request[e]:void 0}let rw={"tools/call":null,"tools/list":null,"prompts/get":null,"prompts/list":null,"resources/list":null,"resources/templates/list":null,"resources/read":null,"completion/complete":null,"server/discover":null,"subscriptions/listen":null},rR={"notifications/cancelled":null,"notifications/progress":null,"notifications/message":null,"notifications/resources/updated":null,"notifications/resources/list_changed":null,"notifications/tools/list_changed":null,"notifications/prompts/list_changed":null,"notifications/subscriptions/acknowledged":null};function rC(e){return Object.prototype.hasOwnProperty.call(rw,e)}function rk(e){return Object.prototype.hasOwnProperty.call(rR,e)}function rx(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function rT(e,t){if(void 0===e)return{ok:!1,reason:"not-in-era"};let o=e.safeParse(t);return o.success?{ok:!0,value:o.data}:{ok:!1,reason:"invalid",message:String(o.error)}}Object.keys(rw),Object.keys(rR);let rE={ok:!1,reason:"not-in-era"},rI=[P,O],rP={era:"2026-07-28",hasRequestMethod:rC,hasNotificationMethod:rk,hasInputRequestMethod:e=>void 0!==r_(e),validateRequest:(e,t)=>rT(rC(e)?ra().dispatchRequestSchemas[e]:void 0,t),validateResult:(e,t)=>rT(Object.prototype.hasOwnProperty.call(rw,e)?ra().dispatchResultSchemas[e]:void 0,t),validateNotification:(e,t)=>rT(rk(e)?ra().notificationSchemas2026[e]:void 0,t),validateInputRequest:(e,t)=>rT(r_(e),t),validateInputResponse:(e,t)=>rT(ry(e)?rb().response[e]:void 0,t),samplingResultVariant:()=>rE,outboundEnvelope:e=>({[P]:e.protocolVersion,[q]:e.clientInfo,[O]:e.clientCapabilities,...void 0!==e.logLevel&&{[M]:e.logLevel}}),validateEnvelopeMeta(e){let t=[];for(let o of rI)o in e||t.push({key:o,problem:"missing"});let o=ra().RequestMetaEnvelopeSchema.safeParse(e);if(!o.success)for(let e of o.error.issues){let o=e.path.map(String),r=o.length>0?o.join("."):"_meta";1===o.length&&t.some(e=>e.key===r&&"missing"===e.problem)||t.push({key:r,problem:e.message})}return t},projectCallToolResult:e=>oX(e),inputRequestSchema:r_,decodeResult(e,t){if(!rx(t))return{kind:"invalid",error:new oD(oz.InvalidResult,`Invalid result for ${e}: not an object`,{method:e})};let o=t.resultType;if(void 0===o)return{kind:"invalid",error:new oD(oz.InvalidResult,`Invalid result for ${e}: missing required resultType — servers implementing protocol revision 2026-07-28 MUST include it (the absent-means-complete bridge applies only to earlier-revision servers)`,{method:e,violation:"missing-resultType"})};if("string"!=typeof o)return{kind:"invalid",error:new oD(oz.InvalidResult,`Invalid result for ${e}: non-string resultType`,{method:e,resultType:o})};if("input_required"===o){let o=t.inputRequests,r=rx(o)?o:{},i=t.requestState;return 0===Object.keys(r).length&&"string"!=typeof i?{kind:"invalid",error:new oD(oz.InvalidResult,`Invalid result for ${e}: input_required carries neither inputRequests nor requestState (every input_required result must include at least one of the two)`,{method:e,violation:"input-required-missing-both"})}:{kind:"input_required",inputRequests:r,..."string"==typeof i&&{requestState:i}}}if("complete"!==o)return{kind:"invalid",error:new oD(oz.UnsupportedResultType,`Unsupported result type '${o}' for ${e}`,{resultType:o,method:e})};let r=rq(),i=Object.hasOwn(r,e)?r[e]:void 0;if(void 0!==i){let o=i.safeParse(t);if(!o.success)return{kind:"invalid",error:new oD(oz.InvalidResult,`Invalid result for ${e}: ${o.error}`,{method:e})}}let n={...t};return delete n.resultType,{kind:"complete",result:n}},encodeResult:(e,t,o)=>(function(e,t){if(void 0===t)return e;let o=e._meta;return void 0===o?{...e,_meta:{[j]:t}}:null===o||"object"!=typeof o||Array.isArray(o)||void 0!==o[j]?e:{...e,_meta:{...o,[j]:t}}})(function(e,t){var o,r;let i=t[rl];if("complete"!==t.resultType||!rs.includes(e)){let e;return void 0===i?t:(e={...t},delete e[rl],e)}let n=rc(t.ttlMs)?t.ttlMs:void 0!==(o=i)&&rc(o.ttlMs)?o.ttlMs:0,a=ru(t.cacheScope)?t.cacheScope:void 0!==(r=i)&&ru(r.cacheScope)?r.cacheScope:"private",s={...t,ttlMs:n,cacheScope:a};return delete s[rl],s}(e,function(e,t){let o=t.resultType;if(void 0===o)return{...t,resultType:"complete"};if("complete"===o||rS.includes(e))return t;throw new rp(rd.InternalError,`Handler for ${e} returned resultType '${String(o)}', but results of ${e} only support 'complete' on protocol revision 2026-07-28`)}(e,function(e,t){let o=t,r=!1,i=()=>(r||(o={...o},r=!0),o),n=t.tools;"tools/list"===e&&Array.isArray(n)&&n.some(e=>rx(e)&&"execution"in e)&&(i().tools=n.map(e=>{if(!rx(e)||!("execution"in e))return e;let t={...e};return delete t.execution,t}));let a=t.capabilities;if(rx(a)&&"tasks"in a){let e={...a};delete e.tasks,i().capabilities=e}return o}(e,t))),o),encodeErrorCode:e=>-32002===e?-32602:e,checkInboundEnvelope(e){if(void 0===e.envelope)return"Request is missing the required _meta envelope for protocol revision 2026-07-28 (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientCapabilities)";let t=ra().RequestMetaEnvelopeSchema.safeParse(e.envelope);if(!t.success)return`Invalid _meta envelope for protocol revision 2026-07-28: ${t.error.issues.map(e=>e.message).join("; ")}`}};function rq(){if(n)return n;let e=ra();return n={"tools/call":e.CallToolResultSchema,"tools/list":e.ListToolsResultSchema,"prompts/get":e.GetPromptResultSchema,"prompts/list":e.ListPromptsResultSchema,"resources/list":e.ListResourcesResultSchema,"resources/templates/list":e.ListResourceTemplatesResultSchema,"resources/read":e.ReadResourceResultSchema,"completion/complete":e.CompleteResultSchema,"server/discover":e.DiscoverResultSchema}}let rj="2026-07-28";function rO(e){return void 0!==e&&oJ(e)?rP:rn}function r$(e){return void 0!==e.revision?rO(e.revision).era:"modern"===e.era?rP.era:rn.era}function rM(e){return rL.some(t=>t.hasRequestMethod(e))}function rN(e){return rL.some(t=>t.hasNotificationMethod(e))}let rL=[rn,rP];var rA=(e=>{let t={};for(var o in e)p(t,o,{get:e[o],enumerable:!0});return t})({AnnotationsSchema:()=>eM,AudioContentSchema:()=>tt,BaseMetadataSchema:()=>
1ec,BaseRequestParamsSchema:()=>H,BlobResourceContentsSchema:()=>eO,BooleanSchemaSchema:()=>tN,CallToolRequestParamsSchema:()=>tg,CallToolRequestSchema:()=>tS,CallToolResultSchema:()=>tm,CancelTaskRequestSchema:()=>op,CancelTaskResultSchema:()=>oh,CancelledNotificationParamsSchema:()=>en,CancelledNotificationSchema:()=>ea,ClientCapabilitiesSchema:()=>ef,ClientNotificationSchema:()=>of,ClientRequestSchema:()=>om,ClientResultSchema:()=>og,ClientTasksCapabilitySchema:()=>eh,CompatibilityCallToolResultSchema:()=>tf,CompleteRequestParamsSchema:()=>t4,CompleteRequestSchema:()=>t9,CompleteResultSchema:()=>t6,ContentBlockSchema:()=>tn,CreateMessageRequestParamsSchema:()=>tj,CreateMessageRequestSchema:()=>tO,CreateMessageResultSchema:()=>t$,CreateMessageResultWithToolsSchema:()=>tM,CreateTaskResultSchema:()=>or,CursorSchema:()=>U,DiscoverRequestSchema:()=>e_,DiscoverResultSchema:()=>ew,ElicitRequestFormParamsSchema:()=>tJ,ElicitRequestParamsSchema:()=>tK,ElicitRequestSchema:()=>tX,ElicitRequestURLParamsSchema:()=>tG,ElicitResultSchema:()=>t0,ElicitationCompleteNotificationParamsSchema:()=>tY,ElicitationCompleteNotificationSchema:()=>tQ,EmbeddedResourceSchema:()=>tr,EmptyResultSchema:()=>ei,EnumSchemaSchema:()=>
1tW,GetPromptRequestParamsSchema:()=>e5,GetPromptRequestSchema:()=>e8,GetPromptResultSchema:()=>ts,GetTaskPayloadRequestSchema:()=>ol,GetTaskPayloadResultSchema:()=>oc,GetTaskRequestSchema:()=>oa,GetTaskResultSchema:()=>os,IconSchema:()=>es,IconsSchema:()=>el,ImageContentSchema:()=>te,ImplementationSchema:()=>eu,InitializeRequestParamsSchema:()=>eg,InitializeRequestSchema:()=>eS,InitializeResultSchema:()=>eb,InitializedNotificationSchema:()=>ey,JSONArraySchema:()=>A,JSONObjectSchema:()=>L,JSONRPCErrorResponseSchema:()=>et,JSONRPCMessageSchema:()=>eo,JSONRPCNotificationSchema:()=>Q,JSONRPCRequestSchema:()=>Y,JSONRPCResponseSchema:()=>er,JSONRPCResultResponseSchema:()=>ee,JSONValueSchema:()=>N,LegacyTitledEnumSchemaSchema:()=>tz,ListChangedOptionsBaseSchema:()=>tb,ListPromptsRequestSchema:()=>e6,ListPromptsResultSchema:()=>e3,ListResourceTemplatesRequestSchema:()=>eU,ListResourceTemplatesResultSchema:()=>ez,ListResourcesRequestSchema:()=>eA,ListResourcesResultSchema:()=>eZ,ListRootsRequestSchema:()=>t5,ListRootsResultSchema:()=>t8,ListTasksRequestSchema:()=>ou,ListTasksResultSchema:()=>od,ListToolsRequestSchema:()=>tp,ListToolsResultSchema:()=>th,LoggingLevelSchema:()=>ty,LoggingMessageNotificationParamsSchema:()=>tR,LoggingMessageNotificationSchema:()=>tC,ModelHintSchema:()=>tk,ModelPreferencesSchema:()=>tx,MultiSelectEnumSchemaSchema:()=>tF,NotificationSchema:()=>J,NotificationsParamsSchema:()=>B,NumberSchemaSchema:()=>tA,PaginatedRequestParamsSchema:()=>eT,PaginatedRequestSchema:()=>eE,PaginatedResultSchema:()=>eI,PingRequestSchema:()=>eR,PrimitiveSchemaDefinitionSchema:()=>tB,ProgressNotificationParamsSchema:()=>ek,ProgressNotificationSchema:()=>ex,ProgressSchema:()=>eC,ProgressTokenSchema:()=>Z,PromptArgumentSchema:()=>e4,PromptListChangedNotificationSchema:()=>tl,PromptMessageSchema:()=>ta,PromptReferenceSchema:()=>t2,PromptSchema:()=>
1e9,ReadResourceRequestParamsSchema:()=>eD,ReadResourceRequestSchema:()=>eV,ReadResourceResultSchema:()=>eH,RelatedTaskMetadataSchema:()=>D,RequestIdSchema:()=>X,RequestMetaSchema:()=>V,RequestSchema:()=>W,ResourceContentsSchema:()=>eP,ResourceLinkSchema:()=>ti,ResourceListChangedNotificationSchema:()=>eF,ResourceRequestParamsSchema:()=>eD,ResourceSchema:()=>eN,ResourceTemplateReferenceSchema:()=>t1,ResourceTemplateSchema:()=>eL,ResourceUpdatedNotificationParamsSchema:()=>e1,ResourceUpdatedNotificationSchema:()=>e2,ResultMetaObjectSchema:()=>G,ResultSchema:()=>K,RoleSchema:()=>e$,RootSchema:()=>t3,RootsListChangedNotificationSchema:()=>t7,SamplingContentSchema:()=>tI,SamplingMessageContentBlockSchema:()=>tP,SamplingMessageSchema:()=>tq,ServerCapabilitiesSchema:()=>ev,ServerNotificationSchema:()=>ov,ServerRequestSchema:()=>oS,ServerResultSchema:()=>ob,ServerTasksCapabilitySchema:()=>em,SetLevelRequestParamsSchema:()=>t_,SetLevelRequestSchema:()=>tw,SingleSelectEnumSchemaSchema:()=>tD,StringSchemaSchema:()=>tL,SubscribeRequestParam
1sSchema:()=>eD,SubscribeRequestSchema:()=>eW,SubscriptionFilterSchema:()=>eJ,SubscriptionsAcknowledgedNotificationParamsSchema:()=>eX,SubscriptionsAcknowledgedNotificationSchema:()=>eY,SubscriptionsListenRequestParamsSchema:()=>eG,SubscriptionsListenRequestSchema:()=>eK,SubscriptionsListenResultMetaSchema:()=>eQ,SubscriptionsListenResultSchema:()=>e0,TaskAugmentedRequestParamsSchema:()=>F,TaskCreationParamsSchema:()=>oe,TaskMetadataSchema:()=>z,TaskSchema:()=>oo,TaskStatusNotificationParamsSchema:()=>oi,TaskStatusNotificationSchema:()=>on,TaskStatusSchema:()=>ot,TextContentSchema:()=>e7,TextResourceContentsSchema:()=>eq,TitledMultiSelectEnumSchemaSchema:()=>tH,TitledSingleSelectEnumSchemaSchema:()=>tU,ToolAnnotationsSchema:()=>tc,ToolChoiceSchema:()=>tT,ToolExecutionSchema:()=>tu,ToolListChangedNotificationSchema:()=>tv,ToolResultContentSchema:()=>tE,ToolSchema:()=>td,ToolUseContentSchema:()=>to,UnsubscribeRequestParamsSchema:()=>eD,UnsubscribeRequestSchema:()=>eB,UntitledMultiSelectEnumSchemaSchema:()=>tV,UntitledSingleSelectEnumSchemaSchema:()=>tZ});let rZ=e=>Y.safeParse(e).success,rU=e=>Q.safeParse(e).success,rz=e=>ee.safeParse(e).success,rD=e=>et.safeParse(e).success,rV=e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&"input_required"===e.resultType,rH=e=>eS.safeParse(e).success,rF=e=>ey.safeParse(e).success,rW="x-mcp-header",rB=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,rJ=new Set(["string","integer","boolean","number"]);function rG(e){let t=[],o=new Map,r=(e,i,n)=>{if(null===e||"object"!=typeof e)return;if(rW in e){if(!n||0===i.length)return`${rY(i)}: x-mcp-header is only permitted on properties statically reachable via a chain of 'properties' keys (not under items, additionalProperties, oneOf/anyOf/allOf/not, if/then/else, or $ref)`;let r=e[rW];if("string"!=typeof r||0===r.length)return`${rY(i)}: x-mcp-header MUST be a non-empty string`;if(!rB.test(r))return`${rY(i)}: x-mcp-header '${r}' is not a valid RFC 9110 token (no spaces, control characters or HTTP delimiters)`;let a="string"==typeof e.type?e.type:void 0;if(void 0===a||!rJ.has(a))return`${rY(i)}: x-mcp-header is only permitted on primitive-typed properties (string, integer, boolean); got ${a??"<none>"}`;let s=r.toLowerCase(),l=o.get(s);if(void 0!==l)return`x-mcp-header '${r}' is not case-insensitively unique (also declared as '${l}')`;o.set(s,r),t.push({path:i,headerName:r,type:a})}let a=e.properties;if(null!==a&&"object"==typeof a)for(let[e,t]of Object.entries(a)){let o=r(t,[...i,e],n);if(void 0!==o)return o}for(let t of rK){let o=e[t];if(void 0!==o)for(let e of Array.isArray(o)?o:null!==o&&"object"==typeof o&&rX.has(t)?Object.values(o):[o]){let o=r(e,[...i,`<${t}>`],!1);if(void 0!==o)return o}}},i=r(e,[],!0);return void 0===i?{valid:!0,declarations:t}:{valid:!1,reason:i}}let rK=["items","prefixItems","contains","additionalProperties","unevaluatedProperties","unevaluatedItems","propertyNames","patternProperties","dependentSchemas","oneOf","anyOf","allOf","not","if","then","else","$defs","definitions"],rX=new Set(["patternProperties","dependentSchemas","$defs","definitions"]);function rY(e){return 0===e.length?"<root>":e.join(".")}let rQ="=?base64?";function r0(e){return!function(e){if(0===e.length||e.startsWith(rQ)&&e.endsWith("?=")||e!==e.trim())return!0;for(let t=0;t<e.length;t++){let o=e.codePointAt(t);if(9!==o&&(!(o>=32)||!(o<=126)))return!0}return!1}(e)?e:`${rQ}${function(e){let t=new TextEncoder().encode(e),o="";for(let e of t)o+=String.fromCodePoint(e);return btoa(o)}(e)}?=`}function r1(e,t){let o={};for(let r of e){let e=function(e,t){let o=e;for(let e of t){if(null===o||"object"!=typeof o)return;o=o[e]}return o}(t,r.path);if(null==e)continue;let i=function(e){if("string"==typeof e)return e;if("boolean"==typeof e)return e?"true":"false";if("number"==typeof e){if(!Number.isFinite(e)||Number.isInteger(e)&&!Number.isSafeInteger(e))return;return String(e)}}(e);void 0!==i&&(o[`Mcp-Param-${r.headerName}`]=r0(i))}return o}function r2(e,t){return o$.safeParse(e,t)}function r4(e){return new Set(e.flatMap(e=>Object.keys(e.shape)))}function r9(e){if(null==e)return!1;let t=typeof e;return("object"===t||"function"===t)&&"~standard"in e&&"function"==typeof e["~standard"]?.validate}rd.InvalidRequest,rd.UnsupportedProtocolVersion,rd.InvalidParams,rd.MethodNotFound,rd.InvalidParams,rd.MissingRequiredClientCapability,rd.ParseError,rd.InvalidRequest,rd.MethodNotFound,rd.UnsupportedProtocolVersion,rd.MissingRequiredClientCapability;
1let r6=!1,r3="draft-2020-12";async function r5(e,t){let o=await e["~standard"].validate(t);return o.issues&&o.issues.length>0?{success:!1,error:o.issues.map(e=>e.path?.length?`${e.path.map(e=>String("object"==typeof e?e.key:e)).join(".")}: ${e.message}`:e.message).join(", ")}:{success:!0,data:o.value}}let r8=/\\\.\\d\{(\d+)\}/;function r7(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let ie=new Set(["$comment","deprecated","description","examples","readOnly","title","writeOnly"]);function it(e){return ie.has(e)||e.startsWith("x-")}let io=new Set(["$schema",...Object.keys(tJ.shape.requestedSchema.shape)]),ir={string:r4([tL,tZ,tU,tz]),number:r4([tA]),integer:r4([tA]),boolean:r4([tN]),array:r4([tV,tH])},ii=new Set(tL.shape.format.unwrap().options);function ia(e){return{autoFulfill:e?.autoFulfill??!0,maxRounds:e?.maxRounds??10}}async function is(e){let{config:t,method:o,originalParams:r,requestOptions:i,hooks:n,signal:a}=e,s=e.flowStartedAt??Date.now(),l=e.firstPayload,c=0;for(;;){let e;if((c+=1)>t.maxRounds){var u;throw new oD(oz.InputRequiredRoundsExceeded,(u=t.maxRounds,`Multi-round-trip request '${o}' still required input after ${u} rounds (inputRequired.maxRounds)`),{rounds:t.maxRounds,lastResult:{inputRequests:l.inputRequests,...void 0!==l.requestState&&{requestState:l.requestState}}})}i.onprogress?.({progress:c,message:`Fulfilling input required by '${o}' (round ${c})`});let d=Object.entries(l.inputRequests??{});if(d.length>0){let t=function(e){let t=new AbortController,o=()=>t.abort(e?.reason);return e?.addEventListener("abort",o,{once:!0}),e?.aborted&&t.abort(e.reason),{signal:t.signal,abort:e=>t.abort(e),dispose:()=>e?.removeEventListener("abort",o)}}(a);try{let o=await Promise.all(d.map(async([e,o])=>{try{return[e,await n.dispatchInputRequest(e,o,t.signal)]}catch(e){throw t.abort(e),e}}));e=Object.fromEntries(o)}finally{t.dispose()}}else await function(e){return new Promise((t,o)=>{if(e?.aborted)return void o(e.reason instanceof oD?e.reason:new oD(oz.RequestTimeout,String(e.reason)));let r=setTimeout(()=>{e?.removeEventListener("abort",i),t()},250),i=()=>{clearTimeout(r),o(e?.reason instanceof oD?e.reason:new oD(oz.RequestTimeout,String(e?.reason)))};e?.addEventListener("abort",i,{once:!0})})}(a);let p={...void 0!==i.timeout&&{timeout:i.timeout}};if(void 0!==i.maxTotalTimeout){let e=Date.now()-s,t=i.maxTotalTimeout-e;if(t<=0)throw new oD(oz.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:i.maxTotalTimeout,totalElapsed:e});p.maxTotalTimeout=t}let h=await n.retry(function(e,t,o){let r=void 0!==t&&Object.keys(t).length>0;return r||void 0!==o?{...e,...r&&{inputResponses:t},...void 0!==o&&{requestState:o}}:e}(r,e,l.requestState),p);if(rV(h)){l={inputRequests:h.inputRequests??{},...void 0!==h.requestState&&{requestState:h.requestState}};continue}return h}}Object.assign(function(e){let t=void 0!==e.inputRequests&&Object.keys(e.inputRequests).length>0,o="string"==typeof e.requestState;if(!t&&!o)throw TypeError("inputRequired() requires at least one of inputRequests (with at least one entry) or requestState (spec: every InputRequiredResult MUST include at least one of the two)");return{resultType:"input_required",...void 0!==e.inputRequests&&{inputRequests:e.inputRequests},...void 0!==e.requestState&&{requestState:e.requestState}}},{elicit(e){try{return{method:"elicitation/create",params:function(e){if(!r9(e.requestedSchema))return{...e,mode:"form",requestedSchema:e.requestedSchema};let t=e.requestedSchema["~standard"].vendor,o=function(e,t){let o={},r=[];for(let[i,n]of Object.entries(e))"properties"===i&&r7(n)?o[i]=Object.fromEntries(Object.entries(n).map(([e,o])=>[e,function(e,t,o,r){if(!r7(e))return e;let i="string"==typeof e.type&&Object.hasOwn(ir,e.type)?ir[e.type]:void 0;if(void 0===i)return e;let n={};for(let[s,l]of Object.entries(e))if(i.has(s)||it(s))n[s]=l;else if("pattern"===s&&"string"===e.type&&"string"==typeof e.format)if(ii.has(e.format)){var a;"string"==typeof l&&(a=e.format,"zod"!==o||(function(e,t){let o;switch(e){case"email":o=[w.email()];break;case"uri":o=[w.url()];break;case"date":o=[R.date()];break;case"date-time":let r,i;r=r8.exec(t),i=[void 0,-1,0],r&&i.push(Number(r[1])),o=[!1,!0].flatMap(e=>[!1,!0].flatMap(t=>i.map(o=>R.datetime({local:e,offset:t,precision:o}))))}return new Set(o.map(e=>{let t;return t=oM.toJSONSchema(e,{target:r3,io:"input"}),"string"==typeof t.pattern?t.pattern:void 0}).filter(e=>void 0!==e))})(a,l).has(l))||r.push(`${t}.${s}`)}else n[s]=l;else r.push(`${t}.${s}`);return n}(o,`properties.${e}`,t,r)])):io.has(i)?o[i]=n:it(i)||r.push(i);if(r.length>0)throw new rp(rd.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${r.join(", ")}`);return o}(function(e){try{return function(e,t="input"){let o,r=e["~standard"];if(r.jsonSchema)o=r.jsonSchema[t]({target:r3});else if("zod"===r.vendor){if(!("_zod"in e))throw Error("Schema a
1ppears to be from zod 3, which the SDK cannot convert to JSON Schema. Upgrade to zod >=4.2.0, or wrap your JSON Schema with fromJsonSchema().");r6||(r6=!0,console.warn("[mcp-sdk] Your zod version does not implement `~standard.jsonSchema` (added in zod 4.2.0). Falling back to z.toJSONSchema(). Upgrade to zod >=4.2.0 to silence this warning.")),o=oM.toJSONSchema(e,{target:r3,io:t})}else throw Error(`Schema library "${r.vendor}" does not implement StandardJSONSchemaV1 (\`~standard.jsonSchema\`). Upgrade to a version that does, or wrap your JSON Schema with fromJsonSchema().`);if("output"===t)return void 0!==o.type||!function e(t){if("properties"in t||"patternProperties"in t||"additionalProperties"in t||"required"in t)return!0;for(let o of["oneOf","anyOf","allOf"]){let r=t[o];if(Array.isArray(r)&&r.length>0)return r.every(t=>null!==t&&"object"==typeof t&&("object"===t.type||e(t)))}return!1}(o)?o:{type:"object",...o};if(void 0!==o.type&&"object"!==o.type)throw Error(`MCP tool and prompt schemas must describe objects (got type: ${JSON.stringify(o.type)}). Wrap your schema in z.object({...}) or equivalent.`);return{type:"object",...o}}(e,"input")}catch(t){let e=t instanceof Error?t.message:String(t);throw new rp(rd.InvalidParams,`Elicitation requestedSchema must describe an object with flat primitive properties: ${e}`)}}(e.requestedSchema),t),r=r2(tJ.shape.requestedSchema,o);if(!r.success)throw new rp(rd.InvalidParams,`Elicitation requestedSchema only supports flat primitive properties (string, number, integer, boolean, and string enums): ${function(e,t){if(!r7(e.properties))return t;let o=Object.entries(e.properties).filter(([,e])=>!r2(tB,e).success).map(([e])=>`properties.${e}`);return o.length>0?o.join(", "):t}(o,r.error.message)}`);let i=function e(t,o,r=""){return Array.isArray(t)&&Array.isArray(o)?t.flatMap((t,i)=>e(t,o[i],`${r}[${i}]`)):r7(t)&&r7(o)?Object.entries(t).flatMap(([t,i])=>{let n=r?`${r}.${t}`:t;return Object.prototype.hasOwnProperty.call(o,t)?e(i,o[t],n):it(t)?[]:[n]}):[]}(o,r.data);if(i.length>0)throw new rp(rd.InvalidParams,`Elicitation requestedSchema contains unsupported JSON Schema constraint(s) after Standard Schema conversion: ${i.join(", ")}`);let n=(r.data.required??[]).filter(e=>!Object.prototype.hasOwnProperty.call(r.data.properties,e));if(n.length>0)throw new rp(rd.InvalidParams,`Elicitation requestedSchema lists required properties that are not defined in properties: ${n.join(", ")}`);return{...e,mode:"form",requestedSchema:r.data}}(e)}}catch(e){throw e instanceof rp?TypeError(e.message,{cause:e}):e}},elicitUrl:e=>({method:"elicitation/create",params:{...e,mode:"url"}}),createMessage:e=>({method:"sampling/createMessage",params:e}),listRoots:()=>({method:"roots/list"})});let il={},ic={};function iu(e,t){let o=e.slice(0,-6);il[o]=t,ic[o]=e=>t.safeParse(e).success}for(let e of["AnnotationsSchema","AudioContentSchema","BaseMetadataSchema","BlobResourceContentsSchema","BooleanSchemaSchema","CallToolRequestSchema","CallToolRequestParam
1sSchema","CallToolResultSchema","CancelledNotificationSchema","CancelledNotificationParamsSchema","CancelTaskRequestSchema","CancelTaskResultSchema","ClientCapabilitiesSchema","ClientNotificationSchema","ClientRequestSchema","ClientResultSchema","CompatibilityCallToolResultSchema","CompleteRequestSchema","CompleteRequestParamsSchema","CompleteResultSchema","ContentBlockSchema","CreateMessageRequestSchema","CreateMessageRequestParamsSchema","CreateMessageResultSchema","CreateMessageResultWithToolsSchema","CreateTaskResultSchema","CursorSchema","DiscoverRequestSchema","DiscoverResultSchema","ElicitationCompleteNotificationSchema","ElicitationCompleteNotificationParamsSchema","ElicitRequestSchema","ElicitRequestFormParamsSchema","ElicitRequestParamsSchema","ElicitRequestURLParamsSchema","ElicitResultSchema","EmbeddedResourceSchema","EmptyResultSchema","EnumSchemaSchema","GetPromptRequestSchema","GetPromptRequestParamsSchema","GetPromptResultSchema","GetTaskPayloadRequestSchema","GetTaskPayloadResultSchema","GetTaskRequestSchema","GetTaskResultSchema","IconSchema","IconsSchema","ImageContentSchema","ImplementationSchema","InitializedNotificationSchema","InitializeRequestSchema","InitializeRequestParam
1sSchema","InitializeResultSchema","JSONArraySchema","JSONObjectSchema","JSONRPCErrorResponseSchema","JSONRPCMessageSchema","JSONRPCNotificationSchema","JSONRPCRequestSchema","JSONRPCResponseSchema","JSONRPCResultResponseSchema","JSONValueSchema","LegacyTitledEnumSchemaSchema","ListPromptsRequestSchema","ListPromptsResultSchema","ListResourcesRequestSchema","ListResourcesResultSchema","ListResourceTemplatesRequestSchema","ListResourceTemplatesResultSchema","ListRootsRequestSchema","ListRootsResultSchema","ListTasksRequestSchema","ListTasksResultSchema","ListToolsRequestSchema","ListToolsResultSchema","LoggingLevelSchema","LoggingMessageNotificationSchema","LoggingMessageNotificationParamsSchema","ModelHintSchema","ModelPreferencesSchema","MultiSelectEnumSchemaSchema","NotificationSchema","NumberSchemaSchema","PaginatedRequestSchema","PaginatedRequestParamsSchema","PaginatedResultSchema","PingRequestSchema","PrimitiveSchemaDefinitionSchema","ProgressSchema","ProgressNotificationSchema","ProgressNotificationParamsSchema","ProgressTokenSchema","PromptSchema","PromptArgumentSchema","PromptListChangedNotificationSchema","PromptMessageSchema","PromptReferenceSchema","ReadResourceRequestSchema","ReadResourceRequestParam
1sSchema","ReadResourceResultSchema","RelatedTaskMetadataSchema","RequestSchema","RequestIdSchema","RequestMetaSchema","ResourceSchema","ResourceContentsSchema","ResourceLinkSchema","ResourceListChangedNotificationSchema","ResourceRequestParamsSchema","ResourceTemplateSchema","ResourceTemplateReferenceSchema","ResourceUpdatedNotificationSchema","ResourceUpdatedNotificationParamsSchema","ResultMetaObjectSchema","ResultSchema","RoleSchema","RootSchema","RootsListChangedNotificationSchema","SamplingContentSchema","SamplingMessageSchema","SamplingMessageContentBlockSchema","ServerCapabilitiesSchema","ServerNotificationSchema","ServerRequestSchema","ServerResultSchema","SetLevelRequestSchema","SetLevelRequestParamsSchema","SingleSelectEnumSchemaSchema","StringSchemaSchema","SubscribeRequestSchema","SubscribeRequestParamsSchema","SubscriptionFilterSchema","SubscriptionsAcknowledgedNotificationSchema","SubscriptionsAcknowledgedNotificationParamsSchema","SubscriptionsListenRequestSchema","SubscriptionsListenRequestParamsSchema","SubscriptionsListenResultSchema","SubscriptionsListenResultMetaSchema","TaskAugmentedRequestParamsSchema","TaskCreationParamsSchema","TaskMetadataSchema","TaskSchema","TaskStatusSchema","TaskStatusNotificationSchema","TaskStatusNotificationParamsSchema","TextContentSchema","TextResourceContentsSchema","TitledMultiSelectEnumSchemaSchema","TitledSingleSelectEnumSchemaSchema","ToolSchema","ToolAnnotationsSchema","ToolChoiceSchema","ToolExecutionSchema","ToolListChangedNotificationSchema","ToolResultContentSchema","ToolUseContentSchema","UnsubscribeRequestSchema","UnsubscribeRequestParam
1sSchema","UntitledMultiSelectEnumSchemaSchema","UntitledSingleSelectEnumSchemaSchema"])iu(e,rA[e]);for(let[e,t]of Object.entries({IdJagTokenExchangeResponseSchema:ox,OAuthClientInformationFullSchema:oq,OAuthClientInformationSchema:oP,OAuthClientMetadataSchema:oI,OAuthClientRegistrationErrorSchema:oj,OAuthErrorResponseSchema:oT,OAuthMetadataSchema:ow,OAuthProtectedResourceMetadataSchema:o_,OAuthTokenRevocationRequestSchema:oO,OAuthTokensSchema:ok,OpenIdProviderDiscoveryMetadataSchema:oC,OpenIdProviderMetadataSchema:oR}))iu(e,t);let id=Object.freeze(il),ip=Object.freeze(ic),ih=[P,q,O,M],im=["inputResponses","requestState"];function ig(e,t){let o=e.params;if(!iy(o))return{message:e,lifted:{}};let r=o._meta,i=iy(r)?ih.filter(e=>e in r):[],n="request"===t?im.filter(e=>e in o):[];if(0===i.length&&0===n.length)return{message:e,lifted:{}};let a={},s={...o};if(i.length>0&&iy(r)){let e={},t={...r};for(let o of i)e[o]=r[o],delete t[o];a.envelope=e,Object.keys(t).length>0?s._meta=t:delete s._meta}for(let e of n)"inputResponses"===e&&(a.inputResponses=s[e]),"requestState"===e&&(a.requestState=s[e]),delete s[e];return{message:{...e,params:s},lifted:a}}function iS(e,t){let o=e.validateResult(t,void 0);if(o.ok||"not-in-era"!==o.reason)return{"~standard":{version:1,vendor:"mcp-wire-codec",validate(o){let r=e.validateResult(t,o);return r.ok?{value:r.value}:{issues:[{message:"invalid"===r.reason?r.message:`not-in-era: ${t}`}]}}}}}let iv=(nn=void 0,()=>nn);var ib=class{_transport;_requestMessageId=0;_requestHandlers=new Map;_requestHandlerAbortControllers=new Map;_notificationHandlers=new Map;_responseHandlers=new Map;_progressHandlers=new Map;_timeoutInfo=new Map;_pendingDebouncedNotifications=new Set;_negotiatedProtocolVersion;_supportedProtocolVersions;onclose;onerror;fallbackRequestHandler;fallbackNotificationHandler;constructor(e){this._options=e,this._supportedProtocolVersions=e?.supportedProtocolVersions??E,this.setNotificationHandler("notifications/cancelled",e=>{this._oncancel(e)}),this.setNotificationHandler("notifications/progress",e=>{this._onprogress(e)}),this.setRequestHandler("ping",e=>({}))}_shouldDropInbound(e){}_outboundMetaEnvelope(){}_envelopeOutbound(e){let t=this._outboundMetaEnvelope();if(void 0===t)return e;let o=e.params??{};return{...e,params:{...o,_meta:{...t,...o._meta}}}}_resolveNonCompleteResult(e,t){return Promise.reject(new oD(oz.UnsupportedResultType,`Unsupported result type '${e.kind}' for ${t.request.method}`,{resultType:e.kind,method:t.request.method}))}_getRequestHandler(e){return this._requestHandlers.get(e)}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,o,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:o,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let o=Date.now()-t.startTime;if(t.maxTotalTimeout&&o>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new oD(oz.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:o});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{try{t?.()}finally{this._onclose()}};let o=this.transport?.onerror;this._transport.onerror=e=>{o?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),rz(e)||rD(e)?this._onresponse(e):rZ(e)?this._onrequest(e,t):rU(e)?this._onnotification(e,t):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},e.setSupportedProtocolVersions?.(this._supportedProtocolVersions),await this._transport.start()}_onclose(){let e=this._responseHandlers;for(let e of(this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._timeoutInfo.values()))clearTimeout(e.timeoutId);this._timeoutInfo.clear();let t=this._requestHandlerAbortControllers;this._requestHandlerAbortControllers=new Map;let o=new oD(oz.ConnectionClosed,"Connection closed");this._transport=void 0;try{this.onclose?.()}finally{for(let t of e.values())t(o);for(let e of t.values())e.abort(o)}}_onerror(e){this.onerror?.(e)}_onnotification(e,t){let{message:o}=ig(e,"notification"),r=this._negotiatedWireCodec();if(t?.classification===void 0&&"drop"===this._shouldDropInbound(e))return;if(t?.classification!==void 0){let e=r$(t.classification);
1if(e!==r.era)return void this._onerror(Error(`Era mismatch on inbound notification '${o.method}': classified as ${e} but this instance serves ${r.era}`))}if(rN(o.method)&&!r.hasNotificationMethod(o.method))return;let i=this._notificationHandlers.get(o.method),n=this.fallbackNotificationHandler;(void 0!==i||void 0!==n)&&Promise.resolve().then(()=>void 0===i?n(o):i(o,r)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){var o;let{message:r,lifted:i}=ig(e,"request"),n=this._negotiatedWireCodec();if(t?.classification===void 0&&"drop"===this._shouldDropInbound(e))return void this._onerror(Error(`Dropped inbound request '${e.method}': not servable on this connection's protocol era`));let a=this._transport,s=(e,t,o)=>{let i={jsonrpc:"2.0",id:r.id,error:{code:e,message:t,...void 0!==o&&{data:o}}};a?.send(i).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)))};if(t?.classification!==void 0){let e=r$(t.classification);if(e!==n.era){this._onerror(Error(`Era mismatch on inbound request '${r.method}': classified as ${e} but this instance serves ${n.era}`));let o=t.classification.revision??e;s(rd.UnsupportedProtocolVersion,`Unsupported protocol version: ${o}`,{supported:this._supportedProtocolVersions,requested:o});return}}if(rM(r.method)&&!n.hasRequestMethod(r.method))return void s(rd.MethodNotFound,"Method not found");let l=this._requestHandlers.get(r.method)??this.fallbackRequestHandler;if(void 0===l)return void s(rd.MethodNotFound,"Method not found");let c=n.checkInboundEnvelope(i);if(void 0!==c)return void s(rd.InvalidParams,c);let u=(e,t)=>this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,{...t,relatedRequestId:r.id}),d=(e,t,o)=>this._requestWithSchemaViaCodec(this._resolveOutboundCodec(e.method),e,t,{...o,relatedRequestId:r.id}),p=new AbortController;this._requestHandlerAbortControllers.set(r.id,p);let h=void 0===i.inputResponses?void 0:function(e){let t={},o=[];if(!iw(e))return{accepted:t,droppedKeys:o};for(let[r,i]of Object.entries(e)){if(!iw(i)||"method"in i||"result"in i){o.push(r);continue}t[r]=i}return{accepted:t,droppedKeys:o}}(i.inputResponses),m={sessionId:a?.sessionId,mcpReq:{id:r.id,method:r.method,_meta:r.params?._meta,...void 0!==i.envelope&&{envelope:i.envelope},...void 0!==h&&{inputResponses:h.accepted},...void 0!==h&&h.droppedKeys.length>0&&{droppedInputResponseKeys:h.droppedKeys},requestState:void 0===i.requestState?iv:(o=i.requestState,()=>o),signal:p.signal,send:(e,t,o)=>{let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),r9(t))return d(e,t,o);let i=iS(r,e.method);if(void 0===i)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to ctx.mcpReq.send().`);return d(e,i,t)},notify:u},http:t?.authInfo?{authInfo:t.authInfo}:void 0},f=this.buildContext(m,t);Promise.resolve().then(()=>l(r,f)).then(async e=>{let t;if(p.signal.aborted)return;try{t=n.encodeResult(r.method,e,this._outboundServerInfo())}catch(e){this._onerror(Error(`Failed to encode result for ${r.method}: ${e}`)),s(rd.InternalError,"Internal error");return}let o={result:t,jsonrpc:"2.0",id:r.id};await a?.send(o)},async e=>{if(p.signal.aborted)return;let t=Number.isSafeInteger(e.code)?e.code:rd.InternalError,o={jsonrpc:"2.0",id:r.id,error:{code:n.encodeErrorCode(t),message:e.message??"Internal error",...void 0!==e.data&&{data:e.data}}};await a?.send(o)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.get(r.id)===p&&this._requestHandlerAbortControllers.delete(r.id)})}_onprogress(e){let{progressToken:t,...o}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i)return void this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));let n=this._responseHandlers.get(r),a=this._timeoutInfo.get(r);if(a&&n&&a.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),n(e);return}i(o)}_onresponse(e){let t=Number(e.id),o=this._responseHandlers.get(t);
1void 0===o?this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`)):(this._responseHandlers.delete(t),this._cleanupTimeout(t),this._progressHandlers.delete(t),o(rz(e)?e:rp.fromError(e.error.code,e.error.message,e.error.data)))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,o){let r=this._resolveOutboundCodec(e.method);if(this._assertOutboundRequestInEra(r,e.method),r9(t))return this._requestWithSchemaViaCodec(r,e,t,o);let i=iS(r,e.method);if(void 0===i)throw TypeError(`'${e.method}' is not a spec method; pass a result schema as the second argument to request().`);return this._requestWithSchemaViaCodec(r,e,i,t)}_negotiatedWireCodec(){return rO(this._negotiatedProtocolVersion)}_wireCodec(){return this._negotiatedWireCodec()}_resolveOutboundCodec(e){if(void 0===this._negotiatedProtocolVersion){let t=function(e){switch(e){case"initialize":case"notifications/initialized":return rO(void 0);case"server/discover":return rO(rj);default:return}}(e);if(t)return t}return this._negotiatedWireCodec()}_assertOutboundRequestInEra(e,t){if(rM(t)&&!e.hasRequestMethod(t))throw new oD(oz.MethodNotSupportedByProtocolVersion,`Method '${t}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t,era:e.era})}_requestWithSchema(e,t,o){let r=this._resolveOutboundCodec(e.method);return this._assertOutboundRequestInEra(r,e.method),this._requestWithSchemaViaCodec(r,e,t,o)}_requestWithSchemaViaCodec(e,t,o,r){let i,n,{relatedRequestId:a,resumptionToken:s,onresumptiontoken:l,headers:c}=r??{},u=Date.now();return new Promise((d,p)=>{let h=e=>{p(e)};if(!this._transport)return void h(Error("Not connected"));if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method)}catch(e){h(e);return}if(r?.signal?.aborted){let e=r.signal.reason;throw e instanceof oD?e:new oD(oz.RequestTimeout,String(e))}let m=e.era===rj&&!0===this._transport.hasPerRequestStream?new AbortController:void 0,f=this._requestMessageId++;n=f;let g={...t,jsonrpc:"2.0",id:f};r?.onprogress&&(this._progressHandlers.set(f,r.onprogress),g.params={...t.params,_meta:{...t.params?._meta,progressToken:f}});let S=this._envelopeOutbound(g),v=!1,b=e=>{v||(this._progressHandlers.delete(f),void 0===m?this._transport?.send(this._envelopeOutbound({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(e)}}),{relatedRequestId:a,resumptionToken:s,onresumptiontoken:l}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))):m.abort(),p(e instanceof oD?e:new oD(oz.RequestTimeout,String(e))))};this._responseHandlers.set(f,i=>{let n;if(!r?.signal?.aborted){if(v=!0,i instanceof Error)return p(i);try{n=e.decodeResult(t.method,i.result)}catch(e){return p(e instanceof Error?e:Error(String(e)))}if("invalid"===n.kind)return p(n.error);if("input_required"===n.kind){var a;return r?.allowInputRequired===!0?d({resultType:"input_required",inputRequests:(a=n).inputRequests,...void 0!==a.requestState&&{requestState:a.requestState}}):d(this._resolveNonCompleteResult(n,{codec:e,request:t,resultSchema:o,options:r,flowStartedAt:u,retry:(r,i)=>this._requestWithSchemaViaCodec(e,void 0===r?{method:t.method}:{method:t.method,params:r},o,i)}))}r5(o,n.result).then(e=>{e.success?d(e.data):p(new oD(oz.InvalidResult,`Invalid result for ${t.method}: ${e.error}`))},p)}}),i=()=>b(r?.signal?.reason),r?.signal?.addEventListener("abort",i,{once:!0});let y=r?.timeout??6e4;this._setupTimeout(f,y,r?.maxTotalTimeout,()=>b(new oD(oz.RequestTimeout,"Request timed out",{timeout:y})),r?.resetTimeoutOnProgress??!1),this._transport.send(S,{relatedRequestId:a,resumptionToken:s,onresumptiontoken:l,headers:c,requestSignal:m?.signal}).catch(e=>{this._progressHandlers.delete(f),p(e)})}).finally(()=>{i&&r?.signal?.removeEventListener("abort",i),void 0!==n&&(this._responseHandlers.delete(n),this._cleanupTimeout(n))})}async notification(e,t){return this._notificationViaCodec(this._resolveOutboundCodec(e.method),e,t)}async _notificationViaCodec(e,t,o){if(!this._transport)throw new oD(oz.NotConnected,"Not connected");if(rN(t.method)&&!e.hasNotificationMethod(t.method))throw new oD(oz.MethodNotSupportedByProtocolVersion,`Notification '${t.method}' is not supported by the negotiated protocol version (wire era ${e.era})`,{method:t.method,era:e.era});this.assertNotificationCapability(t.method);let r=this._envelopeOutbound({jsonrpc:"2.0",...t});if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!o?.relatedRequestId){if
1(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method),this._transport&&this._transport?.send(r,o).catch(e=>this._onerror(e))});return}await this._transport.send(r,o)}setRequestHandler(e,t,o){let r;if(this.assertRequestHandlerCapability(e),"function"==typeof t){if(!rM(e))throw TypeError(`'${e}' is not a spec request method; pass schemas as the second argument to setRequestHandler().`);r=(o,r)=>{let i=this._negotiatedWireCodec(),n=i.validateRequest(e,o);if(n.ok||"not-in-era"!==n.reason||(n=i.validateInputRequest(e,o)),!n.ok){if("not-in-era"===n.reason)throw new rp(rd.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(n.message)}return Promise.resolve(t(n.value,r))}}else if(o)r=async(r,i)=>{let n=await r5(t.params,{...r.params});if(!n.success)throw new rp(rd.InvalidParams,`Invalid params for ${e}: ${n.error}`);return o(n.data,i)};else throw TypeError("setRequestHandler: handler is required");this._requestHandlers.set(e,this._wrapHandler(e,r))}_wrapHandler(e,t){return t}_outboundServerInfo(){}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t,o){if("function"==typeof t){if(!rN(e))throw TypeError(`'${e}' is not a spec notification method; pass schemas as the second argument to setNotificationHandler().`);this._notificationHandlers.set(e,(o,r)=>{let i=r.validateNotification(e,o);if(!i.ok){if("not-in-era"===i.reason)throw new rp(rd.InternalError,`No wire schema for ${e} in the resolved era`);throw Error(i.message)}return Promise.resolve(t(i.value))});return}if(!o)throw TypeError("setNotificationHandler: handler is required");this._notificationHandlers.set(e,async r=>{let i=await r5(t.params,{...r.params});if(!i.success)throw new rp(rd.InvalidParams,`Invalid params for notification ${e}: ${i.error}`);await o(i.data,r)})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function iy(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function i_(e,t){let o={...e};for(let e in t){let r=t[e];if(void 0===r)continue;let i=o[e];o[e]=iy(i)&&iy(r)?{...i,...r}:r}return o}function iw(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function iR(e){throw new oD(oz.SendFailed,`ctx.mcpReq.${e} is not available while fulfilling an embedded input request: the request is fulfilled locally and has no related peer request`)}async function iC(e,t,o,r,i){var n;if(!iw(r)||"string"!=typeof r.method)throw new oD(oz.InvalidResult,`Invalid input request '${o}': each inputRequests entry must be an embedded request object with a method`,{key:o});let a=r.method;if(!t.hasInputRequestMethod(a))throw new oD(oz.InvalidResult,`Invalid input request '${o}': '${a}' is not an embedded request the ${t.era} revision defines (expected elicitation/create, sampling/createMessage, or roots/list)`,{key:o,method:a});let s=e.getRequestHandler(a);if(void 0===s)throw new oD(oz.CapabilityNotSupported,`Cannot fulfil input request '${o}': no handler is registered for '${a}' on this client. Declare the corresponding capability and register a handler, or handle input_required results manually.`,{key:o,method:a});let l=iw(r.params)?r.params:void 0;return await s({jsonrpc:"2.0",id:o,method:a,...void 0!==l&&{params:l}},e.buildContext({sessionId:e.sessionId,mcpReq:{id:o,method:a,_meta:l?._meta,requestState:(n=void 0,()=>n),signal:i,send:()=>iR("send"),notify:()=>iR("notify")}}))}function ik(e,t,o,r){let{codec:i,request:n,options:a,flowStartedAt:s}=r,l={inputRequests:o.inputRequests,...void 0!==o.requestState&&{requestState:o.requestState}};return is({config:t,method:n.method,originalParams:n.params,firstPayload:l,flowStartedAt:s,signal:a?.signal,requestOptions:{...a?.timeout!==void 0&&{timeout:a.timeout},...a?.maxTotalTimeout!==void 0&&{maxTotalTimeout:a.maxTotalTimeout},...a?.onprogress!==void 0&&{onprogress:a.onprogress}},hooks:{dispatchInputRequest:(t,o,r)=>iC(e,i,t,o,r),retry:(e,t)=>r.retry(e,{...a?.signal!==void 0&&{signal:a.signal},...a?.onprogress!==void 0&&{onprogress:a.onprogress},...a?.resetTimeoutOnProgress!==void 0&&{resetTimeoutOnProgress:a.resetTimeoutOnProgress},...a?.headers!==void 0&&{headers:a.headers},...void 0!==t.timeout&&{timeout:t.timeout},...void 0!==t.maxTotalTimeout&&{maxTotalTimeout:t.maxTotalTimeout},allowInputRequired:!0})}})}var ix=((e,t,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var r,i=m(t),n=0,a=i.length;n<a;n++)r=i[n],g.call(e,r)||void 0===r||p(e,r,{get:(e=>t[e]).bind(null,r),enumerable:!(o=h(t,r))||o.enumerable});return e})(p(null!=(c=(s=e=>{var t=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u
1005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,o=/\\([\u000b\u0020-\u00ff])/g,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function i(e){this.parameters=Object.create(null),this.type=e}e.parse=function(e){if(!e)throw TypeError("argument string is required");var n,a,s,l="object"==typeof e?function(e){var t;if("function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]),"string"!=typeof t)throw TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof l)throw TypeError("argument string is required to be a string");var c=l.indexOf(";"),u=-1!==c?l.slice(0,c).trim():l.trim();if(!r.test(u))throw TypeError("invalid media type");var d=new i(u.toLowerCase());if(-1!==c){for(t.lastIndex=c;a=t.exec(l);){if(a.index!==c)throw TypeError("invalid parameter format");c+=a[0].length,n=a[1].toLowerCase(),34===(s=a[2]).charCodeAt(0)&&-1!==(s=s.slice(1,-1)).indexOf("\\")&&(s=s.replace(o,"$1")),d.parameters[n]=s}if(c!==l.length)throw TypeError("invalid parameter format")}return d}},()=>(l||s((l={exports:{}}).exports),l.exports))())?d(f(c)):{},"default",{value:c,enumerable:!0}),c);function iT(e){if(e)try{return ix.parse(e).type}catch{let t=(e.split(";",1)[0]??"").trim().toLowerCase();if(""===t||e.slice(t.length).includes(","))return;return t}}var iE=class{_buffer;_maxBufferSize;constructor(e){this._maxBufferSize=e?.maxBufferSize??0xa00000}append(e){if((this._buffer?.length??0)+e.length>this._maxBufferSize)throw this.clear(),Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?u.Buffer.concat([this._buffer,e]):e}readMessage(){for(;this._buffer;){let e=this._buffer.indexOf("\n");if(-1===e)break;let t=this._buffer.toString("utf8",0,e).replace(/\r$/,"");this._buffer=this._buffer.subarray(e+1);try{return iI(t)}catch(e){if(e instanceof SyntaxError)continue;throw e}}return null}clear(){this._buffer=void 0}};function iI(e){return eo.parse(JSON.parse(e))}function iP(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function iq(e=fetch,t){return t?async(o,r)=>e(o,{...t,...r,headers:r?.headers?{...iP(t.headers),...iP(r.headers)}:t.headers}):e}var ij=class e{static isTemplate(e){return/\{[^}\s]+\}/.test(e)}static validateLength(e,t,o){if(e.length>t)throw Error(`${o} exceeds maximum length of ${t} characters (got ${e.length})`)}template;parts;get variableNames(){return this.parts.flatMap(e=>"string"==typeof e?[]:e.names)}constructor(t){e.validateLength(t,1e6,"Template"),this.template=t,this.parts=this.parse(t)}toString(){return this.template}parse(t){let o=[],r="",i=0,n=0;for(;i<t.length;)if("{"===t[i]){r&&(o.push(r),r="");let a=t.indexOf("}",i);if(-1===a)throw Error("Unclosed template expression");if(++n>1e4)throw Error("Template contains too many expressions (max 10000)");let s=t.slice(i+1,a),l=this.getOperator(s),c=s.includes("*"),u=this.getNames(s),d=u[0];for(let t of u)e.validateLength(t,1e6,"Variable name");o.push({name:d,operator:l,names:u,exploded:c}),i=a+1}else r+=t[i],i++;return r&&o.push(r),o}getOperator(e){return["+","#",".","/","?","&"].find(t=>e.startsWith(t))||""}getNames(e){let t=this.getOperator(e);return e.slice(t.length).split(",").map(e=>e.replace("*","").trim()).filter(e=>e.length>0)}encodeValue(t,o){return(e.validateLength(t,1e6,"Variable value"),"+"===o||"#"===o)?encodeURI(t):encodeURIComponent(t)}expandPart(e,t){if("?"===e.operator||"&"===e.operator){let o=e.names.map(o=>{let r=t[o];return void 0===r?"":`${o}=${Array.isArray(r)?r.map(t=>this.encodeValue(t,e.operator)).join(","):this.encodeValue(r.toString(),e.operator)}`}).filter(e=>e.length>0);return 0===o.length?"":("?"===e.operator?"?":"&")+o.join("&")}if(e.names.length>1){let o=e.names.map(e=>t[e]).filter(e=>void 0!==e);return 0===o.length?"":o.map(e=>Array.isArray(e)?e[0]:e).join(",")}let o=t[e.name];if(void 0===o)return"";let r=(Array.isArray(o)?o:[o]).map(t=>this.encodeValue(t,e.operator));switch(e.operator){case"":case"+":default:return r.join(",");case"#":return"#"+r.join(",");case".":return"."+r.join(".");case"/":return"/"+r.join("/")}}expand(e){let t="",o=!1;for(let r of this.parts){if("string"==typeof r){t+=r;continue}let i=this.expandPart(r,e);i&&(t+=("?"===r.operator||"&"===r.operator)&&o?i.replace("?","&"):i,("?"===r.operator||"&"===r.operator)&&(o=!0))}return t}escapeRegExp(e){return e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`)}partToRegExp(t){let o,r=[];for(let o of t.names)e.validateLength(o,1e6,"Variable name");if("?"===t.operator||"&"===t.operator){for(let e=0;e<t.names.length;e++){let o=t.names[e],i=0===e?"\\"+t.operator:"&";r.push({pattern:i+this.escapeRegExp(o)+"=([^&]+)",name:o})}return r}let i=t.name;switch(t.operator){case"":o=t.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)";break;case"+":case"#":o="(.+)";break;case".":o=String.raw`\.([^/,]+)`;break;case"/":o="/"+(t.exploded?"([^/,]+(?:,[^/,]+)*)":"([^/,]+)");break;default:o="([^/]+)"}return r.push({pattern:o,name:i}),r}match(t){e.validateLength(t,1e6,"URI");let o="^",r=[];for(let e of this.parts)if("string"==typeof e)o+=this.escapeRegExp(e);else for(let{pattern:t,name:i}of this.partToRegExp(e))o+=t,r.push({name:i,exploded:e.exploded}
1);o+="$",e.validateLength(o,1e6,"Generated regex pattern");let i=new RegExp(o),n=t.match(i);if(!n)return null;let a={};for(let[e,t]of r.entries()){let{name:o,exploded:r}=t,i=n[e+1];a[o.replace("*","")]=r&&i.includes(",")?i.split(","):i}return a}},iO=class e{_otherTransport;_messageQueue=[];_closed=!1;onclose;onerror;onmessage;sessionId;static createLinkedPair(){let t=new e,o=new e;return t._otherTransport=o,o._otherTransport=t,[t,o]}async start(){for(;this._messageQueue.length>0;){let e=this._messageQueue.shift();this.onmessage?.(e.message,e.extra)}}async close(){if(this._closed)return;this._closed=!0;let e=this._otherTransport;this._otherTransport=void 0;try{await e?.close()}finally{this.onclose?.()}}async send(e,t){if(!this._otherTransport)throw new oD(oz.NotConnected,"Not connected");this._otherTransport.onmessage?this._otherTransport.onmessage(e,{authInfo:t?.authInfo}):this._otherTransport._messageQueue.push({message:e,extra:{authInfo:t?.authInfo}})}};function i$(e,t){let o=typeof e;if(o!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;let o=e.length;if(o!==t.length)return!1;for(let r=0;r<o;r++)if(!i$(e[r],t[r]))return!1;return!0}if("object"===o){if(!e||!t)return e===t;let o=Object.keys(e),r=Object.keys(t);if(o.length!==r.length)return!1;for(let r of o)if(!i$(e[r],t[r]))return!1;return!0}return e===t}function iM(e){return encodeURI(e.replace(/~/g,"~0").replace(/\//g,"~1"))}e.s(["$",0,oG,"A",0,rH,"At",0,oz,"C",0,-32020,"D",0,function(e){if("ref/prompt"!==e.params.ref.type)throw TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)},"E",0,rG,"F",0,rZ,"Ft",0,oL,"G",0,rg,"I",0,e=>er.safeParse(e).success,"J",0,rf,"K",0,rp,"L",0,rz,"M",0,rV,"Mt",0,oU,"N",0,rD,"Nt",0,oZ,"O",0,function(e){if("ref/resource"!==e.params.ref.type)throw TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)},"P",0,rU,"Pt",0,oA,"Q",0,oJ,"R",0,e=>F.safeParse(e).success,"S",0,r2,"T",0,r0,"U",0,rj,"W",0,rO,"X",0,rd,"Y",0,rm,"Z",0,oB,"_",0,i_,"a",0,iq,"b",0,ia,"bt",0,oF,"c",0,0xa00000,"d",0,function(e){return void 0!==e.title&&""!==e.title?e.title:"annotations"in e&&e.annotations?.title?e.annotations.title:e.name},"et",0,oK,"f",0,function(e){return"application/json"===e||"application/json"===iT(e)},"g",0,ib,"h",0,6e4,"i",0,ij,"j",0,rF,"jt",0,oV,"k",0,e=>"object"==typeof e&&null!==e&&void 0!==e.content&&tm.safeParse(e).success,"kt",0,oD,"l",0,iI,"m",0,ik,"n",0,function(){o0(),ra(),o8(),rb(),rq()},"o",0,iP,"p",0,iT,"q",0,rh,"r",0,iO,"s",0,iE,"t",0,function(e,t){let o=t.getValidator(e);return{"~standard":{version:1,vendor:"mcp",jsonSchema:{input:()=>e,output:()=>e},validate:e=>{let t=o(e);return t.valid?{value:t.data}:{issues:[{message:t.errorMessage}]}}}}},"u",0,function(e){return JSON.stringify(e)+"\n"},"v",0,ip,"w",0,r1,"x",0,function(e){return{"~standard":{version:1,vendor:"modelcontextprotocol",validate:(t,o)=>rV(t)?{value:t}:e["~standard"].validate(t,o)}}},"xt",0,oH,"y",0,id,"z",0,function(e){return eo.parse(e)}],699461);let iN={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},iL={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},iA={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},iZ="u">typeof self&&self.location&&"null"!==self.location.origin?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function iU(e,t=Object.create(null),o=iZ,r=""){if(e&&"object"==typeof e&&!Array.isArray(e)){let i=e.$id||e.id;if(i){let n=new URL(i,o.href);n.hash.length>1?t[n.href]=e:(n.hash="",""===r?o=n:iU(e,t,o))}}else if(!0!==e&&!1!==e)return t;let i=o.href+(r?"#"+r:"");if(void 0!==t[i])throw Error(`Duplicate schema URI "${i}".`);if(t[i]=e,!0===e||!1===e)return t;if(void 0===e.__absolute_uri__&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&void 0===e.__absolute_ref__){let t=new URL(e.$ref,o.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&void 0===e.__absolute_recursive_ref__){let t=new URL(e.$recursiveRef,o.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}for(let i in e.$anchor&&(t[new URL("#"+e.$anchor,o.href).href]=e),e){if(iA[i])continue;let n=`${r}/${iM(i)}`,a=e[i];if(Array.isArray(a)){if(iN[i]){let e=a.length;for(let r=0;r<e;r++)iU(a[r],t,o,`${n}/${r}`)}}else if(iL[i])for(let e in a)iU(a[e],t,o,`${n}/${iM(e)}`);else iU(a,t,o,n)}return t}let iz=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,iD=[0,31,28,31,30,31,30,31,31,30,31,30,31],iV=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;function iH(e){return e.test.bind(e)}let iF={date:iW,time:iB.bind(void 0,!1),"date-time":function(e){let t=e.split(iJ);return 2==t.length&&iW(t[0])&&iB(!0,t[1])},duration:e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e)),uri:function(e){return iG.test(e)&&iK.test(e)},"uri-reference":iH(/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2}
1)*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i),"uri-template":iH(/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i),url:iH(/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu),email:e=>{if('"'===e[0])return!1;let[t,o,...r]=e.split("@");return!(!t||!o||0!==r.length||t.length>64||o.length>253||"."===t[0]||t.endsWith(".")||t.includes(".."))&&!!/^[a-z0-9.-]+$/i.test(o)&&!!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t)&&o.split(".").every(e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e))},hostname:iH(/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i),ipv4:iH(/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/),ipv6:iH(/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i),regex:function(e){if(iX.test(e))return!1;try{return RegExp(e,"u"),!0}catch(e){return!1}},uuid:iH(/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i),"json-pointer":iH(/^(?:\/(?:[^~/]|~0|~1)*)*$/),"json-pointer-uri-fragment":iH(/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i),"relative-json-pointer":iH(/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/)};function iW(e){var t;let o=e.match(iz);if(!o)return!1;let r=+o[1],i=+o[2],n=+o[3];return i>=1&&i<=12&&n>=1&&n<=(2==i&&(t=r)%4==0&&(t%100!=0||t%400==0)?29:iD[i])}function iB(e,t){let o=t.match(iV);if(!o)return!1;let r=+o[1],i=+o[2],n=+o[3],a=!!o[5];return(r<=23&&i<=59&&n<=59||23==r&&59==i&&60==n)&&(!e||a)}let iJ=/t|\s/i,iG=/\/|:/,iK=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2}
1)*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,iX=/[^\\]\\Z/;var iY=class{schema;draft;shortCircuit;lookup;constructor(e,t="2019-09",o=!0){this.schema=e,this.draft=t,this.shortCircuit=o,this.lookup=iU(e)}validate(e){return function e(t,o,r="2019-09",i=iU(o),n=!0,a=null,s="#",l="#",c=Object.create(null)){let u;if(!0===o)return{valid:!0,errors:[]};if(!1===o)return{valid:!1,errors:[{instanceLocation:s,keyword:"false",keywordLocation:s,error:"False boolean schema."}]};let d=typeof t;switch(d){case"boolean":case"number":case"string":u=d;break;case"object":u=null===t?"null":Array.isArray(t)?"array":"object";break;default:throw Error(`Instances of "${d}" type are not supported.`)}let{$ref:p,$recursiveRef:h,$recursiveAnchor:m,type:f,const:g,enum:S,required:v,not:b,anyOf:y,allOf:_,oneOf:w,if:R,then:C,else:k,format:x,properties:T,patternProperties:E,additionalProperties:I,unevaluatedProperties:P,minProperties:q,maxProperties:j,propertyNames:O,dependentRequired:$,dependentSchemas:M,dependencies:N,prefixItems:L,items:A,additionalItems:Z,unevaluatedItems:U,contains:z,minContains:D,maxContains:V,minItems:H,maxItems:F,uniqueItems:W,minimum:B,maximum:J,exclusiveMinimum:G,exclusiveMaximum:K,multipleOf:X,minLength:Y,maxLength:Q,pattern:ee,__absolute_ref__:et,__absolute_recursive_ref__:eo}=o,er=[];if(!0===m&&null===a&&(a=o),"#"===h){let u=null===a?i[eo]:a,d=`${l}/$recursiveRef`,p=e(t,null===a?o:a,r,i,n,u,s,d,c);p.valid||er.push({instanceLocation:s,keyword:"$recursiveRef",keywordLocation:d,error:"A subschema had errors."},...p.errors)}if(void 0!==p){let o=i[et||p];if(void 0===o){let e=`Unresolved $ref "${p}".`;throw et&&et!==p&&(e+=`  Absolute URI "${et}".`),Error(e+=`
2Known schemas:
3- ${Object.keys(i).join("\n- ")}`)}let u=`${l}/$ref`,d=e(t,o,r,i,n,a,s,u,c);if(d.valid||er.push({instanceLocation:s,keyword:"$ref",keywordLocation:u,error:"A subschema had errors."},...d.errors),"4"===r||"7"===r)return{valid:0===er.length,errors:er}}if(Array.isArray(f)){let e=f.length,o=!1;for(let r=0;r<e;r++)if(u===f[r]||"integer"===f[r]&&"number"===u&&t%1==0&&t==t){o=!0;break}o||er.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${u}" is invalid. Expected "${f.join('", "')}".`})}else"integer"===f?("number"!==u||t%1||t!=t)&&er.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${u}" is invalid. Expected "${f}".`}):void 0!==f&&u!==f&&er.push({instanceLocation:s,keyword:"type",keywordLocation:`${l}/type`,error:`Instance type "${u}" is invalid. Expected "${f}".`});if(void 0!==g&&("object"===u||"array"===u?i$(t,g)||er.push({instanceLocation:s,keyword:"const",keywordLocation:`${l}/const`,error:`Instance does not match ${JSON.stringify(g)}.`}):t!==g&&er.push({instanceLocation:s,keyword:"const",keywordLocation:`${l}/const`,error:`Instance does not match ${JSON.stringify(g)}.`})),void 0!==S&&("object"===u||"array"===u?S.some(e=>i$(t,e))||er.push({instanceLocation:s,keyword:"enum",keywordLocation:`${l}/enum`,error:`Instance does not match any of ${JSON.stringify(S)}.`}):S.some(e=>t===e)||er.push({instanceLocation:s,keyword:"enum",keywordLocation:`${l}/enum`,error:`Instance does not match any of ${JSON.stringify(S)}.`})),void 0!==b){let o=`${l}/not`;e(t,b,r,i,n,a,s,o).valid&&er.push({instanceLocation:s,keyword:"not",keywordLocation:o,error:'Instance matched "not" schema.'})}let ei=[];if(void 0!==y){let o=`${l}/anyOf`,u=er.length,d=!1;for(let l=0;l<y.length;l++){let u=y[l],p=Object.create(c),h=e(t,u,r,i,n,!0===m?a:null,s,`${o}/${l}`,p);er.push(...h.errors),d=d||h.valid,h.valid&&ei.push(p)}d?er.length=u:er.splice(u,0,{instanceLocation:s,keyword:"anyOf",keywordLocation:o,error:"Instance does not match any subschemas."})}if(void 0!==_){let o=`${l}/allOf`,u=er.length,d=!0;for(let l=0;l<_.length;l++){let u=_[l],p=Object.create(c),h=e(t,u,r,i,n,!0===m?a:null,s,`${o}/${l}`,p);er.push(...h.errors),d=d&&h.valid,h.valid&&ei.push(p)}d?er.length=u:er.splice(u,0,{instanceLocation:s,keyword:"allOf",keywordLocation:o,error:"Instance does not match every subschema."})}if(void 0!==w){let o=`${l}/oneOf`,u=er.length,d=w.filter((l,u)=>{let d=Object.create(c),p=e(t,l,r,i,n,!0===m?a:null,s,`${o}/${u}`,d);return er.push(...p.errors),p.valid&&ei.push(d),p.valid}).length;1===d?er.length=u:er.splice(u,0,{instanceLocation:s,keyword:"oneOf",keywordLocation:o,error:`Instance does not match exactly one subschema (${d} matches).`})}if(("object"===u||"array"===u)&&Object.assign(c,...ei),void 0!==R){let o=`${l}/if`;if(e(t,R,r,i,n,a,s,o,c).valid){if(void 0!==C){let u=e(t,C,r,i,n,a,s,`${l}/then`,c);u.valid||er.push({instanceLocation:s,keyword:"if",keywordLocation:o,error:'Instance does not match "then" schema.'},...u.errors)}}else if(void 0!==k){let u=e(t,k,r,i,n,a,s,`${l}/else`,c);u.valid||er.push({instanceLocation:s,keyword:"if",keywordLocation:o,error:'Instance does not match "else" schema.'},...u.errors)}}if("object"===u){if(void 0!==v)for(let e of v)e in t||er.push({instanceLocation:s,keyword:"required",keywordLocation:`${l}/required`,error:`Instance does not have required property "${e}".`});let o=Object.keys(t);if(void 0!==q&&o.length<q&&er.push({instanceLocation:s,keyword:"minProperties",keywordLocation:`${l}/minProperties`,error:`Instance does not have at least ${q} properties.`}),void 0!==j&&o.length>j&&er.push({instanceLocation:s,keyword:"maxProperties",keywordLocation:`${l}/maxProperties`,error:`Instance does not have at least ${j} properties.`}),void 0!==O){let o=`${l}/propertyNames`;for(let l in t){let t=`${s}/${iM(l)}`,c=e(l,O,r,i,n,a,t,o);c.valid||er.push({instanceLocation:s,keyword:"propertyNames",keywordLocation:o,error:`Property name "${l}
3" does not match schema.`},...c.errors)}}if(void 0!==$){let e=`${l}/dependantRequired`;for(let o in $)if(o in t)for(let r of $[o])r in t||er.push({instanceLocation:s,keyword:"dependentRequired",keywordLocation:e,error:`Instance has "${o}" but does not have "${r}".`})}if(void 0!==M)for(let o in M){let u=`${l}/dependentSchemas`;if(o in t){let l=e(t,M[o],r,i,n,a,s,`${u}/${iM(o)}`,c);l.valid||er.push({instanceLocation:s,keyword:"dependentSchemas",keywordLocation:u,error:`Instance has "${o}" but does not match dependant schema.`},...l.errors)}}if(void 0!==N){let o=`${l}/dependencies`;for(let l in N)if(l in t){let c=N[l];if(Array.isArray(c))for(let e of c)e in t||er.push({instanceLocation:s,keyword:"dependencies",keywordLocation:o,error:`Instance has "${l}" but does not have "${e}".`});else{let u=e(t,c,r,i,n,a,s,`${o}/${iM(l)}`);u.valid||er.push({instanceLocation:s,keyword:"dependencies",keywordLocation:o,error:`Instance has "${l}" but does not match dependant schema.`},...u.errors)}}}let u=Object.create(null),d=!1;if(void 0!==T){let o=`${l}/properties`;for(let l in T){if(!(l in t))continue;let p=`${s}/${iM(l)}`,h=e(t[l],T[l],r,i,n,a,p,`${o}/${iM(l)}`);if(h.valid)c[l]=u[l]=!0;else if(d=n,er.push({instanceLocation:s,keyword:"properties",keywordLocation:o,error:`Property "${l}" does not match schema.`},...h.errors),d)break}}if(!d&&void 0!==E){let o=`${l}/patternProperties`;for(let l in E){let p=RegExp(l,"u"),h=E[l];for(let m in t){if(!p.test(m))continue;let f=`${s}/${iM(m)}`,g=e(t[m],h,r,i,n,a,f,`${o}/${iM(l)}`);g.valid?c[m]=u[m]=!0:(d=n,er.push({instanceLocation:s,keyword:"patternProperties",keywordLocation:o,error:`Property "${m}" matches pattern "${l}" but does not match associated schema.`},...g.errors))}}}if(d||void 0===I){if(!d&&void 0!==P){let o=`${l}/unevaluatedProperties`;for(let l in t)if(!c[l]){let u=`${s}/${iM(l)}`,d=e(t[l],P,r,i,n,a,u,o);d.valid?c[l]=!0:er.push({instanceLocation:s,keyword:"unevaluatedProperties",keywordLocation:o,error:`Property "${l}" does not match unevaluated properties schema.`},...d.errors)}}}else{let o=`${l}/additionalProperties`;for(let l in t){if(u[l])continue;let p=`${s}/${iM(l)}`,h=e(t[l],I,r,i,n,a,p,o);h.valid?c[l]=!0:(d=n,er.push({instanceLocation:s,keyword:"additionalProperties",keywordLocation:o,error:`Property "${l}" does not match additional properties schema.`},...h.errors))}}}else if("array"===u){void 0!==F&&t.length>F&&er.push({instanceLocation:s,keyword:"maxItems",keywordLocation:`${l}/maxItems`,error:`Array has too many items (${t.length} > ${F}).`}),void 0!==H&&t.length<H&&er.push({instanceLocation:s,keyword:"minItems",keywordLocation:`${l}/minItems`,error:`Array has too few items (${t.length} < ${H}).`});let o=t.length,u=0,d=!1;if(void 0!==L){let p=`${l}/prefixItems`,h=Math.min(L.length,o);for(;u<h;u++){let o=e(t[u],L[u],r,i,n,a,`${s}/${u}`,`${p}/${u}`);if(c[u]=!0,!o.valid&&(d=n,er.push({instanceLocation:s,keyword:"prefixItems",keywordLocation:p,error:"Items did not match schema."},...o.errors),d))break}}if(void 0!==A){let p=`${l}/items`;if(Array.isArray(A)){let l=Math.min(A.length,o);for(;u<l;u++){let o=e(t[u],A[u],r,i,n,a,`${s}/${u}`,`${p}/${u}`);if(c[u]=!0,!o.valid&&(d=n,er.push({instanceLocation:s,keyword:"items",keywordLocation:p,error:"Items did not match schema."},...o.errors),d))break}}else for(;u<o;u++){let o=e(t[u],A,r,i,n,a,`${s}/${u}`,p);if(c[u]=!0,!o.valid&&(d=n,er.push({instanceLocation:s,keyword:"items",keywordLocation:p,error:"Items did not match schema."},...o.errors),d))break}if(!d&&void 0!==Z){let p=`${l}/additionalItems`;for(;u<o;u++){let o=e(t[u],Z,r,i,n,a,`${s}/${u}`,p);c[u]=!0,o.valid||(d=n,er.push({instanceLocation:s,keyword:"additionalItems",keywordLocation:p,error:"Items did not match additional items schema."},...o.errors))}}}if(void 0!==z)if(0===o&&void 0===D)er.push({instanceLocation:s,keyword:"contains",keywordLocation:`${l}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(void 0!==D&&o<D)er.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array has less items (${o}) than minContains (${D}).`});else{let u=`${l}/contains`,d=er.length,p=0;for(let l=0;l<o;l++){let o=e(t[l],z,r,i,n,a,`${s}/${l}`,u);o.valid?(c[l]=!0,p++):er.push(...o.errors)}p>=(D||0)&&(er.length=d),void 0===D&&void 0===V&&0===p?er.splice(d,0,{instanceLocation:s,keyword:"contains",keywordLocation:u,error:"Array does not contain item matching schema."}):void 0!==D&&p<D?er.push({instanceLocation:s,keyword:"minContains",keywordLocation:`${l}/minContains`,error:`Array must contain at least ${D} items matching schema. Only ${p} items were found.`}):void 0!==V&&p>V&&er.push({instanceLocation:s,keyword:"maxContains",keywordLocation:`${l}/maxContains`,error:`Array may contain at most ${V} items matching schema. ${p} items were found.`})}if(!d&&void 0!==U){let d=`${l}/unevaluatedItems`;for(;u<o;u++){if(c[u])continue;let o=e(t[u],U,r,i,n,a,`${s}/${u}`,d);c[u]=!0,o.valid||er.push({instanceLocation:s,keyword:"unevaluatedItems",keywordLocation:d,error:"Items did not match unevaluated items schema."},...o.errors)}}if(W)for(let e=0;e<o;e++){let r=t[e],i="object"==typeof r&&null!==r;for(let n=0;n<o;n++){if(e===n)continue;let o=t[n];(r===o||i&&"object"==typeof o&&null!==o&&i$(r,o))&&(er.push({instanceLocation:s,keyword:"uniqueItems",keywordLocation:`${l}/uniqueItems`,error:`Duplicate items at indexes ${e} and ${n}.`}),e=Number.MAX_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER)}}}else if("number"===u){if("4"===r?(void 0!==B&&(!0===G&&t<=B||t<B)&&er.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${l}/minimum`,error:`${t} is less than ${G?"or equal to ":""} ${B}.`}),void 0!==J&&(!0===K&&t>=J||t>J)&&er.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${l}/maximum`,error:`${t} is greater than ${K?"or equal to ":""} ${J}.`})):(void 0!==B&&t<B&&er.push({instanceLocation:s,keyword:"minimum",keywordLocation:`${l}/minimum`,error:`${t} is less than ${B}.`}),void 0!==J&&t>J&&er.push({instanceLocation:s,keyword:"maximum",keywordLocation:`${l}/maximum`,error:`${t} is greater than ${J}.`}),void 0!==G&&t<=G&&er.push({instanceLocation:s,keyword:"exclusiveMinimum",keywordLocation:`${l}/exclusiveMinimum`,error:`${t} is less than ${G}.`}),void 0!==K&&t>=K&&er.push({instanceLocation:s,keyword:"exclusiveMaximum",keywordLocation:`${l}/exclusiveMaximum`,error:`${t} is greater than or equal to ${K}.`})),void 0!==X){let e=t%X;Math.abs(0-e)>=11920929e-14&&Math.abs(X-e)>=11920929e-14&&er.push({instanceLocation:s,keyword:"multipleOf",keywordLocation:`${l}/multipleOf`,error:`${t} is not a multiple of ${X}.`})}}else if("string"===u){let e=void 0===Y&&void 0===Q?0:function(e){let t,o=0,r=e.length,i=0;for(;i<r;)o++,(t=e.charCodeAt(i++))>=55296&&t<=56319&&i<r&&(64512&(t=e.charCodeAt(i)))==56320&&i++;return o}(t);void 0!==Y&&e<Y&&er.push({instanceLocation:s,keyword:"minLength",keywordLocation:`${l}/minLength`,error:`String is too short (${e} < ${Y}).`}),void 0!==Q&&e>Q&&er.push({instanceLocation:s,keyword:"maxLength",keywordLocation:`${l}/maxLength`,error:`String is too long (${e} > ${Q}).`}),void 0===ee||RegExp(ee,"u").test(t)||er.push({instanceLocation:s,keyword:"pattern",keywordLocation:`${l}/pattern`,error:"String does not match pattern."}),void 0!==x&&iF[x]&&!iF[x](t)&&er.push({instanceLocation:s,keyword:"format",keywordLocation:`${l}/format`,error:`String does not match format "${x}".`})}return{valid:0===er.length,errors:er}}(e,this.schema,this.draft,this.lookup,this.shortCircuit)}addSchema(e,t){t&&(e={...e,$id:t}),iU(e,this.lookup)}},iQ=class{shortcircuit;draft;constructor(e){this.shortcircuit=e?.shortcircuit??!0,this.draft=e?.draft}_draftFor(e){let t=function(e,t){if(!("$schema"in e)||"string"!=typeof e.$schema)return"2020-12";
3let o=e.$schema.replace(/#$/,"");if(S.has(o))return"2020-12";if(v.has(o))return"2019-09";if(b.has(o)||y.has(o))return"draft-7";throw Error(`JSON Schema declares an unsupported dialect ("$schema": "${e.$schema.slice(0,200)}"). The default validator supports JSON Schema 2020-12, 2019-09, draft-07, and draft-06; ${t}`)}(e,"pass an explicit { draft } to CfWorkerJsonSchemaValidator to validate other dialects.");return"draft-7"===t?"7":t}getValidator(e){let t=new iY(e,this.draft??this._draftFor(e),this.shortcircuit);return e=>{let o=t.validate(e);return o.valid?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:o.errors.map(e=>`${e.instanceLocation}: ${e.error}`).join("; ")}}}};async function i0(e){return(await a).getRandomValues(new Uint8Array(e))}async function i1(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",o=256-256%t.length,r="";for(;r.length<e;)for(let i of(await i0(e-r.length)))i<o&&(r+=t[i%t.length]);return r}async function i2(e){return await i1(e)}async function i4(e){return btoa(String.fromCharCode(...new Uint8Array(await (await a).subtle.digest("SHA-256",new TextEncoder().encode(e))))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function i9(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await i2(e),o=await i4(t);return{code_verifier:t,code_challenge:o}}a=globalThis.crypto;class i6 extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}function i3(e){}function i5(e){if("function"==typeof e)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=i3,onError:o=i3,onRetry:r=i3,onComment:i,maxBufferSize:n}=e,a=[],s=0,l=!0,c,u="",d=0,p,h=!1;function m(){void 0!==n&&(s+u.length<=n||(h=!0,a.length=0,s=0,c=void 0,u="",d=0,p=void 0,o(new i6(`Buffered data exceeded max buffer size of ${n} characters`,{type:"max-buffer-size-exceeded"}))))}function f(e){let o=0;if(-1===e.indexOf("\r")){let r=e.indexOf(`
4`,o);for(;-1!==r;){if(o===r){d>0&&t({id:c,event:p,data:u}),c=void 0,u="",d=0,p=void 0,o=r+1,r=e.indexOf(`
5`,o);continue}let i=e.charCodeAt(o);if(i8(e,o,i)){let i=32===e.charCodeAt(o+5)?o+6:o+5,n=e.slice(i,r);if(0===d&&10===e.charCodeAt(r+1)){t({id:c,event:p,data:n}),c=void 0,u="",p=void 0,o=r+2,r=e.indexOf(`
6`,o);continue}u=0===d?n:`${u}
7${n}`,d++}else i7(e,o,i)?p=e.slice(32===e.charCodeAt(o+6)?o+7:o+6,r)||void 0:g(e,o,r);o=r+1,r=e.indexOf(`
8`,o)}return e.slice(o)}for(;o<e.length;){let t=e.indexOf("\r",o),r=e.indexOf(`
9`,o),i=-1;if(-1!==t&&-1!==r?i=t<r?t:r:-1!==t?i=t===e.length-1?-1:t:-1!==r&&(i=r),-1===i)break;g(e,o,i),o=i+1,13===e.charCodeAt(o-1)&&10===e.charCodeAt(o)&&o++}return e.slice(o)}function g(e,o,r){if(o===r)return void(d>0&&t({id:c,event:p,data:u}),c=void 0,u="",d=0,p=void 0);let n=e.charCodeAt(o);if(i8(e,o,n)){let t=32===e.charCodeAt(o+5)?o+6:o+5,i=e.slice(t,r);u=0===d?i:`${u}
10${i}`,d++;return}if(i7(e,o,n)){p=e.slice(32===e.charCodeAt(o+6)?o+7:o+6,r)||void 0;return}if(105===n&&100===e.charCodeAt(o+1)&&58===e.charCodeAt(o+2)){let t=e.slice(32===e.charCodeAt(o+3)?o+4:o+3,r);c=t.includes("\0")?void 0:t;return}if(58===n){i&&i(e.slice(o,r).slice(32===e.charCodeAt(o+1)?2:1));return}let a=e.slice(o,r),s=a.indexOf(":");if(-1===s)return void S(a,"",a);let l=a.slice(0,s),h=32===a.charCodeAt(s+1)?2:1;S(l,a.slice(s+h),a)}function S(e,t,i){switch(e){case"event":p=t||void 0;break;case"data":u=0===d?t:`${u}
11${t}`,d++;break;case"id":c=t.includes("\0")?void 0:t;break;case"retry":/^\d+$/.test(t)?r(parseInt(t,10)):o(new i6(`Invalid \`retry\` value: "${t}"`,{type:"invalid-retry",value:t,line:i}));break;default:o(new i6(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:"unknown-field",field:e,value:t,line:i}))}}return{feed:function(e){if(h)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(l&&(l=!1,239===e.charCodeAt(0)&&187===e.charCodeAt(1)&&191===e.charCodeAt(2)&&(e=e.slice(3))),0===a.length){let t=f(e);
11""!==t&&(a.push(t),s=t.length),m();return}if(-1===e.indexOf(`
12`)&&-1===e.indexOf("\r")){a.push(e),s+=e.length,m();return}a.push(e);let t=a.join("");a.length=0,s=0;let o=f(t);""!==o&&(a.push(o),s=o.length),m()},reset:function(e={}){if(e.consume&&a.length>0){let e=a.join("");g(e,0,e.length)}l=!0,c=void 0,u="",d=0,p=void 0,a.length=0,s=0,h=!1}}}function i8(e,t,o){return 100===o&&97===e.charCodeAt(t+1)&&116===e.charCodeAt(t+2)&&97===e.charCodeAt(t+3)&&58===e.charCodeAt(t+4)}function i7(e,t,o){return 101===o&&118===e.charCodeAt(t+1)&&101===e.charCodeAt(t+2)&&110===e.charCodeAt(t+3)&&116===e.charCodeAt(t+4)&&58===e.charCodeAt(t+5)}class ne extends Event{constructor(e,t){var o,r;super(e),this.code=null!=(o=null==t?void 0:t.code)?o:void 0,this.message=null!=(r=null==t?void 0:t.message)?r:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,t,o){return o(nt(this),t)}[Symbol.for("Deno.customInspect")](e,t){return e(nt(this),t)}}function nt(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var no,nr,ni,nn,na,ns,nl,nc,nu,nd,np,nh,nm,nf,ng,nS,nv,nb,ny,n_,nw,nR,nC,nk,nx,nT,nE,nI=e=>{throw TypeError(e)},nP=(e,t,o)=>t.has(e)||nI("Cannot "+o),nq=(e,t,o)=>(nP(e,t,"read from private field"),o?o.call(e):t.get(e)),nj=(e,t,o)=>t.has(e)?nI("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,o),nO=(e,t,o,r)=>(nP(e,t,"write to private field"),t.set(e,o),o),n$=(e,t,o)=>(nP(e,t,"access private method"),o);class nM extends EventTarget{constructor(e,t){var o,r;super(),nj(this,nb),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,nj(this,na),nj(this,ns),nj(this,nl),nj(this,nc),nj(this,nu),nj(this,nd),nj(this,np),nj(this,nh,null),nj(this,nm),nj(this,nf),nj(this,ng,null),nj(this,nS,null),nj(this,nv,null),nj(this,n_,async e=>{var t;nq(this,nf).reset();let{body:o,redirected:r,status:i,headers:n}=e;if(204===i){n$(this,nb,nx).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(r?nO(this,nl,new URL(e.url)):nO(this,nl,void 0),200!==i)return void n$(this,nb,nx).call(this,`Non-200 status code (${i})`,i);if(!(n.get("content-type")||"").startsWith("text/event-stream"))return void n$(this,nb,nx).call(this,'Invalid content type, expected "text/event-stream"',i);if(nq(this,na)===this.CLOSED)return;nO(this,na,this.OPEN);let a=new Event("open");if(null==(t=nq(this,nv))||t.call(this,a),this.dispatchEvent(a),"object"!=typeof o||!o||!("getReader"in o)){n$(this,nb,nx).call(this,"Invalid response body, expected a web ReadableStream",i),this.close();return}let s=new TextDecoder,l=o.getReader(),c=!0;do{let{done:e,value:t}=await l.read();t&&nq(this,nf).feed(s.decode(t,{stream:!e})),e&&(c=!1,nq(this,nf).reset(),n$(this,nb,nT).call(this))}while(c)}),nj(this,nw,e=>{nO(this,nm,void 0),"AbortError"!==e.name&&"aborted"!==e.type&&n$(this,nb,nT).call(this,function e(t){return t instanceof Error?"errors"in t&&Array.isArray(t.errors)?t.errors.map(e).join(", "):"cause"in t&&t.cause instanceof Error?`${t}: ${e(t.cause)}`:t.message:`${t}`}(e))}),nj(this,nC,e=>{"string"==typeof e.id&&nO(this,nh,e.id);let t=new MessageEvent(e.event||"message",{data:e.data,origin:nq(this,nl)?nq(this,nl).origin:nq(this,ns).origin,lastEventId:e.id||""});nq(this,nS)&&(!e.event||"message"===e.event)&&nq(this,nS).call(this,t),this.dispatchEvent(t)}),nj(this,nk,e=>{nO(this,nd,e)}),nj(this,nE,()=>{nO(this,np,void 0),nq(this,na)===this.CONNECTING&&n$(this,nb,ny).call(this)});try{if(e instanceof URL)nO(this,ns,e);else if("string"==typeof e)nO(this,ns,new URL(e,function(){let e="document"in globalThis?globalThis.document:void 0;return e&&"object"==typeof e&&"baseURI"in e&&"string"==typeof e.baseURI?e.baseURI:void 0}()));else throw Error("Invalid URL")}catch{throw function(e){let t=globalThis.DOMException;return"function"==typeof t?new t(e,"SyntaxError"):SyntaxError(e)}("An invalid or illegal string was specified")}nO(this,nf,i5({onEvent:nq(this,nC),onRetry:nq(this,nk)})),nO(this,na,this.CONNECTING),nO(this,nd,3e3),nO(this,nu,null!=(o=null==t?void 0:t.fetch)?o:globalThis.fetch),nO(this,nc,null!=(r=null==t?void 0:t.withCredentials)&&r),n$(this,nb,ny).call(this)}get readyState(){return nq(this,na)}get url(){return nq(this,ns).href}get withCredentials(){return nq(this,nc)}
12get onerror(){return nq(this,ng)}set onerror(e){nO(this,ng,e)}get onmessage(){return nq(this,nS)}set onmessage(e){nO(this,nS,e)}get onopen(){return nq(this,nv)}set onopen(e){nO(this,nv,e)}addEventListener(e,t,o){super.addEventListener(e,t,o)}removeEventListener(e,t,o){super.removeEventListener(e,t,o)}close(){nq(this,np)&&clearTimeout(nq(this,np)),nq(this,na)!==this.CLOSED&&(nq(this,nm)&&nq(this,nm).abort(),nO(this,na,this.CLOSED),nO(this,nm,void 0))}}na=new WeakMap,ns=new WeakMap,nl=new WeakMap,nc=new WeakMap,nu=new WeakMap,nd=new WeakMap,np=new WeakMap,nh=new WeakMap,nm=new WeakMap,nf=new WeakMap,ng=new WeakMap,nS=new WeakMap,nv=new WeakMap,nb=new WeakSet,ny=function(){nO(this,na,this.CONNECTING),nO(this,nm,new AbortController),nq(this,nu)(nq(this,ns),n$(this,nb,nR).call(this)).then(nq(this,n_)).catch(nq(this,nw))},n_=new WeakMap,nw=new WeakMap,nR=function(){var e;let t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...nq(this,nh)?{"Last-Event-ID":nq(this,nh)}:void 0},cache:"no-store",signal:null==(e=nq(this,nm))?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},nC=new WeakMap,nk=new WeakMap,nx=function(e,t){var o;nq(this,na)!==this.CLOSED&&nO(this,na,this.CLOSED);let r=new ne("error",{code:t,message:e});null==(o=nq(this,ng))||o.call(this,r),this.dispatchEvent(r)},nT=function(e,t){var o;if(nq(this,na)===this.CLOSED)return;nO(this,na,this.CONNECTING);let r=new ne("error",{code:t,message:e});null==(o=nq(this,ng))||o.call(this,r),this.dispatchEvent(r),nO(this,np,setTimeout(nq(this,nE),nq(this,nd)))},nE=new WeakMap,nM.CONNECTING=0,nM.OPEN=1,nM.CLOSED=2;class nN extends TransformStream{constructor({onError:e,onRetry:t,onComment:o,maxBufferSize:r}={}){let i;super({start(n){i=i5({onEvent:e=>{n.enqueue(e)},onError(t){"function"==typeof e&&e(t),("terminate"===e||"max-buffer-size-exceeded"===t.type)&&n.error(t)},onRetry:t,onComment:o,maxBufferSize:r})},transform(e){i.feed(e)}})}}var nL=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.OAuthClientFlowError"})}static[Symbol.hasInstance](e){return oA(this,e)}static isInstance(e){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return oA(this,e)}constructor(e){super(e),this.name=new.target.name,oL(this,new.target)}},nA=class extends nL{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.IssuerMismatchError"})}kind;expected;received;constructor(e,t,o){super(`Issuer mismatch in ${"metadata"===e?"authorization server metadata (RFC 8414 §3.3)":"authorization response (RFC 9207)"}: expected ${JSON.stringify(t)}, received ${JSON.stringify(o)}`),this.kind=e,this.expected=t,this.received=o}},nZ=class extends nL{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.RegistrationRejectedError"})}status;body;submittedMetadata;constructor(e){super(`Dynamic Client Registration rejected (HTTP ${e.status}): ${e.body}`),this.status=e.status,this.body=e.body,this.submittedMetadata=e.submittedMetadata}},nU=class extends nL{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsecureTokenEndpointError"})}tokenEndpoint;constructor(e){super(`Refusing to send credentials to non-https token endpoint '${e}'. OAuth token requests MUST use TLS (localhost / 127.0.0.1 / ::1 are exempt).`),this.tokenEndpoint=e}},nz=class extends nL{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.AuthorizationServerMismatchError"})}constructor(e,t){super(`Authorization server changed between redirect and callback (redirected to ${JSON.stringify(e)}, callback resolved ${JSON.stringify(t)}); refusing to send authorization_code/code_verifier to a different token endpoint`),this.recordedIssuer=e,this.currentIssuer=t}},nD=class extends nL{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.InsufficientScopeError"})}requiredScope;resourceMetadataUrl;errorDescription;constructor(e){super(`Insufficient scope${e.requiredScope?`: required "${e.requiredScope}"`:""}`),this.requiredScope=e.requiredScope,this.resourceMetadataUrl=e.resourceMetadataUrl,this.errorDescription=e.errorDescription}};function nV(e,t,o){if(void 0!==e)return void 0===e.issuer?(o?.canPersistStamp!==!1&&console.warn("[mcp-sdk] SEP-2352: stored OAuth credential has no 'issuer' stamp (pre-upgrade storage or provider not round-tripping the value). SEP-2352 isolation is inactive for this read; ensure your provider round-trips the issuer field."),e):nH(e.issuer,t)?e:void 0}function nH(e,t){return e===t||e.endsWith("/")&&e.slice(0,-1)===t||t.endsWith("/")&&t.slice(0,-1)===e}async function nF(e,t,o){let{resourceMetadataUrl:r,scope:i}=n6(t.response);if(await n1(e,{serverUrl:t.serverUrl,resourceMetadataUrl:r,scope:i,fetchFn:t.fetchFn,...o})!=="AUTHORIZED")throw new nW}
12var nW=class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.UnauthorizedError"})}static[Symbol.hasInstance](e){return oA(this,e)}static isInstance(e){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return oA(this,e)}constructor(e){super(e??"Unauthorized"),this.name="UnauthorizedError",oL(this,new.target)}};function nB(e){return e?.authorization_response_iss_parameter_supported===!0}function nJ({iss:e,expectedIssuer:t,issParameterSupported:o}){if(void 0!==t){if(void 0===e){if(o)throw new nA("authorization_response",t,void 0);return}if(e!==t)throw new nA("authorization_response",t,e)}}function nG(...e){let t=new Set;for(let o of e)if(o)for(let e of o.split(/\s+/))e&&t.add(e);return t.size>0?[...t].join(" "):void 0}async function nK(e,t,o,r,i){if("string"==typeof e)return{authorizationCode:e,iss:t};let n=e.get("iss")??void 0,a=e.get("code");if(a)return{authorizationCode:a,iss:n};let s=(await o.discoveryState?.())?.authorizationServerMetadata;if(!s)try{s=(await ao(r,i)).authorizationServerMetadata}catch{s=void 0}if(!s)throw new nW("Authorization callback failed and the issuer could not be verified");nJ({iss:n,expectedIssuer:s.issuer,issParameterSupported:nB(s)});let l=e.get("error");if(l)throw new oU(l,e.get("error_description")??l,e.get("error_uri")??void 0);throw new nW("Authorization callback contained neither `code` nor `error`")}let nX="code",nY="S256";function nQ(e){return"localhost"===e||"127.0.0.1"===e||"[::1]"===e||"::1"===e}async function n0(e){let t=e instanceof Response?e.status:void 0,o=e instanceof Response?await e.text():e;try{let e=oT.parse(JSON.parse(o));return oU.fromResponse(e)}catch(r){let e=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${r}. Raw body: ${o}`;return new oU(oZ.ServerError,e)}}async function n1(e,t){try{return await n2(e,t)}catch(o){if(o instanceof oU){if(o.code===oZ.InvalidClient||o.code===oZ.UnauthorizedClient)return await e.invalidateCredentials?.("client"),await e.invalidateCredentials?.("tokens"),await n2(e,t);else if(o.code===oZ.InvalidGrant)return await e.invalidateCredentials?.("tokens"),await n2(e,t)}throw o}}async function n2(e,{serverUrl:t,authorizationCode:o,iss:r,scope:i,resourceMetadataUrl:n,fetchFn:a,skipIssuerMetadataValidation:s,forceReauthorization:l}){let c,u,d,p,h,m={...h=e.clientMetadata,grant_types:h.grant_types??(void 0===e.redirectUrl?void 0:["authorization_code","refresh_token"]),application_type:h.application_type??function(e){for(let t of e??[]){let e;try{e=new URL(t)}catch{continue}if("http:"!==e.protocol&&"https:"!==e.protocol||nQ(e.hostname))return"native"}return"web"}(h.redirect_uris)},f=await e.discoveryState?.(),g=n;if(!g&&f?.resourceMetadataUrl&&(g=new URL(f.resourceMetadataUrl)),f?.authorizationServerUrl){if(u=f.authorizationServerUrl,c=f.resourceMetadata,d=f.authorizationServerMetadata??await at(u,{fetchFn:a,skipIssuerValidation:s}),!c)try{c=await n5(t,{resourceMetadataUrl:g},a)}catch(e){if(e instanceof TypeError)throw e}(d!==f.authorizationServerMetadata||c!==f.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(u),resourceMetadataUrl:g?.toString(),resourceMetadata:c,authorizationServerMetadata:d})}else{let e=await ao(t,{resourceMetadataUrl:g,fetchFn:a,skipIssuerMetadataValidation:s});u=e.authorizationServerUrl,d=e.authorizationServerMetadata,c=e.resourceMetadata,p={authorizationServerUrl:String(u),resourceMetadataUrl:g?.toString(),resourceMetadata:c,authorizationServerMetadata:d}}let S=d?.issuer??String(u),v={issuer:S};if(await e.saveAuthorizationServerUrl?.(S),void 0!==o){let t=f?.authorizationServerMetadata?.issuer??f?.authorizationServerUrl;if(void 0===t){if(void 0!==e.saveDiscoveryState)throw new nz("discoveryState was not available on the callback leg; ensure your provider persists discoveryState alongside codeVerifier",S);console.warn("[mcp-sdk] OAuthClientProvider does not implement saveDiscoveryState()/discoveryState(); the SEP-2352 callback-leg authorization-server binding cannot be checked. Implement discoveryState (persist alongside co
12deVerifier) — see docs/migration/upgrade-to-v2.md §SEP-2352.")}else if(!nH(t,S))throw new nz(t,S)}p&&await e.saveDiscoveryState?.(p);let b=await n9(t,e,c);b&&await e.saveResourceUrl?.(String(b));let y=function(e){let{requestedScope:t,resourceMetadata:o,authServerMetadata:r,clientMetadata:i}=e,n=t||o?.scopes_supported?.join(" ")||i.scope;return n&&r?.scopes_supported?.includes("offline_access")&&!n.split(" ").includes("offline_access")&&i.grant_types?.includes("refresh_token")&&(n=`${n} offline_access`),n}({requestedScope:i,resourceMetadata:c,authServerMetadata:d,clientMetadata:e.clientMetadata}),_=await Promise.resolve(e.clientInformation(v)),w=nV(_,S,{canPersistStamp:void 0!==e.saveClientInformation});if(void 0===w&&_?.issuer&&void 0===e.saveClientInformation)throw new nz(_.issuer,S);if(w&&void 0===w.issuer&&(w={...w,issuer:S},await e.saveClientInformation?.(w,v)),!w){if(void 0!==o)throw Error("Existing OAuth client information is required when exchanging an authorization code");let t=d?.client_id_metadata_document_supported===!0,r=e.clientMetadataUrl;if(r&&!n4(r))throw new oU(oZ.InvalidClientMetadata,`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${r}`);if(t&&r)w={client_id:r,issuer:S},await e.saveClientInformation?.(w,v);else{if(!e.saveClientInformation)throw Error("OAuth client information must be saveable for dynamic registration");w={...await as(u,{metadata:d,clientMetadata:m,scope:y,fetchFn:a}),issuer:S},await e.saveClientInformation(w,v)}}let R=!e.redirectUrl;if(void 0!==o||R){void 0!==o&&nJ({iss:r,expectedIssuer:d?.issuer,issParameterSupported:nB(d)});let t=await aa(e,u,{metadata:d,resource:b,authorizationCode:o,iss:r,scope:y,fetchFn:a});return await e.saveTokens({...t,issuer:S},v),"AUTHORIZED"}let C=nV(await e.tokens(v),S);if(C&&void 0===C.issuer&&(C={...C,issuer:S},await e.saveTokens(C,v)),C?.refresh_token&&!l)try{let t=await an(u,{metadata:d,clientInformation:w,refreshToken:C.refresh_token,resource:b,addClientAuthentication:e.addClientAuthentication,fetchFn:a});return await e.saveTokens({...t,issuer:S},v),"AUTHORIZED"}catch(e){if(e instanceof nU||e instanceof oU&&e.code!==oZ.ServerError)throw e}let k=e.state?await e.state():void 0,{authorizationUrl:x,codeVerifier:T}=await ar(u,{metadata:d,clientInformation:w,state:k,redirectUrl:e.redirectUrl,scope:y,resource:b});return await e.saveCodeVerifier(T),await e.redirectToAuthorization(x),"REDIRECT"}function n4(e){if(!e)return!1;try{let t=new URL(e);return"https:"===t.protocol&&"/"!==t.pathname}catch{return!1}}async function n9(e,t,o){let r=oH(e);if(t.validateResourceURL)return await t.validateResourceURL(r,o?.resource);if(o){if(!oF({requestedResource:r,configuredResource:o.resource}))throw Error(`Protected resource ${o.resource} does not match expected ${r} (or origin)`);return new URL(o.resource)}}function n6(e){let t,o=e.headers.get("WWW-Authenticate");if(!o)return{};let[r,i]=o.split(" ");if(r?.toLowerCase()!=="bearer"||!i)return{};let n=n3(e,"resource_metadata")||void 0;if(n)try{t=new URL(n)}catch{}let a=n3(e,"scope")||void 0;return{resourceMetadataUrl:t,scope:a,error:n3(e,"error")||void 0,errorDescription:n3(e,"error_description")||void 0}}function n3(e,t){let o=e.headers.get("WWW-Authenticate");if(!o)return null;let r=new RegExp(String.raw`${t}=(?:"([^"]+)"|([^\s,]+))`),i=o.match(r);if(i){let e=i[1]||i[2];if(e)return e}return null}async function n5(e,t,o=fetch){let r=await ae(e,"oauth-protected-resource",o,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!r||404===r.status)throw await r?.text?.().catch(()=>{}),Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!r.ok)throw await r.text?.().catch(()=>{}),Error(`HTTP ${r.status} trying to load well-known OAuth protected resource metadata.`);return o_.parse(await r.json())}async function n8(e,t,o=fetch){try{return await o(e,{headers:t})}catch(r){if(!(r instanceof TypeError))throw r;if(t)try{return await o(e,{})}catch(e){if(!(e instanceof TypeError))throw e}return}}async function n7(e,t,o=fetch){return await n8(e,{"MCP-Protocol-Version":t},o)}async function ae(e,t,o,r){var i,n;let a,s=new URL(e),l=r?.protocolVersion??T;r?.metadataUrl?a=new URL(r.metadataUrl):(a=new URL(function(e,t="",o={}
12){return t.endsWith("/")&&(t=t.slice(0,-1)),o.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}(t,s.pathname),r?.metadataServerUrl??s)).search=s.search;let c=await n7(a,l,o);return!r?.metadataUrl&&(i=c,n=s.pathname,!i||"/"!==n&&(i.status>=400&&i.status<500||502===i.status))&&(c=await n7(new URL(`/.well-known/${t}`,s),l,o)),c}async function at(e,{fetchFn:t=fetch,protocolVersion:o=T,skipIssuerValidation:r=!1}={}){let i={"MCP-Protocol-Version":o,Accept:"application/json"};for(let{url:o,type:n}of function(e){let t="string"==typeof e?new URL(e):e,o="/"!==t.pathname,r=[];if(!o)return r.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"},{url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),r;let i=t.pathname;return i.endsWith("/")&&(i=i.slice(0,-1)),r.push({url:new URL(`/.well-known/oauth-authorization-server${i}`,t.origin),type:"oauth"},{url:new URL(`/.well-known/openid-configuration${i}`,t.origin),type:"oidc"},{url:new URL(`${i}/.well-known/openid-configuration`,t.origin),type:"oidc"}),r}(e)){let a=await n8(o,i,t);if(!a)continue;if(!a.ok){if(await a.text?.().catch(()=>{}),a.status>=400&&a.status<500||502===a.status)continue;throw Error(`HTTP ${a.status} trying to load ${"oauth"===n?"OAuth":"OpenID provider"} metadata from ${o}`)}let s="oauth"===n?ow.parse(await a.json()):oC.parse(await a.json());if(!r){let t="string"==typeof e?e:e.href;if(!(s.issuer===t||t.endsWith("/")&&s.issuer===t.slice(0,-1)))throw new nA("metadata",t,s.issuer)}return s}}async function ao(e,t){let o,r;try{(o=await n5(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn)).authorization_servers&&o.authorization_servers.length>0&&(r=o.authorization_servers[0])}catch(e){if(e instanceof TypeError)throw e}r||(r=String(new URL("/",e)));let i=await at(r,{fetchFn:t?.fetchFn,skipIssuerValidation:t?.skipIssuerMetadataValidation});return{authorizationServerUrl:r,authorizationServerMetadata:i,resourceMetadata:o}}async function ar(e,{metadata:t,clientInformation:o,redirectUrl:r,scope:i,state:n,resource:a}){let s;if(t){if(s=new URL(t.authorization_endpoint),!t.response_types_supported.includes(nX))throw Error(`Incompatible auth server: does not support response type ${nX}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(nY))throw Error(`Incompatible auth server: does not support code challenge method ${nY}`)}else s=new URL("/authorize",e);let l=await i9(),c=l.code_verifier,u=l.code_challenge;return s.searchParams.set("response_type",nX),s.searchParams.set("client_id",o.client_id),s.searchParams.set("code_challenge",u),s.searchParams.set("code_challenge_method",nY),s.searchParams.set("redirect_uri",String(r)),n&&s.searchParams.set("state",n),i&&s.searchParams.set("scope",i),i?.split(" ").includes("offline_access")&&s.searchParams.append("prompt","consent"),a&&s.searchParams.set("resource",a.href),{authorizationUrl:s,codeVerifier:c}}async function ai(e,{metadata:t,tokenRequestParams:o,clientInformation:r,addClientAuthentication:i,resource:n,fetchFn:a}){var s,l;let c,u=function(e){let t=new URL(String(e));if("https:"!==t.protocol&&!nQ(t.hostname))throw new nU(t.href);return t}(t?.token_endpoint??new URL("/token",e)),d=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});n&&o.set("resource",n.href),i?await i(d,o,u,t):r&&function(e,t,o,r){let{client_id:i,client_secret:n}=t;switch(e){case"client_secret_basic":var a,s,l,c,u=i,d=n,p=o;if(!d)throw Error("client_secret_basic authentication requires a client_secret");let h=btoa(`${u}:${d}`);p.set("Authorization",`Basic ${h}`);return;case"client_secret_post":a=i,s=n,(l=r).set("client_id",a),s&&l.set("client_secret",s);return;case"none":c=i,r.set("client_id",c);return;default:throw Error(`Unsupported client authentication method: ${e}`)}}((s=r,l=t?.token_endpoint_auth_methods_supported??[],c=void 0!==s.client_secret,"token_endpoint_auth_method"in s&&s.token_endpoint_auth_method&&["client_secret_basic","client_secret_post","none"].includes(s.token_endpoint_auth_method)&&(0===l.length||l.includes(s.token_endpoint_auth_method))?s.token_endpoint_auth_method:0===l.length?c?"client_secret_basic":"none":c&&l.includes("client_secret_basic")?"client_secret_basic":c&&l.includes("client_secret_post")?"client_secret_post":l.includes("none")?"none":c?"client_secret_post":"none"),r,d,o);let p=await (a??fetch)(u,{method:"POST",headers:d,body:o});if(!p.ok)throw await n0(p);let h=await p.json();try{return ok.parse(h)}catch(e){if("object"==typeof h&&null!==h&&"error"in h)throw await n0(JSON.stringify(h));throw e}}async function an(e,{metadata:t,clientInformation:o,refreshToken:r,resource:i,addClientAuthentication:n,fetchFn:a}){return{refresh_token:r,...await ai(e,{metadata:t,tokenRequestParam
12s:new URLSearchParams({grant_type:"refresh_token",refresh_token:r}),clientInformation:o,addClientAuthentication:n,resource:i,fetchFn:a})}}async function aa(e,t,{metadata:o,resource:r,authorizationCode:i,iss:n,scope:a,fetchFn:s}={}){let l;void 0!==i&&nJ({iss:n,expectedIssuer:o?.issuer,issParameterSupported:nB(o)});let c=a??e.clientMetadata.scope;if(e.prepareTokenRequest&&(l=await e.prepareTokenRequest(c)),!l){if(!i)throw Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw Error("redirectUrl is required for authorization_code flow");l=new URLSearchParams({grant_type:"authorization_code",code:i,code_verifier:await e.codeVerifier(),redirect_uri:String(e.redirectUrl)})}let u=await e.clientInformation({issuer:o?.issuer??String(t)});return ai(t,{metadata:o,tokenRequestParams:l,clientInformation:u??void 0,addClientAuthentication:e.addClientAuthentication,resource:r,fetchFn:s})}async function as(e,{metadata:t,clientMetadata:o,scope:r,fetchFn:i}){let n;if(t){if(!t.registration_endpoint)throw Error("Incompatible auth server: does not support dynamic client registration");n=new URL(t.registration_endpoint)}else n=new URL("/register",e);let a={...o,...void 0===r?{}:{scope:r}},s=await (i??fetch)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});if(!s.ok)throw new nZ({status:s.status,body:await s.text(),submittedMetadata:a});return oq.parse(await s.json())}let al=new Set(["tools/list","prompts/list","resources/list","resources/templates/list","server/discover"]);var ac=class{_entries=new Map;_maxEntries;_stamp=0;_cappedSize=0;constructor(e){this._maxEntries=e?.maxEntries??512}get size(){return this._entries.size}get(e){return this._entries.get(au(e))}set(e,t){let o=au(e),r=al.has(e.method),i=!this._entries.has(o);if(!r&&i&&this._maxEntries>0&&this._cappedSize>=this._maxEntries){for(let e of this._entries.keys())if(!al.has(e.slice(0,e.indexOf("\0")))){this._entries.delete(e),this._cappedSize--;break}}let n=++this._stamp;return this._entries.set(o,{...t,stamp:n}),i&&!r&&this._cappedSize++,n}delete(e){this._entries.delete(au(e))&&!al.has(e.method)&&this._cappedSize--}evict(e){let t=`${e}\0`,o=al.has(e);for(let e of this._entries.keys())e.startsWith(t)&&(this._entries.delete(e),!o&&this._cappedSize--)}clear(){this._entries.clear(),this._cappedSize=0}};function au(e){return`${e.method}\0${JSON.stringify([e.partition??"",e.params??""])}`}function ad(e,t){return void 0===t?e:`${e}\0${t}`}var ap=class{_evictionGeneration=new Map;_toolIndex;_toolOutputValidatorIndex;_serverIdentity="";constructor(e,t,o=()=>{},r="",i=Date.now){this._store=e,this._isUserSupplied=t,this._reportError=o,this._cachePartition=r,this._now=i}now(){return this._now()}setServerIdentity(e){this._serverIdentity=e}_partitionFor(e){return JSON.stringify([this._serverIdentity,"public"===e?"":this._cachePartition])}async _probe(e,t){let o={method:e,params:t??""},r=this._partitionFor("private"),i=await this._store.get({...o,partition:r});if(void 0!==i)return i;let n=this._partitionFor("public");if(n===r)return;let a=await this._store.get({...o,partition:n});return a?.scope==="public"?a:void 0}async evict(e){this._evictionGeneration.set(e,(this._evictionGeneration.get(e)??0)+1),await this._deleteBoth(e,"")}async _deleteBoth(e,t){let o=this._partitionFor("private"),r=this._partitionFor("public");try{await this._store.delete({method:e,params:t,partition:o})}catch(e){this._reportError(e)}if(r!==o)try{await this._store.delete({method:e,params:t,partition:r})}catch(e){this._reportError(e)}}async evictKey(e,t){let o=ad(e,t),r=this._evictionGeneration.get(o);void 0!==r&&this._evictionGeneration.set(o,r+1),await this._deleteBoth(e,t)}captureGeneration(e,t){let o=ad(e,t),r=this._evictionGeneration.get(o)??0;return this._evictionGeneration.set(o,r),r}async write(e,t,o,r){if((this._evictionGeneration.get(ad(e,r?.params))??0)!==o)return;let i=r?.params??"",n=this._partitionFor("private"),a=this._partitionFor("public"),s=(r?.scope??"private")==="public"?a:n;try{await this._store.set({method:e,params:i,partition:s},{value:function(e){let t;try{t=JSON.stringify(e)}catch(e){throw TypeError(`cache value is not JSON-serializable: ${e instanceof Error?e.message:String(e)}`)}if("string"!=typeof t)throw TypeError("cache value is not JSON-serializable: it has no JSON representation");return t}(t),expiresAt:r?.expiresAt,scope:r?.scope})}catch(e){this._reportError(e)}if(a!==n)try{await this._store.delete({method:e,params:i,partition:s===n?a:n})}catch(e){this._reportError(e)}}async read(e,t){let o=await this._probe(e,t);if(o?.expiresAt!==void 0&&o.expiresAt>this.now())try{let e=JSON.parse(o.value);if("object"!=typeof e||null===e||Array.isArray(e))throw TypeError("cached document is not an object");return{value:e}}catch(o){this._reportError(o),await this._deleteBoth(e,t??"");return}}resetForReconnect(){this._isUserSupplied||this._store.clear(),this._evictionGeneration.clear(),this._toolIndex=void 0,this._toolOutputValidatorIndex=void 0,this._serverIdentity=""}async toolDefinition(e){let t=await this._probe("tools/list");if(void 0===t){this._toolIndex=void 0;return}if(this._toolIndex?.stamp!==t.stamp){let e=this._decodeListTools(t),o=new Map;if(void 0!==e)for(let t of e.tools)o.set(t.name,t);this._toolIndex={stamp:t.stamp,byName:o}}return this._toolIndex.byName.get(e)}async outputValidator(e,t){let o=await this._probe("tools/list");if(void 0===o){this._toolOutputValidatorIndex=void 0;return}if(this._toolOutputValidatorIndex?.stamp!==o.stamp){let e=this._decodeListTools(o)??{tools:[]}
12,r=new Map;for(let o of e.tools){let e=t(o);void 0!==e&&r.set(o.name,e)}this._toolOutputValidatorIndex={stamp:o.stamp,byName:r}}return this._toolOutputValidatorIndex.byName.get(e)}_decodeListTools(e){try{let t=JSON.parse(e.value);if(!Array.isArray(t?.tools)||!t.tools.every(e=>null!==e&&"object"==typeof e))throw TypeError("cached tools/list document has a malformed tools array");return t}catch(e){this._reportError(e);return}}};let ah=Symbol.for("mcp.authSeamEscape");function am(e){if("object"==typeof e&&null!==e||"function"==typeof e)try{Object.defineProperty(e,ah,{value:!0,configurable:!0})}catch{}return e}let af=new Set([-32001,-32020,-32021]);function ag(e,t){let{code:o,message:r,data:i}=e;if(-32022===o){let e=function(e){if("object"!=typeof e||null===e)return;let t=e.supported;if(Array.isArray(t)&&0!==t.length&&t.every(e=>"string"==typeof e))return t}(i);if(void 0===e)return{kind:"legacy"};let o=new rf({supported:e,requested:function(e){if("object"!=typeof e||null===e)return;let t=e.requested;return"string"==typeof t?t:void 0}(i)??t.requestedVersion},r),n=oK(e),a=t.clientModernVersions.find(e=>n.includes(e));return void 0!==a?{kind:"corrective",version:a,error:o}:n.length>0?{kind:"error",error:o}:t.fallbackAvailable?{kind:"legacy"}:{kind:"error",error:o}}return af.has(o),{kind:"legacy"}}function aS(e,t){var o,r;return"browser"===t.environment&&((o=e)instanceof TypeError||o instanceof Error&&"TypeError"===o.name)?{kind:"legacy"}:{kind:"error",error:new oD(oz.EraNegotiationFailed,`Version negotiation probe failed: ${(r=e)instanceof Error?r.message:String(r)}`,{cause:e})}}function av(){let e=globalThis;return void 0!==e.window&&void 0!==e.document?"browser":"node"}function ab(e){return"stderr"in e&&"pid"in e?"stdio":"http"}var ay=class e{_pending;_probeCounter=0;_savedOnMessage;_savedOnError;_savedOnClose;_closeDelivered=!1;constructor(e){this._transport=e,this._savedOnMessage=e.onmessage,this._savedOnError=e.onerror,this._savedOnClose=e.onclose}static async open(t){let o=new e(t);t.onmessage=e=>{let t=o._pending;if(void 0!==t&&(rz(e)||rD(e))&&e.id===t.id){o._pending=void 0,rz(e)?t.resolve({kind:"response",result:e.result}):t.resolve({kind:"response",error:e.error});return}},t.onerror=e=>{o._savedOnError?.(e)},t.onclose=()=>{let e=o._pending;void 0!==e&&(o._pending=void 0,e.resolve({kind:"closed"})),o._closeDelivered=!0,o._savedOnClose?.()};try{await t.start()}catch(e){throw o.detach(),e}return o}async exchange(e,t){let o=`server-discover-probe-${++this._probeCounter}`;return new Promise(r=>{let i=!1,n=e=>{i||(i=!0,clearTimeout(a),this._pending?.id===o&&(this._pending=void 0),r(e))},a=setTimeout(()=>n({kind:"timeout"}),t);this._pending={id:o,resolve:n},this._transport.send(e(o)).catch(e=>n({kind:"send-error",error:e}))})}detach(){if(this._pending=void 0,this._transport.onmessage=this._savedOnMessage,this._transport.onerror=this._savedOnError,this._closeDelivered&&void 0!==this._savedOnClose){let e=this._savedOnClose,t=this._transport,o=!1,r=()=>{if(!o){o=!0;return}e()};t.onclose=r,a_.set(t,()=>{t.onclose===r&&(t.onclose=e)})}else this._transport.onclose=this._savedOnClose}release(){this.detach();let e=this._transport,t=e.start,o=!0;e.start=async function(){if(o){o=!1,e.start=t;return}return t.call(e)}}};let a_=new WeakMap;function aw(e){let t=a_.get(e);a_.delete(e),t?.()}async function aR(e,t){let o,r=e.probe.timeoutMs??t.defaultTimeoutMs,i=Math.max(0,e.probe.maxRetries??0),n="pin"===e.kind?[e.version]:e.modernVersions,a="auto"===e.kind&&e.fallbackAvailable,s=await ay.open(t.transport),l=async()=>{let o=n[0],l=!1,c=i;for(;;){let i=await s.exchange(e=>{var r,i,n;return r=o,i=t.clientInfo,n=t.capabilities,{jsonrpc:"2.0",id:e,method:"server/discover",params:{_meta:rO(r).outboundEnvelope({protocolVersion:r,clientInfo:i,clientCapabilities:n})}}},r);if("timeout"===i.kind&&c>0){c--;continue}let u=function(e,t){switch(e.kind){case"response":return void 0===e.error?{kind:"result",result:e.result}:{kind:"rpc-error",...e.error};case"send-error":{let t=e.error;if(("object"==typeof t&&null!==t||"function"==typeof t)&&!0===t[ah]||t instanceof nW||t instanceof Error&&"UnauthorizedError"===t.name)return{kind:"auth-required",error:t};if(t instanceof oV){let e=t.data?.text;return{kind:"http-error",status:t.data.status,body:"string"==typeof e?e:void 0,statusText:t.data.statusText}}return{kind:"network-error",error:t}}case"closed":return{kind:"closed"};case"timeout":return{kind:"timeout",timeoutMs:t}}}(i,r),d=function(e,t){switch(e.kind){case"result":return function(e,t){let o=rO(rj).validateResult("server/discover",e);if(!o.ok)return{kind:"legacy"};let r=o.value.supportedVersions,i=t.clientModernVersions.find(e=>r.includes(e));
12return void 0!==i?{kind:"modern",version:i,discover:o.value}:t.fallbackAvailable?{kind:"legacy"}:{kind:"error",error:new rf({supported:[...r],requested:t.requestedVersion})}}(e.result,t);case"rpc-error":return ag(e,t);case"http-error":return function(e,t){if(401===e.status||403===e.status){let t=403===e.status;return{kind:"error",error:new oV(t?oz.ClientHttpForbidden:oz.ClientHttpAuthentication,`Version negotiation failed: ${t?"the server denied access (HTTP 403)":"the server requires authorization (HTTP 401)"}`,{status:e.status,statusText:e.statusText,text:e.body})}}if(e.status>=500)return{kind:"error",error:new oV(oz.EraNegotiationFailed,`Version negotiation failed: the server answered the probe with HTTP ${e.status}`,{status:e.status,statusText:e.statusText,text:e.body})};let o=function(e){let t;if(void 0===e||""===e)return;try{t=JSON.parse(e)}catch{return}if("object"!=typeof t||null===t)return;let o=t.error;if("object"!=typeof o||null===o)return;let{code:r,message:i,data:n}=o;if("number"==typeof r)return{code:r,message:"string"==typeof i?i:"",data:n}}(e.body);return void 0!==o?ag(o,t):{kind:"legacy"}}(e,t);case"network-error":return aS(e.error,t);case"auth-required":return{kind:"error",error:e.error};case"closed":if("stdio"===t.transportKind)return{kind:"legacy"};return aS(Error("Connection closed during the version negotiation probe"),t);case"timeout":if("stdio"===t.transportKind)return{kind:"legacy"};return{kind:"error",error:new oD(oz.RequestTimeout,`Version negotiation probe timed out after ${e.timeoutMs}ms`,{timeout:e.timeoutMs})}}}(u,{clientModernVersions:n,requestedVersion:o,fallbackAvailable:a,environment:t.environment,transportKind:t.transportKind});switch(d.kind){case"modern":return{era:"modern",version:d.version,discover:d.discover};case"corrective":if(l)throw d.error;l=!0,o=d.version;continue;case"legacy":{let o="closed"===u.kind?"the connection closed during the server/discover probe":void 0;if("pin"===e.kind)throw new oD(oz.EraNegotiationFailed,void 0===o?`Version negotiation failed: the server did not offer pinned protocol version ${e.version} via server/discover (no fallback in pin mode)`:`Version negotiation failed: ${o} before the server offered pinned protocol version ${e.version} (no fallback in pin mode)`);if(!e.fallbackAvailable)throw new oD(oz.EraNegotiationFailed,void 0===o?"Version negotiation failed: the server gave no modern evidence and this client supports no pre-2026-07-28 protocol version to fall back to":`Version negotiation failed: ${o} and this client supports no pre-2026-07-28 protocol version to fall back to`);if(void 0!==o&&!0!==t.disposableProbe)throw new oD(oz.EraNegotiationFailed,`Version negotiation failed: ${o} (this transport probed in place — the disposable sibling probe requires the SDK's base StdioClientTransport)`);return{era:"legacy"}}case"error":throw d.error}}};try{o=await l()}catch(e){throw s.detach(),e}return s.release(),o}async function aC(e,t,o,r){let i,n,a=new t.constructor({...o,stderr:"ignore"}),s=t.close,l=!1,c=new Promise((e,t)=>{i=()=>t(ak())});t.close=async function(){return l=!0,i?.(),s.call(t)};try{let t=aR(e,{...r,transport:a,transportKind:"stdio",disposableProbe:!0});t.catch(()=>{}),n=await Promise.race([t,c])}finally{await ax(a),t.close=s}if(l)throw ak();return n}function ak(){return new oD(oz.EraNegotiationFailed,"Version negotiation failed: the transport was closed during the server/discover probe")}async function ax(e){try{let t=e._dispose;await ("function"==typeof t?t.call(e):e.close())}catch{}}function aT(e){let t=e._meta?.[j];return ip.Implementation(t)?t:void 0}let aE={"notifications/tools/list_changed":["tools/list"],"notifications/prompts/list_changed":["prompts/list"],"notifications/resources/list_changed":["resources/list","resources/templates/list"]};var aI=class extends ib{_serverCapabilities;_serverVersion;_capabilities;_instructions;_jsonSchemaValidator;_cache;_defaultCacheTtlMs;_listMaxPages;_listChangedDebounceTimers=new Map;_listChangedConfig;_enforceStrictCapabilities;_versionNegotiation;_supportedProtocolVersionsOption;_inputRequiredDriverConfig;_listenState=new Map;_nextListenId=0;_autoOpenedSubscription;_discoverResult;_resetConnectionState(){if(this._negotiatedProtocolVersion=void 0,this._serverCapabilities=void 0,this._serverVersion=void 0,this._instructions=void 0,this._discoverResult=void 0,this._autoOpenedSubscription=void 0,this._listenState.size>0){let e=new oD(oz.ConnectionClosed,"subscriptions/listen: client reconnected or closed; subscription state from the previous connection was reset");for(let t of this._listenState.values())t.settle({cause:"remote",error:e})}for(let e of(this._listenState.clear(),this._listChangedDebounceTimers.values())
12)clearTimeout(e);this._listChangedDebounceTimers.clear(),this._cache.resetForReconnect()}async close(){try{await super.close()}finally{this._resetConnectionState()}}constructor(e,t){super(t),this._clientInfo=e,this._capabilities=t?.capabilities?{...t.capabilities}:{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new iQ,this._enforceStrictCapabilities=t?.enforceStrictCapabilities??!1,this._versionNegotiation=t?.versionNegotiation,this._supportedProtocolVersionsOption=t?.supportedProtocolVersions,this._inputRequiredDriverConfig=ia(t?.inputRequired),this._cache=new ap(t?.responseCacheStore??new ac,t?.responseCacheStore!==void 0,e=>this._reportStoreError(e),t?.cachePartition??""),this._defaultCacheTtlMs=t?.defaultCacheTtlMs??0,this._listMaxPages=t?.listMaxPages??64,t?.listChanged&&(this._listChangedConfig=t.listChanged)}buildContext(e,t){return e}_shouldDropInbound(e){if(void 0!==this._negotiatedProtocolVersion&&oJ(this._negotiatedProtocolVersion)&&rZ(e))return"drop"}_outboundMetaEnvelope(){let e=this._negotiatedProtocolVersion;if(void 0!==e)return this._wireCodec().outboundEnvelope({protocolVersion:e,clientInfo:this._clientInfo,clientCapabilities:this._capabilities})}_resolveNonCompleteResult(e,t){return this._inputRequiredDriverConfig.autoFulfill?ik({getRequestHandler:e=>this._getRequestHandler(e),buildContext:e=>this.buildContext(e,void 0),sessionId:this.transport?.sessionId},this._inputRequiredDriverConfig,e,t):Promise.reject(new oD(oz.UnsupportedResultType,`Unsupported result type 'input_required' for ${t.request.method}: multi-round-trip auto-fulfilment is not enabled on this instance — pass allowInputRequired: true to handle it manually, or enable inputRequired.autoFulfill`,{resultType:"input_required",method:t.request.method}))}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools","notifications/tools/list_changed",e.tools,async()=>(await this.listTools(void 0,{cacheMode:"refresh"})).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts","notifications/prompts/list_changed",e.prompts,async()=>(await this.listPrompts(void 0,{cacheMode:"refresh"})).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources","notifications/resources/list_changed",e.resources,async()=>(await this.listResources(void 0,{cacheMode:"refresh"})).resources)}registerCapabilities(e){if(this.transport)throw Error("Cannot register capabilities after connecting to transport");this._capabilities=i_(this._capabilities,e)}setVersionNegotiation(e){if(this.transport)throw Error("Cannot configure version negotiation after connecting to transport");this._versionNegotiation=e}_wrapHandler(e,t){return"elicitation/create"===e?async(e,o)=>{let r=rO(this._negotiatedProtocolVersion),i=r.validateRequest("elicitation/create",e);if(i.ok||"not-in-era"!==i.reason||(i=r.validateInputRequest("elicitation/create",e)),!i.ok)throw new rp("not-in-era"===i.reason?rd.InternalError:rd.InvalidParams,"not-in-era"===i.reason?"No wire schema for elicitation/create in the resolved era":`Invalid elicitation request: ${i.message}`);let{params:n}=i.value;n.mode=n.mode??"form";let{supportsFormMode:a,supportsUrlMode:s}=function(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=void 0!==e.form,o=void 0!==e.url;return{supportsFormMode:t||!t&&!o,supportsUrlMode:o}}(this._capabilities.elicitation);if("form"===n.mode&&!a)throw new rp(rd.InvalidParams,"Client does not support form-mode elicitation requests");if("url"===n.mode&&!s)throw new rp(rd.InvalidParams,"Client does not support URL-mode elicitation requests");let l=await t(e,o),c=r.validateResult("elicitation/create",l);if(c.ok||"not-in-era"!==c.reason||(c=r.validateInputResponse("elicitation/create",l)),!c.ok)throw new rp("not-in-era"===c.reason?rd.InternalError:rd.InvalidParams,"not-in-era"===c.reason?"No wire schema for elicitation/create in the resolved era":`Invalid elicitation result: ${c.message}`);let u=c.value,d="form"===n.mode?n.requestedSchema:void 0;if("form"===n.mode&&"accept"===u.action&&u.content&&d&&this._capabilities.elicitation?.form?.applyDefaults)try{!function e(t,o){if(t&&null!==o&&"object"==typeof o){if("object"===t.type&&t.properties&&"object"==typeof t.properties){let r=t.properties;for(let t of Object.keys(r)){let i=r[t];void 0===o[t]&&Object.prototype.hasOwnProperty.call(i,"default")&&(o[t]=i.default),void 0!==o[t]&&e(i,o[t])}}if(Array.isArray(t.anyOf))for(let r of t.anyOf)"boolean"!=typeof r&&e(r,o);if(Array.isArray(t.oneOf))for(let r of t.oneOf)"boolean"!=typeof r&&e(r,o)}}(d,u.content)}catch{}return u}:"sampling/createMessage"===e?async(e,o)=>{let r=rO(this._negotiatedProtocolVersion),i=r.validateRequest("sampling/createMessage",e);
12if(i.ok||"not-in-era"!==i.reason||(i=r.validateInputRequest("sampling/createMessage",e)),!i.ok)throw new rp("not-in-era"===i.reason?rd.InternalError:rd.InvalidParams,"not-in-era"===i.reason?"No wire schema for sampling/createMessage in the resolved era":`Invalid sampling request: ${i.message}`);let{params:n}=i.value,a=await t(e,o),s=!!(n.tools||n.toolChoice),l=r.samplingResultVariant(s,a);if(l.ok||"not-in-era"!==l.reason||(l=r.validateInputResponse("sampling/createMessage",a)),!l.ok)throw new rp("not-in-era"===l.reason?rd.InternalError:rd.InvalidParams,"not-in-era"===l.reason?"No result schema for sampling/createMessage in the resolved era":`Invalid sampling result: ${l.message}`);return l.value}:t}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new oD(oz.CapabilityNotSupported,`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(t?.prior!=null)return this._connectFromPrior(e,function(e){if("object"==typeof e&&null!==e&&("legacy"===e.kind&&!("supportedVersions"in e)&&!("discover"in e)||"modern"===e.kind&&ew.safeParse(e.discover).success))return e;throw new oD(oz.EraNegotiationFailed,"connect({ prior }): unrecognized prior — expected { kind: 'modern', discover } or { kind: 'legacy' }")}(t.prior),t);let o=function(e,t){let o=e?.mode??"legacy";if("legacy"===o)return{kind:"legacy"};let r=e?.probe??{};if("object"==typeof o){if(!oJ(o.pin))throw TypeError(`versionNegotiation: { pin: '${o.pin}' } is not a modern protocol revision — pinning is for 2026-07-28 and later; omit versionNegotiation (or use mode: 'legacy') for 2025-era servers.`);return{kind:"pin",version:o.pin,probe:r}}let i=t?oK(t):[];return{kind:"auto",modernVersions:i.length>0?i:[...oB],fallbackAvailable:!t||oG(t).length>0,probe:r}}(this._versionNegotiation,this._supportedProtocolVersionsOption);return"legacy"!==o.kind?this._connectNegotiated(e,o,t):this._connectPlainLegacy(e,t)}async _connectPlainLegacy(e,t){if(await super.connect(e),void 0!==e.sessionId){let t=this._negotiatedProtocolVersion;void 0!==t&&e.setProtocolVersion?.(t);return}this._resetConnectionState(),await this._legacyHandshake(e,t)}async _legacyHandshake(e,t){let o=oG(this._supportedProtocolVersions);try{let r=o[0];if(void 0===r)throw new oD(oz.EraNegotiationFailed,"Cannot run the initialize handshake: supportedProtocolVersions contains no pre-2026-07-28 protocol version");let i=await this.request({method:"initialize",params:{protocolVersion:r,capabilities:this._capabilities,clientInfo:this._clientInfo}},t);if(void 0===i)throw Error(`Server sent invalid initialize result: ${i}`);if(!o.includes(i.protocolVersion))throw Error(`Server's protocol version is not supported: ${i.protocolVersion}`);this._serverCapabilities=i.capabilities,this._serverVersion=i.serverInfo,this._cache.setServerIdentity(this._deriveServerIdentity(e)),e.setProtocolVersion&&e.setProtocolVersion(i.protocolVersion),this._instructions=i.instructions,await this.notification({method:"notifications/initialized"}),this._negotiatedProtocolVersion=i.protocolVersion,this._listChangedConfig&&this._setupListChangedHandlers(this._listChangedConfig)}catch(e){throw this.close(),e}}async _connectNegotiated(e,t,o){let r;if(void 0!==e.sessionId){await super.connect(e);let t=this._negotiatedProtocolVersion;void 0!==t&&e.setProtocolVersion&&e.setProtocolVersion(t);return}this._resetConnectionState();try{let i=ab(e),n={clientInfo:this._clientInfo,capabilities:this._capabilities,environment:av(),defaultTimeoutMs:o?.timeout??6e4},a="stdio"===i?function(e){let t=Object.getPrototypeOf(e);if(null===t||!Object.prototype.hasOwnProperty.call(t,"_dispose"))return;let o=e._serverParams;return"object"==typeof o&&null!==o&&"string"==typeof o.command?o:void 0}(e):void 0;r=void 0===a?await aR(t,{...n,transport:e,transportKind:i}):await aC(t,e,a,n)}catch(t){throw await e.close().catch(()=>{}),aw(e),t}if(aw(e),await super.connect(e),"legacy"===r.era)return void await this._legacyHandshake(e,o);if(this._serverCapabilities=r.discover.capabilities,this._serverVersion=aT(r.discover),this._cache.setServerIdentity(this._deriveServerIdentity(e)),this._instructions=r.discover.instructions,this._discoverResult=r.discover,this._negotiatedProtocolVersion=r.version,e.setProtocolVersion&&e.setProtocolVersion(r.version),this._listChangedConfig){let e=this._listChangedConfig,t=this._serverCapabilities,r={...e.tools&&t?.tools?.listChanged&&{tools:e.tools},...e.prompts&&t?.prompts?.listChanged&&{prompts:e.prompts},...e.resources&&t?.resources?.listChanged&&{resources:e.resources}},i=!0;try{this._setupListChangedHandlers(r)}catch(e){i=!1,this.onerror?.(e instanceof Error?e:Error(String(e)))}let n=i?{...r.tools&&{toolsListChanged:!0},...r.prompts&&{promptsListChanged:!0},...r.resources&&{resourcesListChanged:!0}}:{};if(Object.keys(n).length>0){let e=new AbortController,t=()=>e.abort(o?.signal?.reason);o?.signal?.aborted&&t(),o?.signal?.addEventListener("abort",t);try{this._autoOpenedSubscription=await this.listen(n,{timeout:o?.timeout,signal:e.signal})}catch(e){if(o?.signal?.aborted)throw await this.close().catch(()=>{}),e;this.onerror?.(e instanceof Error?e:Error(String(e)))}finally{o?.signal?.removeEventListener("abort",t)}}}}async _connectFromPrior(e,t,o){if("legacy"===t.kind)return this._connectPlainLegacy(e,o);let r=t.discover;this._resetConnectionState();let i=this._supportedProtocolVersionsOption,n=(i&&oK(i).length>0?oK(i):oB).find(e=>r.supportedVersions.includes(e));if(void 0===n)throw new oD(oz.EraNegotiationFailed,"connect({ prior }) with a modern verdict requires a 2026-07-28+ mutual protocol version; the supplied DiscoverResult and this client's supportedProtocolVersions have no modern overlap. For a server known to be legacy, pass prior: { kind: 'legacy' } to skip the probe and initialize directly, or use versionNegotiation: { mode: 'auto' } to re-probe with legacy fallback.");
12if(await super.connect(e),this._discoverResult=r,this._serverCapabilities=r.capabilities,this._serverVersion=aT(r),this._cache.setServerIdentity(this._deriveServerIdentity(e)),this._instructions=r.instructions,this._negotiatedProtocolVersion=n,e.setProtocolVersion?.(n),this._listChangedConfig)try{this._setupListChangedHandlers(this._listChangedConfig)}catch(e){this.onerror?.(e instanceof Error?e:Error(String(e)))}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}_deriveServerIdentity(e){let t=this._serverVersion;return void 0!==t?`${t.name}@${t.version}`:e.sessionId??`anonymous:${Date.now()}-${Math.random().toString(36).slice(2)}`}getNegotiatedProtocolVersion(){return this._negotiatedProtocolVersion}getProtocolEra(){let e=this._negotiatedProtocolVersion;if(void 0!==e)return oJ(e)?"modern":"legacy"}getInstructions(){return this._instructions}getDiscoverResult(){return this._discoverResult}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new oD(oz.CapabilityNotSupported,`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new oD(oz.CapabilityNotSupported,`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!this._serverCapabilities?.resources)throw new oD(oz.CapabilityNotSupported,`Server does not support resources (required for ${e})`);if("resources/subscribe"===e&&!this._serverCapabilities.resources.subscribe)throw new oD(oz.CapabilityNotSupported,`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new oD(oz.CapabilityNotSupported,`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new oD(oz.CapabilityNotSupported,`Server does not support completions (required for ${e})`)}}assertNotificationCapability(e){if("notifications/roots/list_changed"===e&&!this._capabilities.roots?.listChanged)throw new oD(oz.CapabilityNotSupported,`Client does not support roots list changed notifications (required for ${e})`)}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new oD(oz.CapabilityNotSupported,`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new oD(oz.CapabilityNotSupported,`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new oD(oz.CapabilityNotSupported,`Client does not support roots capability (required for ${e})`)}}async ping(e){return this.request({method:"ping"},e)}async discover(e){let t=await this._requestWithSchema({method:"server/discover"},ew,e);return this._discoverResult=t,t}async complete(e,t){return this.request({method:"completion/complete",params:e},t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},t)}async listPrompts(e,t){if(!this._serverCapabilities?.prompts&&!this._enforceStrictCapabilities)return console.debug("Client.listPrompts() called but server does not advertise prompts capability - returning empty list"),{prompts:[]};if(e?.cursor!==void 0)return this.request({method:"prompts/list",params:e},t);let o=await this._serveFromCache("prompts/list",void 0,t);return void 0!==o?o:this._listAllPages("prompts/list",e,t,(e,t)=>e.prompts.push(...t.prompts))}async listResources(e,t){if(!this._serverCapabilities?.resources&&!this._enforceStrictCapabilities)return console.debug("Client.listResources() called but server does not advertise resources capability - returning empty list"),{resources:[]};if(e?.cursor!==void 0)return this.request({method:"resources/list",params:e},t);let o=await this._serveFromCache("resources/list",void 0,t);return void 0!==o?o:this._listAllPages("resources/list",e,t,(e,t)=>e.resources.push(...t.resources))}async listResourceTemplates(e,t){if(!this._serverCapabilities?.resources&&!this._enforceStrictCapabilities)return console.debug("Client.listResourceTemplates() called but server does not advertise resources capability - returning empty list"),{resourceTemplates:[]};if(e?.cursor!==void 0)return this.request({method:"resources/templates/list",params:e},t);let o=await this._serveFromCache("resources/templates/list",void 0,t);return void 0!==o?o:this._listAllPages("resources/templates/list",e,t,(e,t)=>e.resourceTemplates.push(...t.resourceTemplates))}async _listAllPages(e,t,o,r,i){let n=o?.cacheMode==="bypass",a=this._cache.captureGeneration(e),s=await this.request({method:e,...t&&{params:{...t}}},o),l=s.nextCursor,c=new Set,u=1;for(;void 0!==l&&!c.has(l);){if(0!==this._listMaxPages&&u>=this._listMaxPages)throw new oD(oz.ListPaginationExceeded,`${e}: exceeded listMaxPages (${this._listMaxPages}); server pagination did not terminate`,{method:e,listMaxPages:this._listMaxPages});c.add(l);let i=await this.request({method:e,params:{...t,cursor:l}},o);r(s,i),l=i.nextCursor,u++}return delete s.nextCursor,i?.(s),n||await this._cache.write(e,s,a,this._freshness(s)),s}_freshness(e,t){let o="number"==typeof e.ttlMs?e.ttlMs:this._defaultCacheTtlMs,r="public"===e.cacheScope?"public":"private";return{expiresAt:this._cache.now()+Math.min(Math.max(0,o),864e5),scope:r,params:t}}
12async _serveFromCache(e,t,o){if(o?.cacheMode==="bypass"||o?.cacheMode==="refresh")return;let r=await this._cache.read(e,t).catch(e=>void this._reportStoreError(e));if(void 0!==r){if(o?.signal?.aborted){let e=o.signal.reason;throw e instanceof oD?e:new oD(oz.RequestTimeout,String(e))}return r.value}}_reportStoreError(e){this.onerror?.(e instanceof Error?e:Error(String(e)))}_compileOutputValidator(e){if(e.outputSchema)try{return{ok:!0,validator:this._jsonSchemaValidator.getValidator(e.outputSchema)}}catch(e){return{ok:!1,compileError:e}}}async _resolveXMcpHeaderScan(e,t){let o=t??await this._cache.toolDefinition(e);return void 0===o?void 0:rG(o.inputSchema)}async readResource(e,t){let o=await this._serveFromCache("resources/read",e.uri,t);if(void 0!==o)return o;let r=this._cache.captureGeneration("resources/read",e.uri),i=await this.request({method:"resources/read",params:e},t);if(t?.cacheMode!=="bypass"){let o=this._freshness(i,e.uri);o.expiresAt>this._cache.now()?await this._cache.write("resources/read",i,r,o):t?.cacheMode==="refresh"&&await this._cache.evictKey("resources/read",e.uri)}return i}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},t)}async listen(e,t){let o,r,i,n,a;if(void 0===this.transport)throw new oD(oz.NotConnected,"Not connected");let s=this._negotiatedProtocolVersion;if(void 0===s||!oJ(s))throw new oD(oz.MethodNotSupportedByProtocolVersion,`subscriptions/listen requires a 2026-07-28-era connection (negotiated: ${s??"none"}). On a 2025-era connection, change notifications are delivered unsolicited: use ClientOptions.listChanged and resources/subscribe instead.`,{method:"subscriptions/listen",protocolVersion:s});if(t?.signal?.aborted){let e=t.signal.reason;throw e instanceof oD?e:new oD(oz.RequestTimeout,String(e))}let l=new AbortController,c=`listen:${this._nextListenId++}`,u="opening",d=new Promise((e,t)=>{i=e,n=t}),p=new Promise(e=>{a=e}),h=e=>{if("closed"===u)return;let s="opening"===u;if(void 0!==o&&(clearTimeout(o),o=void 0),"ack"in e){u="open",i(e.ack);return}u="closed",void 0!==r&&t?.signal?.removeEventListener("abort",r),this._listenState.delete(c),l.abort(),a(e.cause),s&&n(e.error??new oD(oz.ConnectionClosed,"subscriptions/listen closed before the server acknowledged"))},m=async()=>{l.abort(),await this.notification({method:"notifications/cancelled",params:{requestId:c}}).catch(()=>{})},f=async()=>{"closed"!==u&&(h({cause:"local"}),await m())};this._listenState.set(c,{settle:h});let g=t?.timeout??6e4;if(o=setTimeout(()=>{h({cause:"remote",error:new oD(oz.RequestTimeout,"subscriptions/listen ack timed out",{timeout:g})}),m().catch(()=>{})},g),t?.signal){let e=t.signal;r=()=>{if("closed"===u)return;let t=e.reason;h({cause:"local",error:t instanceof Error?t:Error(String(t??"Aborted"))}),m().catch(()=>{})},e.addEventListener("abort",r,{once:!0})}let S={jsonrpc:"2.0",id:c,method:"subscriptions/listen",params:{_meta:{...this._outboundMetaEnvelope()},notifications:e}};try{await this.transport.send(S,{requestSignal:l.signal,onRequestStreamEnd:()=>h({cause:"remote",error:Error("subscriptions/listen: stream ended")})})}catch(e){h({cause:"remote",error:e instanceof Error?e:Error(String(e))})}return{honoredFilter:await d,close:f,closed:p}}get autoOpenedSubscription(){return this._autoOpenedSubscription}_onnotification(e,t){let o=Object.hasOwn(aE,e.method)?aE[e.method]:void 0;if("notifications/resources/updated"===e.method){let t=e.params?.uri;"string"==typeof t&&this._cache.evictKey("resources/read",t)}else if(void 0!==o)for(let e of o)this._cache.evict(e);if("notifications/subscriptions/acknowledged"===e.method){let t=e.params?._meta?.[$],o="string"==typeof t?this._listenState.get(t):void 0;if(void 0!==o){let t=this._wireCodec().validateNotification("notifications/subscriptions/acknowledged",e);o.settle({ack:t.ok?t.value.params.notifications:{}});return}}if("notifications/cancelled"===e.method){let t=e.params?.requestId,o="string"==typeof t?this._listenState.get(t):void 0;if(void 0!==o)return void o.settle({cause:"remote",error:Error("subscriptions/listen: server cancelled the subscription")})}super._onnotification(e,t)}_onresponse(e){let t=e.id,o="string"==typeof t?this._listenState.get(t):void 0;void 0!==o?rD(e)?o.settle({cause:"remote",error:rp.fromError(e.error.code,e.error.message,e.error.data)}):o.settle({cause:"graceful",error:new oD(oz.ConnectionClosed,"subscriptions/listen: server closed the subscription gracefully before acknowledging")}):super._onresponse(e)}_onclose(){if(this._listenState.size>0){let e=new oD(oz.ConnectionClosed,"Connection closed");for(let t of this._listenState.values())t.settle({cause:"remote",error:e});this._listenState.clear()}super._onclose()}async callTool(e,t){let o,r="modern"===this.getProtocolEra()&&"browser"!==av(),i=async()=>{let o;if(!r)return t;try{o=await this._resolveXMcpHeaderScan(e.name,t?.toolDefinition)}catch(e){this._reportStoreError(e)}if(!o?.valid||0===o.declarations.length)return t;let i=r1(o.declarations,e.arguments);return 0===Object.keys(i).length?t:{...t,headers:{...t?.headers,...i}}},n=t?.toolDefinition===void 0?await this._cache.outputValidator(e.name,e=>this._compileOutputValidator(e)).catch(e=>void this._reportStoreError(e)):this._compileOutputValidator(t.toolDefinition),a=()=>
12{if(void 0===n||n.ok)return;let t=n.compileError,o=(t instanceof Error?t.message:String(t)).slice(0,200);throw new rp(rd.InvalidParams,`Tool '${e.name}' has an invalid outputSchema: ${o}`)};a();try{o=await this.request({method:"tools/call",params:e},await i())}catch(c){let s=c instanceof rp&&-32020===c.code;if(!r||!s||t?.toolDefinition!==void 0)throw c;let l={signal:t?.signal,timeout:t?.timeout,cacheMode:"refresh"};await this._cache.evict("tools/list"),await this.listTools(void 0,l).catch(e=>this._reportStoreError(e)),n=await this._cache.outputValidator(e.name,e=>this._compileOutputValidator(e)).catch(e=>void this._reportStoreError(e)),a(),o=await this.request({method:"tools/call",params:e},await i())}let s=void 0!==n&&n.ok?n.validator:void 0;if(s){if(void 0===o.structuredContent&&!o.isError)throw new rp(rd.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(void 0!==o.structuredContent&&!o.isError)try{let e=s(o.structuredContent);if(!e.valid)throw new rp(rd.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)}catch(e){if(e instanceof rp)throw e;throw new rp(rd.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)}}return o}async listTools(e,t){if(!this._serverCapabilities?.tools&&!this._enforceStrictCapabilities)return console.debug("Client.listTools() called but server does not advertise tools capability - returning empty list"),{tools:[]};if(e?.cursor!==void 0){let o=await this.request({method:"tools/list",params:e},t);return this._excludeInvalidXMcpHeaderTools(o),o}let o=await this._serveFromCache("tools/list",void 0,t);return void 0!==o?o:this._listAllPages("tools/list",e,t,(e,t)=>e.tools.push(...t.tools),e=>this._excludeInvalidXMcpHeaderTools(e))}_excludeInvalidXMcpHeaderTools(e){if("modern"!==this.getProtocolEra()||!this.transport||"stdio"===ab(this.transport))return;let t=e.tools.filter(e=>{let t=rG(e.inputSchema);return!!t.valid||(console.warn(`[mcp-sdk] excluding tool '${e.name}' from tools/list: invalid x-mcp-header declaration — ${t.reason}`),!1)});t.length!==e.tools.length&&(e.tools=t)}_setupListChangedHandler(e,t,o,r){let i=r2(tb,o);if(!i.success)throw Error(`Invalid ${e} listChanged options: ${i.error.message}`);if("function"!=typeof o.onChanged)throw TypeError(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:n,debounceMs:a}=i.data,{onChanged:s}=o,l=async()=>{if(!n)return void s(null,null);try{s(null,await r())}catch(e){s(e instanceof Error?e:Error(String(e)),null)}},c=()=>{if(a){let t=this._listChangedDebounceTimers.get(e);t&&clearTimeout(t);let o=setTimeout(l,a);this._listChangedDebounceTimers.set(e,o)}else l()};this.setNotificationHandler(t,c)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};(class extends Error{static{Object.defineProperty(this,"mcpBrand",{value:"mcp.SseError"})}static[Symbol.hasInstance](e){return oA(this,e)}static isInstance(e){if("function"!=typeof this)throw TypeError("isInstance must be called on the class (e.g. `SdkError.isInstance(value)`); for callbacks use `v => SdkError.isInstance(v)`");return oA(this,e)}constructor(e,t,o){super(`SSE error: ${t}`),this.code=e,this.event=o,oL(this,new.target)}});let aP={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},aq=new Set(["authorization","content-type","mcp-protocol-version","mcp-method","mcp-name","mcp-session-id"]);function aj(e,t){if("function"==typeof AbortSignal.any)return AbortSignal.any([e,t]);let o=new AbortController;if(e.aborted)return o.abort(e.reason),o.signal;if(t.aborted)return o.abort(t.reason),o.signal;let r=()=>{e.removeEventListener("abort",i),t.removeEventListener("abort",n)};function i(){r(),o.abort(e.reason)}function n(){r(),o.abort(t.reason)}return e.addEventListener("abort",i,{once:!0}),t.addEventListener("abort",n,{once:!0}),o.signal}var aO=class{_abortController;_url;_resourceMetadataUrl;_scope;_requestInit;_authProvider;_oauthProvider;_skipIssuerMetadataValidation;_fetch;_fetchWithInit;_sessionId;_reconnectionOptions;_protocolVersion;_onInsufficientScope;_maxStepUpRetries;_serverRetryMs;_reconnectionScheduler;_cancelReconnection;onclose;onerror;onmessage;hasPerRequestStream=!0;constructor(e,t){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._skipIssuerMetadataValidation=t?.skipIssuerMetadataValidation,function(e){return null!=e&&"function"==typeof e.tokens&&"function"==typeof e.clientInformation}(t?.authProvider)?(this._oauthProvider=t.authProvider,this._authProvider=function(e,t){return{token:async()=>(await e.tokens())?.access_token,onUnauthorized:async o=>nF(e,o,t)}}(t.authProvider,{skipIssuerMetadataValidation:t.skipIssuerMetadataValidation})):this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=iq(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._protocolVersion=t?.protocolVersion,this._reconnectionOptions=t?.reconnectionOptions??aP,this._reconnectionScheduler
12=t?.reconnectionScheduler,this._onInsufficientScope=t?.onInsufficientScope??"reauthorize",this._maxStepUpRetries=Math.max(0,t?.maxStepUpRetries??1)}async _stepUpAuthorize(e,t){try{return await this._stepUpAuthorizeInner(e,t)}catch(e){throw am(e)}}async _stepUpAuthorizeInner(e,t){if("throw"===this._onInsufficientScope||!this._oauthProvider)throw new nD({requiredScope:e.scope,resourceMetadataUrl:e.resourceMetadataUrl,errorDescription:e.errorDescription});if(t>=this._maxStepUpRetries)throw new oV(oz.ClientHttpForbidden,`Server returned 403 insufficient_scope after step-up re-authorization (retry limit ${this._maxStepUpRetries} reached)`,{status:403,statusText:e.statusText??"Forbidden",text:e.text});e.resourceMetadataUrl&&(this._resourceMetadataUrl=e.resourceMetadataUrl);let o=await this._oauthProvider.tokens(),r=nG(this._scope,o?.scope,e.scope);this._scope=r;let i=function(e,t){if(!e)return!1;let o=new Set((t??"").split(/\s+/).filter(Boolean));for(let t of e.split(/\s+/))if(t&&!o.has(t))return!0;return!1}(r,o?.scope);return n1(this._oauthProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:r,forceReauthorization:i,fetchFn:this._fetchWithInit,skipIssuerMetadataValidation:this._skipIssuerMetadataValidation})}async _commonHeaders(){let e,t={};try{e=await this._authProvider?.token()}catch(e){throw am(e)}e&&(t.Authorization=`Bearer ${e}`),this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);let o=iP(this._requestInit?.headers);return new Headers({...t,...o})}_applyBodyDerivedHeaders(e,t){if(Array.isArray(t)||!rZ(t))return;let o=t.params?._meta?.[P];if("string"!=typeof o)return;e.set("mcp-protocol-version",o),e.set("mcp-method",t.method);let r=t.params,i="resources/read"===t.method?"string"==typeof r?.uri?r.uri:void 0:"string"==typeof r?.name?r.name:void 0;void 0!==i&&e.set("mcp-name",r0(i))}_isModernEnvelopedRequest(e){if(Array.isArray(e)||!rZ(e))return!1;let t=e.params?._meta?.[P];return"string"==typeof t&&oJ(t)}async _startOrAuthSse(e,t=!1,o=0){let{resumptionToken:r,requestSignal:i}=e,n=()=>this._abortController?.signal.aborted===!0||i?.aborted===!0;try{let n=await this._commonHeaders(),a=[...n.get("accept")?.split(",").map(e=>e.trim().toLowerCase())??[],"text/event-stream"];
12n.set("accept",[...new Set(a)].join(", ")),r&&n.set("last-event-id",r);let s=this._abortController?.signal,l=void 0!==i&&void 0!==s?aj(s,i):i??s,c=await (this._fetch??fetch)(this._url,{...this._requestInit,method:"GET",headers:n,signal:l});if(!c.ok){if(401===c.status&&this._authProvider){if(c.headers.has("www-authenticate")){let{resourceMetadataUrl:e,scope:t}=n6(c);this._resourceMetadataUrl=e,this._scope=nG(this._scope,t)}if(this._authProvider.onUnauthorized&&!t){try{await this._authProvider.onUnauthorized({response:c,serverUrl:this._url,fetchFn:this._fetchWithInit})}catch(e){throw am(e)}return await c.text?.().catch(()=>{}),this._startOrAuthSse(e,!0,o)}if(await c.text?.().catch(()=>{}),t)throw am(new oV(oz.ClientHttpAuthentication,"Server returned 401 after re-authentication",{status:401,statusText:c.statusText}));throw am(new nW)}if(403===c.status){let{resourceMetadataUrl:r,scope:i,error:n,errorDescription:a}=n6(c);if("insufficient_scope"===n){let n=await c.text?.().catch(()=>null);if(await this._stepUpAuthorize({scope:i,resourceMetadataUrl:r,errorDescription:a,statusText:c.statusText,text:n},o)!=="AUTHORIZED")throw am(new nW);return this._startOrAuthSse(e,t,o+1)}}if(await c.text?.().catch(()=>{}),405===c.status)return void e.onRequestStreamEnd?.();throw new oV(oz.ClientHttpFailedToOpenStream,`Failed to open SSE stream: ${c.statusText}`,{status:c.status,statusText:c.statusText})}this._handleSseStream(c.body,e,!0)}catch(e){throw n()||this.onerror?.(e),e}}_getNextReconnectionDelay(e){return void 0!==this._serverRetryMs?this._serverRetryMs:Math.min(this._reconnectionOptions.initialReconnectionDelay*Math.pow(this._reconnectionOptions.reconnectionDelayGrowFactor,e),this._reconnectionOptions.maxReconnectionDelay)}_scheduleReconnection(e,t=0){let o=this._reconnectionOptions.maxRetries;if(t>=o){this.onerror?.(Error(`Maximum reconnection attempts (${o}) exceeded.`)),e.onRequestStreamEnd?.();return}let r=this._getNextReconnectionDelay(t),i=()=>{this._cancelReconnection=void 0,this._abortController?.signal.aborted||e.requestSignal?.aborted||this._startOrAuthSse(e).catch(o=>{if(!(this._abortController?.signal.aborted||e.requestSignal?.aborted)){this.onerror?.(Error(`Failed to reconnect SSE stream: ${o instanceof Error?o.message:String(o)}`));try{this._scheduleReconnection(e,t+1)}catch(e){this.onerror?.(e instanceof Error?e:Error(String(e)))}}})};if(this._reconnectionScheduler){let e=this._reconnectionScheduler(i,r,t);this._cancelReconnection="function"==typeof e?e:void 0}else{let e=setTimeout(i,r);this._cancelReconnection=()=>clearTimeout(e)}}_handleSseStream(e,t,o){let r;if(!e)return void t.onRequestStreamEnd?.();let{onresumptiontoken:i,replayMessageId:n,requestSignal:a,onRequestStreamEnd:s}=t,l=()=>this._abortController?.signal.aborted===!0||a?.aborted===!0,c=!1,u=!1;(async()=>{try{let t=e.pipeThrough(new TextDecoderStream).pipeThrough(new nN({onRetry:e=>{this._serverRetryMs=e}})).getReader();for(;;){let{value:e,done:o}=await t.read();if(o)break;if((e.id&&(r=e.id,c=!0,i?.(e.id)),e.data)&&(!e.event||"message"===e.event))try{let t=eo.parse(JSON.parse(e.data));(rz(t)||rD(t))&&(u=!0,void 0!==n&&(t.id=n)),this.onmessage?.(t)}catch(e){this.onerror?.(e)}}(o||c)&&!u&&this._abortController&&!l()?this._scheduleReconnection({resumptionToken:r,onresumptiontoken:i,replayMessageId:n,requestSignal:a,onRequestStreamEnd:s},0):l()||s?.()}catch(e){if(l())return;if(this.onerror?.(Error(`SSE stream disconnected: ${e}`)),(o||c)&&!u&&this._abortController&&!l())try{this._scheduleReconnection({resumptionToken:r,onresumptiontoken:i,replayMessageId:n,requestSignal:a,onRequestStreamEnd:s},0)}catch(e){this.onerror?.(Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`)),s?.()}else s?.()}})()}async start(){if(this._abortController)throw Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e,t){if(!this._oauthProvider)throw new nW("finishAuth requires an OAuthClientProvider");let{authorizationCode:o,iss:r}=await nK(e,t,this._oauthProvider,this._url,{fetchFn:this._fetchWithInit,resourceMetadataUrl:this._resourceMetadataUrl});if(await n1(this._oauthProvider,{serverUrl:this._url,authorizationCode:o,iss:r,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit,skipIssuerMetadataValidation:this._skipIssuerMetadataValidation})!=="AUTHORIZED")throw new nW("Failed to authorize")}async close(){try{this._cancelReconnection?.()}finally{this._cancelReconnection=void 0,this._abortController?.abort(),this.onclose?.()}}async send(e,t){return this._send(e,t,!1)}async _send(e,t,o,r=0){try{let{resumptionToken:i,onresumptiontoken:n}=t||{};if(i)return void this._startOrAuthSse({resumptionToken:i,replayMessageId:rZ(e)?e.id:void 0,requestSignal:t?.requestSignal}).catch(e=>this.onerror?.(e));let a=await this._commonHeaders();this._applyBodyDerivedHeaders(a,e);let s=Array.isArray(e)?e.some(e=>rH(e)):rH(e);if(s&&a.delete("mcp-session-id"),t?.headers!==void 0)for(let[e,o]of Object.entries(t.headers))aq.has(e.toLowerCase())||a.set(e,o);a.set("content-type","application/json");let l=[...a.get("accept")?.split(",").map(e=>e.trim().toLowerCase())??[],"application/json","text/event-stream"];a.set("accept",[...new Set(l)].join(", "));let c=this._abortController?.signal,u=t?.requestSignal!==void 0&&void 0!==c?aj(c,t.requestSignal):t?.requestSignal??c,d={...this._requestInit,method:"POST",headers:a,body:JSON.stringify(e),signal:u},p=await (this._fetch??fetch)(this._url,d);if(s&&p.ok&&(this._sessionId=p.headers.get("mcp-session-id")||void 0),!p.ok){if(401===p.status&&this._authProvider){if(p.headers.has("www-authenticate")){let{resourceMetadataUrl:e,scope:t}=n6(p);this._resourceMetadataUrl=e,this._scope=nG(this._scope,t)}if(this._authProvider.onUnauthorized&&!o){try{await this._authProvider.onUnauthorized({response:p,serverUrl:this._url,fetchFn:this._fetchWithInit})}catch(e){throw am(e)}return await p.text?.().catch(()=>{}),this._send(e,t,!0,r)}if(await p.text?.().catch(()=>{}),o)throw am(new oV(oz.ClientHttpAuthentication,"Server returned 401 after re-authentication",{status:401,statusText:p.statusText}));throw am(new nW)}let i=await p.text?.().catch(()=>null);if(403===p.status){let{resourceMetadataUrl:n,scope:a,error:s,errorDescription:l}=n6(p);if("insufficient_scope"===s){if(await this._stepUpAuthorize({scope:a,resourceMetadataUrl:n,errorDescription:l,statusText:p.statusText,text:i},r)!=="AUTHORIZED")throw am(new nW);return this._send(e,t,o,r+1)}}if(400===p.status&&"string"==typeof i&&this._isModernEnvelopedRequest(e))try{let t=eo.parse(JSON.parse(i)),o=(Array.isArray(e)?e:[e]).filter(e=>rZ(e));if(rD(t)&&o.some(e=>e.id===t.id))return void this.onmessage?.(t)}catch{}throw new oV(oz.ClientHttpNotImplemented,`Error POSTing to endpoint: ${i}`,{status:p.status,statusText:p.statusText,text:i})}if(202===p.status){await p.text?.().catch(()=>{}),rF(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(e=>this.onerror?.(e));return}let h=(Array.isArray(e)?e:[e]).some(e=>"method"in e&&"id"in e&&void 0!==e.id),m=p.headers.get("content-type"),f=iT(m);
12if(h)if("text/event-stream"===f)this._handleSseStream(p.body,{onresumptiontoken:n,requestSignal:t?.requestSignal,onRequestStreamEnd:t?.onRequestStreamEnd},!1);else if("application/json"===f){let e=await p.json();for(let t of Array.isArray(e)?e.map(e=>eo.parse(e)):[eo.parse(e)])this.onmessage?.(t)}else throw await p.text?.().catch(()=>{}),new oD(oz.ClientHttpUnexpectedContent,`Unexpected content type: ${m}`,{contentType:m});else await p.text?.().catch(()=>{})}catch(e){throw t?.requestSignal?.aborted!==!0&&this.onerror?.(e),e}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),t={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},o=await (this._fetch??fetch)(this._url,t);if(await o.text?.().catch(()=>{}),!o.ok&&405!==o.status)throw new oV(oz.ClientHttpFailedToTerminateSession,`Failed to terminate session: ${o.statusText}`,{status:o.status,statusText:o.statusText});this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}};e.s(["Client",0,aI,"InsufficientScopeError",0,nD,"StreamableHTTPClientTransport",0,aO,"UnauthorizedError",0,nW,"auth",0,n1,"discoverOAuthProtectedResourceMetadata",0,n5,"discoverOAuthServerInfo",0,ao,"extractWWWAuthenticateParams",0,n6,"validateClientMetadataUrl",0,function(e){if(e&&!n4(e))throw new oU(oZ.InvalidClientMetadata,`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${e}`)}],178610),e.s(["SdkError",0,oD],613952),e.s(["SdkHttpError",0,oV],363501),e.s([],964812),e.s(["CfWorkerJsonSchemaValidator",0,iQ],85573)}]);
13
14//# chunkId=bafe9a9f-9f0e-52be-8a95-8049c9a9e0b1

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.