xmcp 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -222,7 +222,7 @@ Please re-run the build so the framework can regenerate the bundle.`);let s=o.js
222
222
  <div id="root"></div>
223
223
  ${e}
224
224
  </body>
225
- </html>`);return{contents:[{uri:r.uri,text:c,mimeType:i,_meta:r._meta}]}}catch(e){throw console.error(`React failed for ${r.name}:`,e),e}let a=r.handler({},t);if(a instanceof Promise&&(a=await a),"string"==typeof a)return{contents:[{uri:r.uri,text:a,mimeType:i,_meta:r._meta}]};if(a&&"object"==typeof a&&"_meta"in a&&!("content"in a))return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]};if(a&&"object"==typeof a&&"content"in a&&Array.isArray(a.content)){let e=a.content.find(e=>"text"===e.type);if(e&&"text"===e.type&&"string"==typeof e.text)return{contents:[{uri:r.uri,text:e.text,mimeType:i,_meta:r._meta}]}}return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]}};e.registerResource(r.name,r.uri,a,o)}),i.forEach((t,r)=>{let i={name:pq(r),description:"No description provided"},{default:n,metadata:a,schema:o}=t;"object"==typeof a&&null!==a&&Object.assign(i,a);let s={};pI(o)?s=o:null!=o&&console.warn(`Invalid schema for resource "${i.name}" at ${r}. Expected Record<string, z.ZodType>`);let l=pO(r);if(!l)return void console.warn(`Skipping resource "${i.name}" at ${r}: Invalid file path format`);let c=l.uriTemplate;i.mimeType&&i.mimeType.includes("html")&&(c=c.endsWith(".html")?c:`${c}.html`);let d=function(e,t,r={}){let i=pO(t);if(!i)throw Error(`Invalid resource file path: ${t}. Must follow (scheme)/path/[param] convention.`);return async(t,n)=>{let a=e(function(e,t,r){let i={},n={};if(0===t.parameters.length)return n;let a=t.uriTemplate.split("://")[1]||"",o=e.split("://")[1]||"",s=a.split("/"),l=o.split("/");for(let e=0;e<s.length&&e<l.length;e++){let t=s[e],r=l[e],n=t.match(/^\{(.+)\}$/);n&&(i[n[1]]=r)}for(let e of t.parameters){let t=i[e],a=r[e];if(void 0===t)throw Error(`Missing required parameter: ${e}`);if(!a){n[e]=t;continue}try{n[e]=a.parse(t)}catch(r){throw Error(`Invalid parameter "${e}": ${t}. Validation error: ${r instanceof Error?r.message:String(r)}`)}}return n}(t.href,i,r),n);if(a instanceof Promise&&(a=await a),"string"==typeof a)return{contents:[{uri:t.href,text:a}]};if(!a||"object"!=typeof a||!Array.isArray(a.contents)){let e=null===a?"null":typeof a,t=void 0===a?"undefined":null===a?"null":"object"==typeof a?JSON.stringify(a,null,2):String(a);throw Error(`Resource handler must return a ReadResourceResult or string. Got ${e}: ${t}
225
+ </html>`);return{contents:[{uri:r.uri,text:c,mimeType:i,_meta:r._meta}]}}catch(e){throw console.error(`React failed for ${r.name}:`,e),e}let a=r.handler({},t);if(a instanceof Promise&&(a=await a),"string"==typeof a)return{contents:[{uri:r.uri,text:a,mimeType:i,_meta:r._meta}]};if(a&&"object"==typeof a&&"_meta"in a&&!("content"in a))return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]};if(a&&"object"==typeof a&&"content"in a&&Array.isArray(a.content)){let e=a.content.find(e=>"text"===e.type);if(e&&"text"===e.type&&"string"==typeof e.text)return{contents:[{uri:r.uri,text:e.text,mimeType:i,_meta:r._meta}]}}return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]}};e.registerResource(r.name,r.uri,a,o)}),i.forEach((t,r)=>{let i={name:pq(r),description:"No description provided"},{default:n,metadata:a,schema:o,complete:s}=t;"object"==typeof a&&null!==a&&Object.assign(i,a);let l={};pI(o)?l=o:null!=o&&console.warn(`Invalid schema for resource "${i.name}" at ${r}. Expected Record<string, z.ZodType>`);let c=pO(r);if(!c)return void console.warn(`Skipping resource "${i.name}" at ${r}: Invalid file path format`);let d=c.uriTemplate;i.mimeType&&i.mimeType.includes("html")&&(d=d.endsWith(".html")?d:`${d}.html`);let u=function(e,t,r={}){let i=pO(t);if(!i)throw Error(`Invalid resource file path: ${t}. Must follow (scheme)/path/[param] convention.`);return async(t,n)=>{let a=e(function(e,t,r){let i={},n={};if(0===t.parameters.length)return n;let a=t.uriTemplate.split("://")[1]||"",o=e.split("://")[1]||"",s=a.split("/"),l=o.split("/");for(let e=0;e<s.length&&e<l.length;e++){let t=s[e],r=l[e],n=t.match(/^\{(.+)\}$/);n&&(i[n[1]]=r)}for(let e of t.parameters){let t=i[e],a=r[e];if(void 0===t)throw Error(`Missing required parameter: ${e}`);if(!a){n[e]=t;continue}try{n[e]=a.parse(t)}catch(r){throw Error(`Invalid parameter "${e}": ${t}. Validation error: ${r instanceof Error?r.message:String(r)}`)}}return n}(t.href,i,r),n);if(a instanceof Promise&&(a=await a),"string"==typeof a)return{contents:[{uri:t.href,text:a}]};if(!a||"object"!=typeof a||!Array.isArray(a.contents)){let e=null===a?"null":typeof a,t=void 0===a?"undefined":null===a?"null":"object"==typeof a?JSON.stringify(a,null,2):String(a);throw Error(`Resource handler must return a ReadResourceResult or string. Got ${e}: ${t}
226
226
 
227
227
  Expected ReadResourceResult format:
228
228
  {
@@ -231,7 +231,7 @@ Expected ReadResourceResult format:
231
231
  { uri: "resource://uri", mimeType: "application/json", text: "json content" },
232
232
  { uri: "resource://uri", blob: base64data }
233
233
  ]
234
- }`)}return a.contents.forEach(e=>{e.uri||(e.uri=t.href)}),a}}(n,r,s);if("direct"===l.type)e.registerResource(i.name,c,i,d);else{let t=new c2(c,{list:void 0}),r=async(e,t,r)=>{let i={};for(let e of l.parameters){let r=t[e],n=s[e];if(void 0===r)throw Error(`Missing required parameter: ${e}. Available variables: ${Object.keys(t)}`);n?i[e]=n.parse(r):i[e]=r}let a=n(i,r);return a instanceof Promise&&(a=await a),"string"==typeof a?{contents:[{uri:e.href,text:a}]}:a};e.registerResource(i.name,t,i,r)}})}),e}async function pG(){let{toolModules:e,skippedTools:t}=await pH(pV);return pF(t),e}async function pK(){let{promptModules:e,skippedPrompts:t}=await pL(pD);return pN(t),e}async function pY(){let{resourceModules:e,skippedResources:t}=await pM(pJ);return pZ(t),e}async function pX(){let{instructions:e,...t}=pB,r=new c1(t,{instructions:e}),i=pG(),n=pK(),a=pY(),[o,s,l]=await Promise.all([i,n,a]);return pW(r,o,s,l)}let pQ="This MCP server was bootstrapped with xmcp.",p0={cursor:`
234
+ }`)}return a.contents.forEach(e=>{e.uri||(e.uri=t.href)}),a}}(n,r,l);if("direct"===c.type)e.registerResource(i.name,d,i,u);else{let t=Object.create(null);for(let e of c.parameters)s&&Object.hasOwn(s,e)&&(t[e]=s[e]);let r=new c2(d,{list:void 0,complete:t}),a=async(e,t,r)=>{let i={};for(let e of c.parameters){let r=t[e],n=l[e];if(void 0===r)throw Error(`Missing required parameter: ${e}. Available variables: ${Object.keys(t)}`);n?i[e]=n.parse(r):i[e]=r}let a=n(i,r);return a instanceof Promise&&(a=await a),"string"==typeof a?{contents:[{uri:e.href,text:a}]}:a};e.registerResource(i.name,r,i,a)}})}),e}async function pG(){let{toolModules:e,skippedTools:t}=await pH(pV);return pF(t),e}async function pK(){let{promptModules:e,skippedPrompts:t}=await pL(pD);return pN(t),e}async function pY(){let{resourceModules:e,skippedResources:t}=await pM(pJ);return pZ(t),e}async function pX(){let{instructions:e,...t}=pB,r=new c1(t,{instructions:e}),i=pG(),n=pK(),a=pY(),[o,s,l]=await Promise.all([i,n,a]);return pW(r,o,s,l)}let pQ="This MCP server was bootstrapped with xmcp.",p0={cursor:`
235
235
  <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
236
236
  <g clip-path="url(#cursor)">
237
237
  <path d="M18.1937 4.73376L10.1872 0.111231C9.93007 -0.0372398 9.61283 -0.0372398 9.35573 0.111231L1.34956 4.73376C1.13344 4.85855 1 5.08934 1 5.33929V14.6606C1 14.9106 1.13344 15.1414 1.34956 15.2662L9.3561 19.8887C9.6132 20.0372 9.93044 20.0372 10.1875 19.8887L18.1941 15.2662C18.4102 15.1414 18.5436 14.9106 18.5436 14.6606V5.33929C18.5436 5.08934 18.4102 4.85855 18.1941 4.73376H18.1937ZM17.6908 5.71291L9.96164 19.1001C9.90939 19.1903 9.77145 19.1535 9.77145 19.049V10.2832C9.77145 10.108 9.67785 9.94603 9.526 9.85808L1.9348 5.47536C1.84459 5.42311 1.88143 5.28517 1.98592 5.28517H17.4442C17.6637 5.28517 17.8009 5.5231 17.6912 5.71329H17.6908V5.71291Z" fill="currentColor" />
@@ -226,7 +226,7 @@ Please re-run the build so the framework can regenerate the bundle.`);let c=s.js
226
226
  <div id="root"></div>
227
227
  ${e}
228
228
  </body>
229
- </html>`);return{contents:[{uri:r.uri,text:p,mimeType:i,_meta:r._meta}]}}catch(e){throw console.error(`React failed for ${r.name}:`,e),e}let o=r.handler({},t);if(o instanceof Promise&&(o=await o),"string"==typeof o)return{contents:[{uri:r.uri,text:o,mimeType:i,_meta:r._meta}]};if(o&&"object"==typeof o&&"_meta"in o&&!("content"in o))return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]};if(o&&"object"==typeof o&&"content"in o&&Array.isArray(o.content)){let e=o.content.find(e=>"text"===e.type);if(e&&"text"===e.type&&"string"==typeof e.text)return{contents:[{uri:r.uri,text:e.text,mimeType:i,_meta:r._meta}]}}return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]}};e.registerResource(r.name,r.uri,o,s)}),i.forEach((t,a)=>{let r={name:mX(a),description:"No description provided"},{default:i,metadata:n,schema:o}=t;"object"==typeof n&&null!==n&&Object.assign(r,n);let s={};mY(o)?s=o:null!=o&&console.warn(`Invalid schema for resource "${r.name}" at ${a}. Expected Record<string, z.ZodType>`);let c=mQ(a);if(!c)return void console.warn(`Skipping resource "${r.name}" at ${a}: Invalid file path format`);let l=c.uriTemplate;r.mimeType&&r.mimeType.includes("html")&&(l=l.endsWith(".html")?l:`${l}.html`);let p=function(e,t,a={}){let r=mQ(t);if(!r)throw Error(`Invalid resource file path: ${t}. Must follow (scheme)/path/[param] convention.`);return async(t,i)=>{let n=e(function(e,t,a){let r={},i={};if(0===t.parameters.length)return i;let n=t.uriTemplate.split("://")[1]||"",o=e.split("://")[1]||"",s=n.split("/"),c=o.split("/");for(let e=0;e<s.length&&e<c.length;e++){let t=s[e],a=c[e],i=t.match(/^\{(.+)\}$/);i&&(r[i[1]]=a)}for(let e of t.parameters){let t=r[e],n=a[e];if(void 0===t)throw Error(`Missing required parameter: ${e}`);if(!n){i[e]=t;continue}try{i[e]=n.parse(t)}catch(a){throw Error(`Invalid parameter "${e}": ${t}. Validation error: ${a instanceof Error?a.message:String(a)}`)}}return i}(t.href,r,a),i);if(n instanceof Promise&&(n=await n),"string"==typeof n)return{contents:[{uri:t.href,text:n}]};if(!n||"object"!=typeof n||!Array.isArray(n.contents)){let e=null===n?"null":typeof n,t=void 0===n?"undefined":null===n?"null":"object"==typeof n?JSON.stringify(n,null,2):String(n);throw Error(`Resource handler must return a ReadResourceResult or string. Got ${e}: ${t}
229
+ </html>`);return{contents:[{uri:r.uri,text:p,mimeType:i,_meta:r._meta}]}}catch(e){throw console.error(`React failed for ${r.name}:`,e),e}let o=r.handler({},t);if(o instanceof Promise&&(o=await o),"string"==typeof o)return{contents:[{uri:r.uri,text:o,mimeType:i,_meta:r._meta}]};if(o&&"object"==typeof o&&"_meta"in o&&!("content"in o))return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]};if(o&&"object"==typeof o&&"content"in o&&Array.isArray(o.content)){let e=o.content.find(e=>"text"===e.type);if(e&&"text"===e.type&&"string"==typeof e.text)return{contents:[{uri:r.uri,text:e.text,mimeType:i,_meta:r._meta}]}}return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]}};e.registerResource(r.name,r.uri,o,s)}),i.forEach((t,a)=>{let r={name:mX(a),description:"No description provided"},{default:i,metadata:n,schema:o,complete:s}=t;"object"==typeof n&&null!==n&&Object.assign(r,n);let c={};mY(o)?c=o:null!=o&&console.warn(`Invalid schema for resource "${r.name}" at ${a}. Expected Record<string, z.ZodType>`);let l=mQ(a);if(!l)return void console.warn(`Skipping resource "${r.name}" at ${a}: Invalid file path format`);let p=l.uriTemplate;r.mimeType&&r.mimeType.includes("html")&&(p=p.endsWith(".html")?p:`${p}.html`);let u=function(e,t,a={}){let r=mQ(t);if(!r)throw Error(`Invalid resource file path: ${t}. Must follow (scheme)/path/[param] convention.`);return async(t,i)=>{let n=e(function(e,t,a){let r={},i={};if(0===t.parameters.length)return i;let n=t.uriTemplate.split("://")[1]||"",o=e.split("://")[1]||"",s=n.split("/"),c=o.split("/");for(let e=0;e<s.length&&e<c.length;e++){let t=s[e],a=c[e],i=t.match(/^\{(.+)\}$/);i&&(r[i[1]]=a)}for(let e of t.parameters){let t=r[e],n=a[e];if(void 0===t)throw Error(`Missing required parameter: ${e}`);if(!n){i[e]=t;continue}try{i[e]=n.parse(t)}catch(a){throw Error(`Invalid parameter "${e}": ${t}. Validation error: ${a instanceof Error?a.message:String(a)}`)}}return i}(t.href,r,a),i);if(n instanceof Promise&&(n=await n),"string"==typeof n)return{contents:[{uri:t.href,text:n}]};if(!n||"object"!=typeof n||!Array.isArray(n.contents)){let e=null===n?"null":typeof n,t=void 0===n?"undefined":null===n?"null":"object"==typeof n?JSON.stringify(n,null,2):String(n);throw Error(`Resource handler must return a ReadResourceResult or string. Got ${e}: ${t}
230
230
 
231
231
  Expected ReadResourceResult format:
232
232
  {
@@ -235,7 +235,7 @@ Expected ReadResourceResult format:
235
235
  { uri: "resource://uri", mimeType: "application/json", text: "json content" },
236
236
  { uri: "resource://uri", blob: base64data }
237
237
  ]
238
- }`)}return n.contents.forEach(e=>{e.uri||(e.uri=t.href)}),n}}(i,a,s);if("direct"===c.type)e.registerResource(r.name,l,r,p);else{let t=new up(l,{list:void 0}),a=async(e,t,a)=>{let r={};for(let e of c.parameters){let a=t[e],i=s[e];if(void 0===a)throw Error(`Missing required parameter: ${e}. Available variables: ${Object.keys(t)}`);i?r[e]=i.parse(a):r[e]=a}let n=i(r,a);return n instanceof Promise&&(n=await n),"string"==typeof n?{contents:[{uri:e.href,text:n}]}:n};e.registerResource(r.name,t,r,a)}})}),e}async function fn(){let{toolModules:e,skippedTools:t}=await m3(fe);return m7(t),e}async function fo(){let{promptModules:e,skippedPrompts:t}=await m2(ft);return m4(t),e}async function fs(){let{resourceModules:e,skippedResources:t}=await m9(fa);return m5(t),e}async function fc(){let{instructions:e,...t}=fr,a=new ul(t,{instructions:e}),r=fn(),i=fo(),n=fs(),[o,s,c]=await Promise.all([r,i,n]);return fi(a,o,s,c)}var fl=a(8611),fp=a.n(fl);require("http2");var fu=a(2203),fd=a(6982),fm=global.Request,ff=class extends fm{constructor(e,t){"object"==typeof e&&fv in e&&(e=e[fv]()),void 0!==t?.body?.getReader&&(t.duplex??="half"),super(e,t)}},fh=Symbol("wrapBodyStream"),fv=Symbol("getRequestCache"),fg=Symbol("requestCache"),fy=Symbol("incomingKey"),fb=Symbol("urlKey"),fx=Symbol("headersKey"),f_=Symbol("abortControllerKey"),fw=Symbol("getAbortController"),fS={get method(){return this[fy].method||"GET"},get url(){return this[fb]},get headers(){return this[fx]||=(e=>{let t=[],a=e.rawHeaders;for(let e=0;e<a.length;e+=2){let{[e]:r,[e+1]:i}=a;58!==r.charCodeAt(0)&&t.push([r,i])}return new Headers(t)})(this[fy])},[fw](){return this[fv](),this[f_]},[fv](){return this[f_]||=new AbortController,this[fg]||=((e,t,a,r,i)=>{let n={method:e,headers:a,signal:i.signal};if("TRACE"===e){n.method="GET";let e=new ff(t,n);return Object.defineProperty(e,"method",{get:()=>"TRACE"}),e}if("GET"!==e&&"HEAD"!==e)if("rawBody"in r&&r.rawBody instanceof Buffer)n.body=new ReadableStream({start(e){e.enqueue(r.rawBody),e.close()}});else if(r[fh]){let e;n.body=new ReadableStream({async pull(t){try{e||=fu.Readable.toWeb(r).getReader();let{done:a,value:i}=await e.read();a?t.close():t.enqueue(i)}catch(e){t.error(e)}}})}else n.body=fu.Readable.toWeb(r);return new ff(t,n)})(this.method,this[fb],this.headers,this[fy],this[f_])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach(e=>{Object.defineProperty(fS,e,{get(){return this[fv]()[e]}})}),["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(fS,e,{value:function(){return this[fv]()[e]()}})}),Object.defineProperty(fS,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,a){let r={method:this.method,url:this.url,headers:this.headers,nativeRequest:this[fg]};return`Request (lightweight) ${a(r,{...t,depth:null==e?null:e-1})}`}}),Object.setPrototypeOf(fS,ff.prototype);var fk=Symbol("responseCache"),f$=Symbol("getResponseCache"),fj=Symbol("cache"),fE=global.Response,fR=class e{#e;#t;[f$](){return delete this[fj],this[fk]||=new fE(this.#e,this.#t)}constructor(t,a){let r;if(this.#e=t,a instanceof e){const e=a[fk];if(e){this.#t=e,this[f$]();return}this.#t=a.#t,r=new Headers(a.#t.headers)}else this.#t=a;("string"==typeof t||void 0!==t?.getReader||t instanceof Blob||t instanceof Uint8Array)&&(this[fj]=[a?.status||200,t,r||a?.headers])}get headers(){let e=this[fj];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||{"content-type":"text/plain; charset=UTF-8"})),e[2]):this[f$]().headers}get status(){return this[fj]?.[0]??this[f$]().status}get ok(){let e=this.status;return e>=200&&e<300}};function fC(e){return Array.isArray(e)?e[0]:e}async function fT(e,t,a){let r,i=(e.method??"GET").toUpperCase(),n=`http://${fC(e.headers.host)??fC(e.headers[":authority"])??"localhost"}${e.url??"/"}`,o=new Headers;for(let[t,a]of Object.entries(e.headers))if(!(void 0===a||t.startsWith(":")))if(Array.isArray(a))for(let e of a)o.append(t,e);else o.set(t,a);if("GET"!==i&&"HEAD"!==i)if(void 0===t){let t=new TextDecoder,a="";for await(let r of e)a+="string"==typeof r?r:t.decode(r,{stream:!0});(a+=t.decode()).length>0&&(r=a)}else{let e=JSON.stringify(t);o.delete("content-encoding"),o.delete("transfer-encoding"),void 0===e?o.delete("content-length"):(r=e,o.set("content-length",String(new TextEncoder().encode(e).byteLength)))}return new Request(n,{method:i,headers:o,...a?.signal!==void 0&&{signal:a.signal},...void 0!==r&&{body:r}})}["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(e=>{Object.defineProperty(fR.prototype,e,{get(){return this[f$]()[e]}})}),["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(fR.prototype,e,{value:function(){return this[f$]()[e]()}})}),Object.defineProperty(fR.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,a){let r={status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[fk]};return`Response (lightweight) ${a(r,{...t,depth:null==e?null:e-1})}`}}),Object.setPrototypeOf(fR,fE),Object.setPrototypeOf(fR.prototype,fE.prototype),void 0===global.crypto&&(global.crypto=fd),Symbol("outgoingEnded"),Symbol("incomingDraining");var fP=a(5711),fO=a.n(fP);let fA=require("node:crypto"),fI="This MCP server was bootstrapped with xmcp.",fq={cursor:`
238
+ }`)}return n.contents.forEach(e=>{e.uri||(e.uri=t.href)}),n}}(i,a,c);if("direct"===l.type)e.registerResource(r.name,p,r,u);else{let t=Object.create(null);for(let e of l.parameters)s&&Object.hasOwn(s,e)&&(t[e]=s[e]);let a=new up(p,{list:void 0,complete:t}),n=async(e,t,a)=>{let r={};for(let e of l.parameters){let a=t[e],i=c[e];if(void 0===a)throw Error(`Missing required parameter: ${e}. Available variables: ${Object.keys(t)}`);i?r[e]=i.parse(a):r[e]=a}let n=i(r,a);return n instanceof Promise&&(n=await n),"string"==typeof n?{contents:[{uri:e.href,text:n}]}:n};e.registerResource(r.name,a,r,n)}})}),e}async function fn(){let{toolModules:e,skippedTools:t}=await m3(fe);return m7(t),e}async function fo(){let{promptModules:e,skippedPrompts:t}=await m2(ft);return m4(t),e}async function fs(){let{resourceModules:e,skippedResources:t}=await m9(fa);return m5(t),e}async function fc(){let{instructions:e,...t}=fr,a=new ul(t,{instructions:e}),r=fn(),i=fo(),n=fs(),[o,s,c]=await Promise.all([r,i,n]);return fi(a,o,s,c)}var fl=a(8611),fp=a.n(fl);require("http2");var fu=a(2203),fd=a(6982),fm=global.Request,ff=class extends fm{constructor(e,t){"object"==typeof e&&fv in e&&(e=e[fv]()),void 0!==t?.body?.getReader&&(t.duplex??="half"),super(e,t)}},fh=Symbol("wrapBodyStream"),fv=Symbol("getRequestCache"),fg=Symbol("requestCache"),fy=Symbol("incomingKey"),fb=Symbol("urlKey"),fx=Symbol("headersKey"),f_=Symbol("abortControllerKey"),fw=Symbol("getAbortController"),fS={get method(){return this[fy].method||"GET"},get url(){return this[fb]},get headers(){return this[fx]||=(e=>{let t=[],a=e.rawHeaders;for(let e=0;e<a.length;e+=2){let{[e]:r,[e+1]:i}=a;58!==r.charCodeAt(0)&&t.push([r,i])}return new Headers(t)})(this[fy])},[fw](){return this[fv](),this[f_]},[fv](){return this[f_]||=new AbortController,this[fg]||=((e,t,a,r,i)=>{let n={method:e,headers:a,signal:i.signal};if("TRACE"===e){n.method="GET";let e=new ff(t,n);return Object.defineProperty(e,"method",{get:()=>"TRACE"}),e}if("GET"!==e&&"HEAD"!==e)if("rawBody"in r&&r.rawBody instanceof Buffer)n.body=new ReadableStream({start(e){e.enqueue(r.rawBody),e.close()}});else if(r[fh]){let e;n.body=new ReadableStream({async pull(t){try{e||=fu.Readable.toWeb(r).getReader();let{done:a,value:i}=await e.read();a?t.close():t.enqueue(i)}catch(e){t.error(e)}}})}else n.body=fu.Readable.toWeb(r);return new ff(t,n)})(this.method,this[fb],this.headers,this[fy],this[f_])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach(e=>{Object.defineProperty(fS,e,{get(){return this[fv]()[e]}})}),["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(fS,e,{value:function(){return this[fv]()[e]()}})}),Object.defineProperty(fS,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,a){let r={method:this.method,url:this.url,headers:this.headers,nativeRequest:this[fg]};return`Request (lightweight) ${a(r,{...t,depth:null==e?null:e-1})}`}}),Object.setPrototypeOf(fS,ff.prototype);var fk=Symbol("responseCache"),f$=Symbol("getResponseCache"),fj=Symbol("cache"),fE=global.Response,fR=class e{#e;#t;[f$](){return delete this[fj],this[fk]||=new fE(this.#e,this.#t)}constructor(t,a){let r;if(this.#e=t,a instanceof e){const e=a[fk];if(e){this.#t=e,this[f$]();return}this.#t=a.#t,r=new Headers(a.#t.headers)}else this.#t=a;("string"==typeof t||void 0!==t?.getReader||t instanceof Blob||t instanceof Uint8Array)&&(this[fj]=[a?.status||200,t,r||a?.headers])}get headers(){let e=this[fj];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||{"content-type":"text/plain; charset=UTF-8"})),e[2]):this[f$]().headers}get status(){return this[fj]?.[0]??this[f$]().status}get ok(){let e=this.status;return e>=200&&e<300}};function fC(e){return Array.isArray(e)?e[0]:e}async function fT(e,t,a){let r,i=(e.method??"GET").toUpperCase(),n=`http://${fC(e.headers.host)??fC(e.headers[":authority"])??"localhost"}${e.url??"/"}`,o=new Headers;for(let[t,a]of Object.entries(e.headers))if(!(void 0===a||t.startsWith(":")))if(Array.isArray(a))for(let e of a)o.append(t,e);else o.set(t,a);if("GET"!==i&&"HEAD"!==i)if(void 0===t){let t=new TextDecoder,a="";for await(let r of e)a+="string"==typeof r?r:t.decode(r,{stream:!0});(a+=t.decode()).length>0&&(r=a)}else{let e=JSON.stringify(t);o.delete("content-encoding"),o.delete("transfer-encoding"),void 0===e?o.delete("content-length"):(r=e,o.set("content-length",String(new TextEncoder().encode(e).byteLength)))}return new Request(n,{method:i,headers:o,...a?.signal!==void 0&&{signal:a.signal},...void 0!==r&&{body:r}})}["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(e=>{Object.defineProperty(fR.prototype,e,{get(){return this[f$]()[e]}})}),["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(fR.prototype,e,{value:function(){return this[f$]()[e]()}})}),Object.defineProperty(fR.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,a){let r={status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[fk]};return`Response (lightweight) ${a(r,{...t,depth:null==e?null:e-1})}`}}),Object.setPrototypeOf(fR,fE),Object.setPrototypeOf(fR.prototype,fE.prototype),void 0===global.crypto&&(global.crypto=fd),Symbol("outgoingEnded"),Symbol("incomingDraining");var fP=a(5711),fO=a.n(fP);let fA=require("node:crypto"),fI="This MCP server was bootstrapped with xmcp.",fq={cursor:`
239
239
  <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
240
240
  <g clip-path="url(#cursor)">
241
241
  <path d="M18.1937 4.73376L10.1872 0.111231C9.93007 -0.0372398 9.61283 -0.0372398 9.35573 0.111231L1.34956 4.73376C1.13344 4.85855 1 5.08934 1 5.33929V14.6606C1 14.9106 1.13344 15.1414 1.34956 15.2662L9.3561 19.8887C9.6132 20.0372 9.93044 20.0372 10.1875 19.8887L18.1941 15.2662C18.4102 15.1414 18.5436 14.9106 18.5436 14.6606V5.33929C18.5436 5.08934 18.4102 4.85855 18.1941 4.73376H18.1937ZM17.6908 5.71291L9.96164 19.1001C9.90939 19.1903 9.77145 19.1535 9.77145 19.049V10.2832C9.77145 10.108 9.67785 9.94603 9.526 9.85808L1.9348 5.47536C1.84459 5.42311 1.88143 5.28517 1.98592 5.28517H17.4442C17.6637 5.28517 17.8009 5.5231 17.6912 5.71329H17.6908V5.71291Z" fill="currentColor" />
@@ -210,7 +210,7 @@ Please re-run the build so the framework can regenerate the bundle.`);let l=s.js
210
210
  <div id="root"></div>
211
211
  ${e}
212
212
  </body>
213
- </html>`);return{contents:[{uri:a.uri,text:u,mimeType:i,_meta:a._meta}]}}catch(e){throw console.error(`React failed for ${a.name}:`,e),e}let o=a.handler({},t);if(o instanceof Promise&&(o=await o),"string"==typeof o)return{contents:[{uri:a.uri,text:o,mimeType:i,_meta:a._meta}]};if(o&&"object"==typeof o&&"_meta"in o&&!("content"in o))return{contents:[{uri:a.uri,text:"",mimeType:i,_meta:a._meta}]};if(o&&"object"==typeof o&&"content"in o&&Array.isArray(o.content)){let e=o.content.find(e=>"text"===e.type);if(e&&"text"===e.type&&"string"==typeof e.text)return{contents:[{uri:a.uri,text:e.text,mimeType:i,_meta:a._meta}]}}return{contents:[{uri:a.uri,text:"",mimeType:i,_meta:a._meta}]}};e.registerResource(a.name,a.uri,o,s)}),i.forEach((t,r)=>{let a={name:mx(r),description:"No description provided"},{default:i,metadata:n,schema:o}=t;"object"==typeof n&&null!==n&&Object.assign(a,n);let s={};mR(o)?s=o:null!=o&&console.warn(`Invalid schema for resource "${a.name}" at ${r}. Expected Record<string, z.ZodType>`);let l=mP(r);if(!l)return void console.warn(`Skipping resource "${a.name}" at ${r}: Invalid file path format`);let c=l.uriTemplate;a.mimeType&&a.mimeType.includes("html")&&(c=c.endsWith(".html")?c:`${c}.html`);let u=function(e,t,r={}){let a=mP(t);if(!a)throw Error(`Invalid resource file path: ${t}. Must follow (scheme)/path/[param] convention.`);return async(t,i)=>{let n=e(function(e,t,r){let a={},i={};if(0===t.parameters.length)return i;let n=t.uriTemplate.split("://")[1]||"",o=e.split("://")[1]||"",s=n.split("/"),l=o.split("/");for(let e=0;e<s.length&&e<l.length;e++){let t=s[e],r=l[e],i=t.match(/^\{(.+)\}$/);i&&(a[i[1]]=r)}for(let e of t.parameters){let t=a[e],n=r[e];if(void 0===t)throw Error(`Missing required parameter: ${e}`);if(!n){i[e]=t;continue}try{i[e]=n.parse(t)}catch(r){throw Error(`Invalid parameter "${e}": ${t}. Validation error: ${r instanceof Error?r.message:String(r)}`)}}return i}(t.href,a,r),i);if(n instanceof Promise&&(n=await n),"string"==typeof n)return{contents:[{uri:t.href,text:n}]};if(!n||"object"!=typeof n||!Array.isArray(n.contents)){let e=null===n?"null":typeof n,t=void 0===n?"undefined":null===n?"null":"object"==typeof n?JSON.stringify(n,null,2):String(n);throw Error(`Resource handler must return a ReadResourceResult or string. Got ${e}: ${t}
213
+ </html>`);return{contents:[{uri:a.uri,text:u,mimeType:i,_meta:a._meta}]}}catch(e){throw console.error(`React failed for ${a.name}:`,e),e}let o=a.handler({},t);if(o instanceof Promise&&(o=await o),"string"==typeof o)return{contents:[{uri:a.uri,text:o,mimeType:i,_meta:a._meta}]};if(o&&"object"==typeof o&&"_meta"in o&&!("content"in o))return{contents:[{uri:a.uri,text:"",mimeType:i,_meta:a._meta}]};if(o&&"object"==typeof o&&"content"in o&&Array.isArray(o.content)){let e=o.content.find(e=>"text"===e.type);if(e&&"text"===e.type&&"string"==typeof e.text)return{contents:[{uri:a.uri,text:e.text,mimeType:i,_meta:a._meta}]}}return{contents:[{uri:a.uri,text:"",mimeType:i,_meta:a._meta}]}};e.registerResource(a.name,a.uri,o,s)}),i.forEach((t,r)=>{let a={name:mx(r),description:"No description provided"},{default:i,metadata:n,schema:o,complete:s}=t;"object"==typeof n&&null!==n&&Object.assign(a,n);let l={};mR(o)?l=o:null!=o&&console.warn(`Invalid schema for resource "${a.name}" at ${r}. Expected Record<string, z.ZodType>`);let c=mP(r);if(!c)return void console.warn(`Skipping resource "${a.name}" at ${r}: Invalid file path format`);let u=c.uriTemplate;a.mimeType&&a.mimeType.includes("html")&&(u=u.endsWith(".html")?u:`${u}.html`);let d=function(e,t,r={}){let a=mP(t);if(!a)throw Error(`Invalid resource file path: ${t}. Must follow (scheme)/path/[param] convention.`);return async(t,i)=>{let n=e(function(e,t,r){let a={},i={};if(0===t.parameters.length)return i;let n=t.uriTemplate.split("://")[1]||"",o=e.split("://")[1]||"",s=n.split("/"),l=o.split("/");for(let e=0;e<s.length&&e<l.length;e++){let t=s[e],r=l[e],i=t.match(/^\{(.+)\}$/);i&&(a[i[1]]=r)}for(let e of t.parameters){let t=a[e],n=r[e];if(void 0===t)throw Error(`Missing required parameter: ${e}`);if(!n){i[e]=t;continue}try{i[e]=n.parse(t)}catch(r){throw Error(`Invalid parameter "${e}": ${t}. Validation error: ${r instanceof Error?r.message:String(r)}`)}}return i}(t.href,a,r),i);if(n instanceof Promise&&(n=await n),"string"==typeof n)return{contents:[{uri:t.href,text:n}]};if(!n||"object"!=typeof n||!Array.isArray(n.contents)){let e=null===n?"null":typeof n,t=void 0===n?"undefined":null===n?"null":"object"==typeof n?JSON.stringify(n,null,2):String(n);throw Error(`Resource handler must return a ReadResourceResult or string. Got ${e}: ${t}
214
214
 
215
215
  Expected ReadResourceResult format:
216
216
  {
@@ -219,4 +219,4 @@ Expected ReadResourceResult format:
219
219
  { uri: "resource://uri", mimeType: "application/json", text: "json content" },
220
220
  { uri: "resource://uri", blob: base64data }
221
221
  ]
222
- }`)}return n.contents.forEach(e=>{e.uri||(e.uri=t.href)}),n}}(i,r,s);if("direct"===l.type)e.registerResource(a.name,c,a,u);else{let t=new u2(c,{list:void 0}),r=async(e,t,r)=>{let a={};for(let e of l.parameters){let r=t[e],i=s[e];if(void 0===r)throw Error(`Missing required parameter: ${e}. Available variables: ${Object.keys(t)}`);i?a[e]=i.parse(r):a[e]=r}let n=i(a,r);return n instanceof Promise&&(n=await n),"string"==typeof n?{contents:[{uri:e.href,text:n}]}:n};e.registerResource(a.name,t,a,r)}})}),e}async function mU(){let{toolModules:e,skippedTools:t}=await mz(mM);return mA(t),e}async function mF(){let{promptModules:e,skippedPrompts:t}=await mj(mL);return mO(t),e}async function mH(){let{resourceModules:e,skippedResources:t}=await mN(mZ);return mI(t),e}async function mJ(){let{instructions:e,...t}=mD,r=new u1(t,{instructions:e}),a=mU(),i=mF(),n=mH(),[o,s,l]=await Promise.all([a,i,n]);return mV(r,o,s,l)}var mK=r(8583);r.n(mK)().config();let mB=STDIO_CONFIG.debug||!1;if(STDIO_CONFIG.silent){let e=new console.Console(process.stderr,process.stderr);for(let t of["log","debug","info","warn","error","dir","table","trace","assert","time","timeEnd","timeLog","count","countReset","group","groupEnd","groupCollapsed","clear"])console[t]=e[t].bind(e)}pX({clientInfo:void 0},()=>{let e;!function(e,t={}){let r,a=t.legacy??"serve",i=t.transport??new dt,n={phase:"opening"},c=!1,u=()=>c||"closed"===n.phase,d=e=>{try{t.onerror?.(e)}catch{}},p=(e,t,r,a)=>i.send({jsonrpc:"2.0",id:e,error:{code:t,message:r,...void 0!==a&&{data:a}}}).catch(e=>d(da(e))),m=new uG(t.maxSubscriptions??1024),h=e=>{if(!iJ.safeParse(e).success)return;let t=m.routeOutbound(e);if("passthrough"!==t){for(let e of t)i.send({jsonrpc:"2.0",...e}).catch(e=>d(da(e)));return"handled"}},f=async e=>{if(lS(e)&&"subscriptions/listen"===e.method){let t,r=lg(e.params),a=ly(e.params)?(void 0===r?[]:l_(r))[0]:{key:"_meta",problem:"the per-request envelope is required on protocol revision 2026-07-28"},n=lv(e.params);if(void 0!==a)t={jsonrpc:"2.0",id:e.id,error:{code:-32602,message:`Invalid _meta envelope: ${a.key}: ${a.problem}`}};else if(void 0!==n&&sR.includes(n))t=m.serve(e);else{let r=new s9({supported:[...sR],requested:n??"unknown"});t={jsonrpc:"2.0",id:e.id,error:{code:r.code,message:r.message,data:r.data}}}return await i.send("error"in t?t:{jsonrpc:"2.0",method:t.method,params:t.params}).catch(e=>d(da(e))),!0}if(iJ.safeParse(e).success&&"notifications/cancelled"===e.method){let t=e.params?.requestId;if(void 0!==t&&m.cancel(t))return!0}return!1},g=(e,t,r)=>{let a=function(e,t){switch(e.reason){case"http-method":return lT("http-method","modern-only-method-not-allowed",405,new s0(-32e3,"Method not allowed."),!0);case"batch":return lT("jsonrpc-shape","modern-only-batch-not-supported",400,new s0(sQ.InvalidRequest,"Bad Request: JSON-RPC batches are not supported by this endpoint"),!0);case"response":return lT("jsonrpc-shape","modern-only-response-post",400,new s0(sQ.InvalidRequest,"Bad Request: JSON-RPC responses cannot be posted to this endpoint"),!0);case"notification":return;case"initialize":case"no-claim":{let r=e.requestedVersion;return lT("era-classification","modern-only-missing-envelope",400,void 0===r?new s0(sQ.UnsupportedProtocolVersion,"Unsupported protocol version: the request did not name a protocol version",{supported:[...t]}):new s9({supported:[...t],requested:r}),!0)}}}({kind:"legacy",reason:t,...void 0!==r&&{requestedVersion:r}},sR);return void 0===a?Promise.resolve():(d(Error(`Rejected 2025-era request on a modern-only stdio connection (${a.cell}): ${a.message}`)),p(e.id,a.code,a.message,a.data))},y=async(t,a)=>{let n=await e({era:t}),u=n instanceof u1?n.server:n;"modern"===t&&(o(u,a),s(u,sR),m.setServerCapabilities(u.getCapabilities(),l(u)));let d=new dr(i,()=>{!c&&d!==r&&k()},"modern"===t?h:void 0);return await n.connect(d),{product:n,channel:d}},v=e=>e.product.close().catch(e=>d(da(e))),_=async e=>{r=e.channel;try{await e.channel.whenRequestsAnswered(3e3)||d(Error("Discarded the probe instance with requests still unanswered after 3000ms; continuing with the fallback")),await e.product.close()}catch(e){d(da(e))}finally{r=void 0}},b=async e=>{if("closed"===n.phase)return;if("pinned"===n.phase)return"modern"===n.era&&lS(e)&&"initialize"===e.method&&!lj(e.params)?void await g(e,"initialize",null!==e.params&&"object"==typeof e.params&&"string"==typeof e.params.protocolVersion?e.params.protocolVersion:void 0):void("modern"===n.era&&await f(e)||n.instance.channel.deliver(e));if(!lS(e)&&!iJ.safeParse(e).success)return void d(Error("Discarded a JSON-RPC response received before the connection negotiated an era"));let t=function(e){let t=e.params;if("initialize"===e.method&&!lj(t)){let e=null!==t&&"object"==typeof t&&"string"==typeof t.protocolVersion?t.protocolVersion:void 0;return{kind:"legacy",reason:"initialize",...void 0!==e&&{requestedVersion:e}}}if(!ly(t))return{kind:"legacy",reason:"no-claim"};let r=lg(t),a=(void 0===r?[]:l_(r))[0];if(void 0!==a)return{kind:"invalid-envelope",issue:a};let i=lv(t);return void 0!==i&&sR.includes(i)?{kind:"modern",revision:i,classification:{era:"modern",revision:i}}:{kind:"unsupported-revision",requested:i??"unknown"}}(e);switch(t.kind){case"invalid-envelope":{let r=`Invalid _meta envelope for protocol revision 2026-07-28: ${t.issue.key}: ${t.issue.problem}`;lS(e)?await p(e.id,sQ.InvalidParams,r,{envelope:t.issue}):d(Error(`Discarded a notification with a malformed envelope: ${r}`));return}case"unsupported-revision":if(lS(e)){let r=new s9({supported:[...sR],requested:t.requested});d(r),await p(e.id,r.code,r.message,r.data)}else d(Error(`Discarded a notification claiming unsupported protocol revision ${t.requested}`));return;case"modern":if(lS(e)&&"server/discover"===e.method){if("probe"===n.phase)return void n.instance.channel.deliver(e,{classification:t.classification});let r=await y("modern",t.revision);if(u())return void await v(r);n={phase:"probe",instance:r},r.channel.deliver(e,{classification:t.classification});return}if("probe"===n.phase){if(iJ.safeParse(e).success)return void n.instance.channel.deliver(e,{classification:t.classification});n={phase:"pinned",era:"modern",instance:n.instance}}else{let e=await y("modern",t.revision);if(u())return void await v(e);n={phase:"pinned",era:"modern",instance:e}}if(await f(e))return;n.instance.channel.deliver(e,{classification:t.classification});return;case"legacy":{if("reject"===a){lS(e)&&await g(e,t.reason,t.requestedVersion);return}if("probe"===n.phase){if(await _(n.instance),u())return;n={phase:"opening"}}let r=await y("legacy");if(u())return void await v(r);(n={phase:"pinned",era:"legacy",instance:r}).instance.channel.deliver(e);return}}},S=[],$=!1,w=async()=>{if(!$){$=!0;try{for(;S.length>0;){let e=S.shift();try{await b(e)}catch(t){lS(e)&&await p(e.id,sQ.InternalError,"Internal server error"),d(da(t))}}}finally{$=!1}}},k=async()=>{if(c||"closed"===n.phase)return;c=!0;let e=n;for(let e of(n={phase:"closed"},m.teardownAll()))await i.send(e).catch(e=>d(da(e)));("probe"===e.phase||"pinned"===e.phase)&&await e.instance.product.close().catch(e=>d(da(e))),await i.close().catch(e=>d(da(e)))};i.onmessage=e=>{S.push(e),w()},i.onerror=e=>{d(e),("probe"===n.phase||"pinned"===n.phase)&&n.instance.channel.onerror?.(e)},i.onclose=()=>{if(c||"closed"===n.phase)return;c=!0;let e=n;n={phase:"closed"},("probe"===e.phase||"pinned"===e.phase)&&e.instance.product.close().catch(e=>d(da(e)))},i.start().catch(e=>{throw d(da(e)),e}).catch(()=>{})}(async()=>{let e=await mJ();return e.server.oninitialized=()=>{let t=pQ(e.server.getClientVersion());pW({clientInfo:t}),mB&&t&&console.log(`[STDIO] MCP client initialized: ${t.name}@${t.version}`)},e},{legacy:"serve",onerror:mB?e=>console.error("[STDIO] Error:",e):void 0}),mB&&console.log("[STDIO] MCP Server running with STDIO transport"),e=()=>{mB&&console.log("[STDIO] Shutting down STDIO transport"),process.exit(0)},process.on("SIGINT",e),process.on("SIGTERM",e)})})(),{}})());
222
+ }`)}return n.contents.forEach(e=>{e.uri||(e.uri=t.href)}),n}}(i,r,l);if("direct"===c.type)e.registerResource(a.name,u,a,d);else{let t=Object.create(null);for(let e of c.parameters)s&&Object.hasOwn(s,e)&&(t[e]=s[e]);let r=new u2(u,{list:void 0,complete:t}),n=async(e,t,r)=>{let a={};for(let e of c.parameters){let r=t[e],i=l[e];if(void 0===r)throw Error(`Missing required parameter: ${e}. Available variables: ${Object.keys(t)}`);i?a[e]=i.parse(r):a[e]=r}let n=i(a,r);return n instanceof Promise&&(n=await n),"string"==typeof n?{contents:[{uri:e.href,text:n}]}:n};e.registerResource(a.name,r,a,n)}})}),e}async function mU(){let{toolModules:e,skippedTools:t}=await mz(mM);return mA(t),e}async function mF(){let{promptModules:e,skippedPrompts:t}=await mj(mL);return mO(t),e}async function mH(){let{resourceModules:e,skippedResources:t}=await mN(mZ);return mI(t),e}async function mJ(){let{instructions:e,...t}=mD,r=new u1(t,{instructions:e}),a=mU(),i=mF(),n=mH(),[o,s,l]=await Promise.all([a,i,n]);return mV(r,o,s,l)}var mK=r(8583);r.n(mK)().config();let mB=STDIO_CONFIG.debug||!1;if(STDIO_CONFIG.silent){let e=new console.Console(process.stderr,process.stderr);for(let t of["log","debug","info","warn","error","dir","table","trace","assert","time","timeEnd","timeLog","count","countReset","group","groupEnd","groupCollapsed","clear"])console[t]=e[t].bind(e)}pX({clientInfo:void 0},()=>{let e;!function(e,t={}){let r,a=t.legacy??"serve",i=t.transport??new dt,n={phase:"opening"},c=!1,u=()=>c||"closed"===n.phase,d=e=>{try{t.onerror?.(e)}catch{}},p=(e,t,r,a)=>i.send({jsonrpc:"2.0",id:e,error:{code:t,message:r,...void 0!==a&&{data:a}}}).catch(e=>d(da(e))),m=new uG(t.maxSubscriptions??1024),h=e=>{if(!iJ.safeParse(e).success)return;let t=m.routeOutbound(e);if("passthrough"!==t){for(let e of t)i.send({jsonrpc:"2.0",...e}).catch(e=>d(da(e)));return"handled"}},f=async e=>{if(lS(e)&&"subscriptions/listen"===e.method){let t,r=lg(e.params),a=ly(e.params)?(void 0===r?[]:l_(r))[0]:{key:"_meta",problem:"the per-request envelope is required on protocol revision 2026-07-28"},n=lv(e.params);if(void 0!==a)t={jsonrpc:"2.0",id:e.id,error:{code:-32602,message:`Invalid _meta envelope: ${a.key}: ${a.problem}`}};else if(void 0!==n&&sR.includes(n))t=m.serve(e);else{let r=new s9({supported:[...sR],requested:n??"unknown"});t={jsonrpc:"2.0",id:e.id,error:{code:r.code,message:r.message,data:r.data}}}return await i.send("error"in t?t:{jsonrpc:"2.0",method:t.method,params:t.params}).catch(e=>d(da(e))),!0}if(iJ.safeParse(e).success&&"notifications/cancelled"===e.method){let t=e.params?.requestId;if(void 0!==t&&m.cancel(t))return!0}return!1},g=(e,t,r)=>{let a=function(e,t){switch(e.reason){case"http-method":return lT("http-method","modern-only-method-not-allowed",405,new s0(-32e3,"Method not allowed."),!0);case"batch":return lT("jsonrpc-shape","modern-only-batch-not-supported",400,new s0(sQ.InvalidRequest,"Bad Request: JSON-RPC batches are not supported by this endpoint"),!0);case"response":return lT("jsonrpc-shape","modern-only-response-post",400,new s0(sQ.InvalidRequest,"Bad Request: JSON-RPC responses cannot be posted to this endpoint"),!0);case"notification":return;case"initialize":case"no-claim":{let r=e.requestedVersion;return lT("era-classification","modern-only-missing-envelope",400,void 0===r?new s0(sQ.UnsupportedProtocolVersion,"Unsupported protocol version: the request did not name a protocol version",{supported:[...t]}):new s9({supported:[...t],requested:r}),!0)}}}({kind:"legacy",reason:t,...void 0!==r&&{requestedVersion:r}},sR);return void 0===a?Promise.resolve():(d(Error(`Rejected 2025-era request on a modern-only stdio connection (${a.cell}): ${a.message}`)),p(e.id,a.code,a.message,a.data))},y=async(t,a)=>{let n=await e({era:t}),u=n instanceof u1?n.server:n;"modern"===t&&(o(u,a),s(u,sR),m.setServerCapabilities(u.getCapabilities(),l(u)));let d=new dr(i,()=>{!c&&d!==r&&k()},"modern"===t?h:void 0);return await n.connect(d),{product:n,channel:d}},v=e=>e.product.close().catch(e=>d(da(e))),_=async e=>{r=e.channel;try{await e.channel.whenRequestsAnswered(3e3)||d(Error("Discarded the probe instance with requests still unanswered after 3000ms; continuing with the fallback")),await e.product.close()}catch(e){d(da(e))}finally{r=void 0}},b=async e=>{if("closed"===n.phase)return;if("pinned"===n.phase)return"modern"===n.era&&lS(e)&&"initialize"===e.method&&!lj(e.params)?void await g(e,"initialize",null!==e.params&&"object"==typeof e.params&&"string"==typeof e.params.protocolVersion?e.params.protocolVersion:void 0):void("modern"===n.era&&await f(e)||n.instance.channel.deliver(e));if(!lS(e)&&!iJ.safeParse(e).success)return void d(Error("Discarded a JSON-RPC response received before the connection negotiated an era"));let t=function(e){let t=e.params;if("initialize"===e.method&&!lj(t)){let e=null!==t&&"object"==typeof t&&"string"==typeof t.protocolVersion?t.protocolVersion:void 0;return{kind:"legacy",reason:"initialize",...void 0!==e&&{requestedVersion:e}}}if(!ly(t))return{kind:"legacy",reason:"no-claim"};let r=lg(t),a=(void 0===r?[]:l_(r))[0];if(void 0!==a)return{kind:"invalid-envelope",issue:a};let i=lv(t);return void 0!==i&&sR.includes(i)?{kind:"modern",revision:i,classification:{era:"modern",revision:i}}:{kind:"unsupported-revision",requested:i??"unknown"}}(e);switch(t.kind){case"invalid-envelope":{let r=`Invalid _meta envelope for protocol revision 2026-07-28: ${t.issue.key}: ${t.issue.problem}`;lS(e)?await p(e.id,sQ.InvalidParams,r,{envelope:t.issue}):d(Error(`Discarded a notification with a malformed envelope: ${r}`));return}case"unsupported-revision":if(lS(e)){let r=new s9({supported:[...sR],requested:t.requested});d(r),await p(e.id,r.code,r.message,r.data)}else d(Error(`Discarded a notification claiming unsupported protocol revision ${t.requested}`));return;case"modern":if(lS(e)&&"server/discover"===e.method){if("probe"===n.phase)return void n.instance.channel.deliver(e,{classification:t.classification});let r=await y("modern",t.revision);if(u())return void await v(r);n={phase:"probe",instance:r},r.channel.deliver(e,{classification:t.classification});return}if("probe"===n.phase){if(iJ.safeParse(e).success)return void n.instance.channel.deliver(e,{classification:t.classification});n={phase:"pinned",era:"modern",instance:n.instance}}else{let e=await y("modern",t.revision);if(u())return void await v(e);n={phase:"pinned",era:"modern",instance:e}}if(await f(e))return;n.instance.channel.deliver(e,{classification:t.classification});return;case"legacy":{if("reject"===a){lS(e)&&await g(e,t.reason,t.requestedVersion);return}if("probe"===n.phase){if(await _(n.instance),u())return;n={phase:"opening"}}let r=await y("legacy");if(u())return void await v(r);(n={phase:"pinned",era:"legacy",instance:r}).instance.channel.deliver(e);return}}},S=[],$=!1,w=async()=>{if(!$){$=!0;try{for(;S.length>0;){let e=S.shift();try{await b(e)}catch(t){lS(e)&&await p(e.id,sQ.InternalError,"Internal server error"),d(da(t))}}}finally{$=!1}}},k=async()=>{if(c||"closed"===n.phase)return;c=!0;let e=n;for(let e of(n={phase:"closed"},m.teardownAll()))await i.send(e).catch(e=>d(da(e)));("probe"===e.phase||"pinned"===e.phase)&&await e.instance.product.close().catch(e=>d(da(e))),await i.close().catch(e=>d(da(e)))};i.onmessage=e=>{S.push(e),w()},i.onerror=e=>{d(e),("probe"===n.phase||"pinned"===n.phase)&&n.instance.channel.onerror?.(e)},i.onclose=()=>{if(c||"closed"===n.phase)return;c=!0;let e=n;n={phase:"closed"},("probe"===e.phase||"pinned"===e.phase)&&e.instance.product.close().catch(e=>d(da(e)))},i.start().catch(e=>{throw d(da(e)),e}).catch(()=>{})}(async()=>{let e=await mJ();return e.server.oninitialized=()=>{let t=pQ(e.server.getClientVersion());pW({clientInfo:t}),mB&&t&&console.log(`[STDIO] MCP client initialized: ${t.name}@${t.version}`)},e},{legacy:"serve",onerror:mB?e=>console.error("[STDIO] Error:",e):void 0}),mB&&console.log("[STDIO] MCP Server running with STDIO transport"),e=()=>{mB&&console.log("[STDIO] Shutting down STDIO transport"),process.exit(0)},process.on("SIGINT",e),process.on("SIGTERM",e)})})(),{}})());
@@ -0,0 +1,7 @@
1
+ import type { AudioContent, EmbeddedResource, ImageContent } from "@modelcontextprotocol/server";
2
+ /** Create an MCP image content block from raw bytes. */
3
+ export declare function image(bytes: Uint8Array | ArrayBuffer, mimeType: string): ImageContent;
4
+ /** Create an MCP audio content block from raw bytes. */
5
+ export declare function audio(bytes: Uint8Array | ArrayBuffer, mimeType: string): AudioContent;
6
+ /** Embed text or binary resource contents without registering a resource. */
7
+ export declare function embeddedResource(uri: string, content: string | Uint8Array | ArrayBuffer, mimeType?: string): EmbeddedResource;
@@ -6,7 +6,7 @@ import { UserToolHandler } from "./transformers/tool";
6
6
  import { UserPromptHandler } from "./transformers/prompt";
7
7
  import { UserResourceHandler } from "./transformers/resource";
8
8
  import { ZodRawShape } from "zod/v3";
9
- import { ResourceMetadata } from "@/types/resource";
9
+ import { ResourceMetadata, ResourceCompletions } from "@/types/resource";
10
10
  export type ToolFile = {
11
11
  metadata: ToolMetadata;
12
12
  schema: ZodRawShape;
@@ -21,6 +21,7 @@ export type PromptFile = {
21
21
  export type ResourceFile = {
22
22
  metadata: ResourceMetadata;
23
23
  schema: ZodRawShape;
24
+ complete?: ResourceCompletions;
24
25
  default: UserResourceHandler;
25
26
  };
26
27
  export declare const injectedTools: Record<string, () => Promise<ToolFile>>;
@@ -226,7 +226,7 @@ Please re-run the build so the framework can regenerate the bundle.`);let c=s.js
226
226
  <div id="root"></div>
227
227
  ${e}
228
228
  </body>
229
- </html>`);return{contents:[{uri:a.uri,text:p,mimeType:r,_meta:a._meta}]}}catch(e){throw console.error(`React failed for ${a.name}:`,e),e}let o=a.handler({},t);if(o instanceof Promise&&(o=await o),"string"==typeof o)return{contents:[{uri:a.uri,text:o,mimeType:r,_meta:a._meta}]};if(o&&"object"==typeof o&&"_meta"in o&&!("content"in o))return{contents:[{uri:a.uri,text:"",mimeType:r,_meta:a._meta}]};if(o&&"object"==typeof o&&"content"in o&&Array.isArray(o.content)){let e=o.content.find(e=>"text"===e.type);if(e&&"text"===e.type&&"string"==typeof e.text)return{contents:[{uri:a.uri,text:e.text,mimeType:r,_meta:a._meta}]}}return{contents:[{uri:a.uri,text:"",mimeType:r,_meta:a._meta}]}};e.registerResource(a.name,a.uri,o,s)}),r.forEach((t,a)=>{let r={name:m1(a),description:"No description provided"},{default:i,metadata:n,schema:o}=t;"object"==typeof n&&null!==n&&Object.assign(r,n);let s={};m0(o)?s=o:null!=o&&console.warn(`Invalid schema for resource "${r.name}" at ${a}. Expected Record<string, z.ZodType>`);let c=m2(a);if(!c)return void console.warn(`Skipping resource "${r.name}" at ${a}: Invalid file path format`);let l=c.uriTemplate;r.mimeType&&r.mimeType.includes("html")&&(l=l.endsWith(".html")?l:`${l}.html`);let p=function(e,t,a={}){let r=m2(t);if(!r)throw Error(`Invalid resource file path: ${t}. Must follow (scheme)/path/[param] convention.`);return async(t,i)=>{let n=e(function(e,t,a){let r={},i={};if(0===t.parameters.length)return i;let n=t.uriTemplate.split("://")[1]||"",o=e.split("://")[1]||"",s=n.split("/"),c=o.split("/");for(let e=0;e<s.length&&e<c.length;e++){let t=s[e],a=c[e],i=t.match(/^\{(.+)\}$/);i&&(r[i[1]]=a)}for(let e of t.parameters){let t=r[e],n=a[e];if(void 0===t)throw Error(`Missing required parameter: ${e}`);if(!n){i[e]=t;continue}try{i[e]=n.parse(t)}catch(a){throw Error(`Invalid parameter "${e}": ${t}. Validation error: ${a instanceof Error?a.message:String(a)}`)}}return i}(t.href,r,a),i);if(n instanceof Promise&&(n=await n),"string"==typeof n)return{contents:[{uri:t.href,text:n}]};if(!n||"object"!=typeof n||!Array.isArray(n.contents)){let e=null===n?"null":typeof n,t=void 0===n?"undefined":null===n?"null":"object"==typeof n?JSON.stringify(n,null,2):String(n);throw Error(`Resource handler must return a ReadResourceResult or string. Got ${e}: ${t}
229
+ </html>`);return{contents:[{uri:a.uri,text:p,mimeType:r,_meta:a._meta}]}}catch(e){throw console.error(`React failed for ${a.name}:`,e),e}let o=a.handler({},t);if(o instanceof Promise&&(o=await o),"string"==typeof o)return{contents:[{uri:a.uri,text:o,mimeType:r,_meta:a._meta}]};if(o&&"object"==typeof o&&"_meta"in o&&!("content"in o))return{contents:[{uri:a.uri,text:"",mimeType:r,_meta:a._meta}]};if(o&&"object"==typeof o&&"content"in o&&Array.isArray(o.content)){let e=o.content.find(e=>"text"===e.type);if(e&&"text"===e.type&&"string"==typeof e.text)return{contents:[{uri:a.uri,text:e.text,mimeType:r,_meta:a._meta}]}}return{contents:[{uri:a.uri,text:"",mimeType:r,_meta:a._meta}]}};e.registerResource(a.name,a.uri,o,s)}),r.forEach((t,a)=>{let r={name:m1(a),description:"No description provided"},{default:i,metadata:n,schema:o,complete:s}=t;"object"==typeof n&&null!==n&&Object.assign(r,n);let c={};m0(o)?c=o:null!=o&&console.warn(`Invalid schema for resource "${r.name}" at ${a}. Expected Record<string, z.ZodType>`);let l=m2(a);if(!l)return void console.warn(`Skipping resource "${r.name}" at ${a}: Invalid file path format`);let p=l.uriTemplate;r.mimeType&&r.mimeType.includes("html")&&(p=p.endsWith(".html")?p:`${p}.html`);let u=function(e,t,a={}){let r=m2(t);if(!r)throw Error(`Invalid resource file path: ${t}. Must follow (scheme)/path/[param] convention.`);return async(t,i)=>{let n=e(function(e,t,a){let r={},i={};if(0===t.parameters.length)return i;let n=t.uriTemplate.split("://")[1]||"",o=e.split("://")[1]||"",s=n.split("/"),c=o.split("/");for(let e=0;e<s.length&&e<c.length;e++){let t=s[e],a=c[e],i=t.match(/^\{(.+)\}$/);i&&(r[i[1]]=a)}for(let e of t.parameters){let t=r[e],n=a[e];if(void 0===t)throw Error(`Missing required parameter: ${e}`);if(!n){i[e]=t;continue}try{i[e]=n.parse(t)}catch(a){throw Error(`Invalid parameter "${e}": ${t}. Validation error: ${a instanceof Error?a.message:String(a)}`)}}return i}(t.href,r,a),i);if(n instanceof Promise&&(n=await n),"string"==typeof n)return{contents:[{uri:t.href,text:n}]};if(!n||"object"!=typeof n||!Array.isArray(n.contents)){let e=null===n?"null":typeof n,t=void 0===n?"undefined":null===n?"null":"object"==typeof n?JSON.stringify(n,null,2):String(n);throw Error(`Resource handler must return a ReadResourceResult or string. Got ${e}: ${t}
230
230
 
231
231
  Expected ReadResourceResult format:
232
232
  {
@@ -235,7 +235,7 @@ Expected ReadResourceResult format:
235
235
  { uri: "resource://uri", mimeType: "application/json", text: "json content" },
236
236
  { uri: "resource://uri", blob: base64data }
237
237
  ]
238
- }`)}return n.contents.forEach(e=>{e.uri||(e.uri=t.href)}),n}}(i,a,s);if("direct"===c.type)e.registerResource(r.name,l,r,p);else{let t=new um(l,{list:void 0}),a=async(e,t,a)=>{let r={};for(let e of c.parameters){let a=t[e],i=s[e];if(void 0===a)throw Error(`Missing required parameter: ${e}. Available variables: ${Object.keys(t)}`);i?r[e]=i.parse(a):r[e]=a}let n=i(r,a);return n instanceof Promise&&(n=await n),"string"==typeof n?{contents:[{uri:e.href,text:n}]}:n};e.registerResource(r.name,t,r,a)}})}),e}async function fc(){let{toolModules:e,skippedTools:t}=await ft(fr);return fa(t),e}async function fl(){let{promptModules:e,skippedPrompts:t}=await m9(fi);return m5(t),e}async function fp(){let{resourceModules:e,skippedResources:t}=await m3(fn);return m7(t),e}async function fu(){let{instructions:e,...t}=fo,a=new ud(t,{instructions:e}),r=fc(),i=fl(),n=fp(),[o,s,c]=await Promise.all([r,i,n]);return fs(a,o,s,c)}var fd=i(8611),fm=i.n(fd);t("http2");var ff=i(2203),fh=i(6982),fv=global.Request,fg=class extends fv{constructor(e,t){"object"==typeof e&&fb in e&&(e=e[fb]()),void 0!==t?.body?.getReader&&(t.duplex??="half"),super(e,t)}},fy=Symbol("wrapBodyStream"),fb=Symbol("getRequestCache"),fx=Symbol("requestCache"),f_=Symbol("incomingKey"),fw=Symbol("urlKey"),fS=Symbol("headersKey"),fk=Symbol("abortControllerKey"),f$=Symbol("getAbortController"),fj={get method(){return this[f_].method||"GET"},get url(){return this[fw]},get headers(){return this[fS]||=(e=>{let t=[],a=e.rawHeaders;for(let e=0;e<a.length;e+=2){let{[e]:r,[e+1]:i}=a;58!==r.charCodeAt(0)&&t.push([r,i])}return new Headers(t)})(this[f_])},[f$](){return this[fb](),this[fk]},[fb](){return this[fk]||=new AbortController,this[fx]||=((e,t,a,r,i)=>{let n={method:e,headers:a,signal:i.signal};if("TRACE"===e){n.method="GET";let e=new fg(t,n);return Object.defineProperty(e,"method",{get:()=>"TRACE"}),e}if("GET"!==e&&"HEAD"!==e)if("rawBody"in r&&r.rawBody instanceof Buffer)n.body=new ReadableStream({start(e){e.enqueue(r.rawBody),e.close()}});else if(r[fy]){let e;n.body=new ReadableStream({async pull(t){try{e||=ff.Readable.toWeb(r).getReader();let{done:a,value:i}=await e.read();a?t.close():t.enqueue(i)}catch(e){t.error(e)}}})}else n.body=ff.Readable.toWeb(r);return new fg(t,n)})(this.method,this[fw],this.headers,this[f_],this[fk])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach(e=>{Object.defineProperty(fj,e,{get(){return this[fb]()[e]}})}),["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(fj,e,{value:function(){return this[fb]()[e]()}})}),Object.defineProperty(fj,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,a){let r={method:this.method,url:this.url,headers:this.headers,nativeRequest:this[fx]};return`Request (lightweight) ${a(r,{...t,depth:null==e?null:e-1})}`}}),Object.setPrototypeOf(fj,fg.prototype);var fE=Symbol("responseCache"),fR=Symbol("getResponseCache"),fC=Symbol("cache"),fT=global.Response,fP=class e{#e;#t;[fR](){return delete this[fC],this[fE]||=new fT(this.#e,this.#t)}constructor(t,a){let r;if(this.#e=t,a instanceof e){let e=a[fE];if(e){this.#t=e,this[fR]();return}this.#t=a.#t,r=new Headers(a.#t.headers)}else this.#t=a;("string"==typeof t||void 0!==t?.getReader||t instanceof Blob||t instanceof Uint8Array)&&(this[fC]=[a?.status||200,t,r||a?.headers])}get headers(){let e=this[fC];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||{"content-type":"text/plain; charset=UTF-8"})),e[2]):this[fR]().headers}get status(){return this[fC]?.[0]??this[fR]().status}get ok(){let e=this.status;return e>=200&&e<300}};function fO(e){return Array.isArray(e)?e[0]:e}async function fA(e,t,a){let r,i=(e.method??"GET").toUpperCase(),n=`http://${fO(e.headers.host)??fO(e.headers[":authority"])??"localhost"}${e.url??"/"}`,o=new Headers;for(let[t,a]of Object.entries(e.headers))if(!(void 0===a||t.startsWith(":")))if(Array.isArray(a))for(let e of a)o.append(t,e);else o.set(t,a);if("GET"!==i&&"HEAD"!==i)if(void 0===t){let t=new TextDecoder,a="";for await(let r of e)a+="string"==typeof r?r:t.decode(r,{stream:!0});(a+=t.decode()).length>0&&(r=a)}else{let e=JSON.stringify(t);o.delete("content-encoding"),o.delete("transfer-encoding"),void 0===e?o.delete("content-length"):(r=e,o.set("content-length",String(new TextEncoder().encode(e).byteLength)))}return new Request(n,{method:i,headers:o,...a?.signal!==void 0&&{signal:a.signal},...void 0!==r&&{body:r}})}["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(e=>{Object.defineProperty(fP.prototype,e,{get(){return this[fR]()[e]}})}),["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(fP.prototype,e,{value:function(){return this[fR]()[e]()}})}),Object.defineProperty(fP.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,a){let r={status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[fE]};return`Response (lightweight) ${a(r,{...t,depth:null==e?null:e-1})}`}}),Object.setPrototypeOf(fP,fT),Object.setPrototypeOf(fP.prototype,fT.prototype),void 0===global.crypto&&(global.crypto=fh),Symbol("outgoingEnded"),Symbol("incomingDraining");var fI=i(5711),fq=i.n(fI);let fN=t("node:crypto"),fz="This MCP server was bootstrapped with xmcp.",fM={cursor:`
238
+ }`)}return n.contents.forEach(e=>{e.uri||(e.uri=t.href)}),n}}(i,a,c);if("direct"===l.type)e.registerResource(r.name,p,r,u);else{let t=Object.create(null);for(let e of l.parameters)s&&Object.hasOwn(s,e)&&(t[e]=s[e]);let a=new um(p,{list:void 0,complete:t}),n=async(e,t,a)=>{let r={};for(let e of l.parameters){let a=t[e],i=c[e];if(void 0===a)throw Error(`Missing required parameter: ${e}. Available variables: ${Object.keys(t)}`);i?r[e]=i.parse(a):r[e]=a}let n=i(r,a);return n instanceof Promise&&(n=await n),"string"==typeof n?{contents:[{uri:e.href,text:n}]}:n};e.registerResource(r.name,a,r,n)}})}),e}async function fc(){let{toolModules:e,skippedTools:t}=await ft(fr);return fa(t),e}async function fl(){let{promptModules:e,skippedPrompts:t}=await m9(fi);return m5(t),e}async function fp(){let{resourceModules:e,skippedResources:t}=await m3(fn);return m7(t),e}async function fu(){let{instructions:e,...t}=fo,a=new ud(t,{instructions:e}),r=fc(),i=fl(),n=fp(),[o,s,c]=await Promise.all([r,i,n]);return fs(a,o,s,c)}var fd=i(8611),fm=i.n(fd);t("http2");var ff=i(2203),fh=i(6982),fv=global.Request,fg=class extends fv{constructor(e,t){"object"==typeof e&&fb in e&&(e=e[fb]()),void 0!==t?.body?.getReader&&(t.duplex??="half"),super(e,t)}},fy=Symbol("wrapBodyStream"),fb=Symbol("getRequestCache"),fx=Symbol("requestCache"),f_=Symbol("incomingKey"),fw=Symbol("urlKey"),fS=Symbol("headersKey"),fk=Symbol("abortControllerKey"),f$=Symbol("getAbortController"),fj={get method(){return this[f_].method||"GET"},get url(){return this[fw]},get headers(){return this[fS]||=(e=>{let t=[],a=e.rawHeaders;for(let e=0;e<a.length;e+=2){let{[e]:r,[e+1]:i}=a;58!==r.charCodeAt(0)&&t.push([r,i])}return new Headers(t)})(this[f_])},[f$](){return this[fb](),this[fk]},[fb](){return this[fk]||=new AbortController,this[fx]||=((e,t,a,r,i)=>{let n={method:e,headers:a,signal:i.signal};if("TRACE"===e){n.method="GET";let e=new fg(t,n);return Object.defineProperty(e,"method",{get:()=>"TRACE"}),e}if("GET"!==e&&"HEAD"!==e)if("rawBody"in r&&r.rawBody instanceof Buffer)n.body=new ReadableStream({start(e){e.enqueue(r.rawBody),e.close()}});else if(r[fy]){let e;n.body=new ReadableStream({async pull(t){try{e||=ff.Readable.toWeb(r).getReader();let{done:a,value:i}=await e.read();a?t.close():t.enqueue(i)}catch(e){t.error(e)}}})}else n.body=ff.Readable.toWeb(r);return new fg(t,n)})(this.method,this[fw],this.headers,this[f_],this[fk])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach(e=>{Object.defineProperty(fj,e,{get(){return this[fb]()[e]}})}),["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(fj,e,{value:function(){return this[fb]()[e]()}})}),Object.defineProperty(fj,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,a){let r={method:this.method,url:this.url,headers:this.headers,nativeRequest:this[fx]};return`Request (lightweight) ${a(r,{...t,depth:null==e?null:e-1})}`}}),Object.setPrototypeOf(fj,fg.prototype);var fE=Symbol("responseCache"),fR=Symbol("getResponseCache"),fC=Symbol("cache"),fT=global.Response,fP=class e{#e;#t;[fR](){return delete this[fC],this[fE]||=new fT(this.#e,this.#t)}constructor(t,a){let r;if(this.#e=t,a instanceof e){let e=a[fE];if(e){this.#t=e,this[fR]();return}this.#t=a.#t,r=new Headers(a.#t.headers)}else this.#t=a;("string"==typeof t||void 0!==t?.getReader||t instanceof Blob||t instanceof Uint8Array)&&(this[fC]=[a?.status||200,t,r||a?.headers])}get headers(){let e=this[fC];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||{"content-type":"text/plain; charset=UTF-8"})),e[2]):this[fR]().headers}get status(){return this[fC]?.[0]??this[fR]().status}get ok(){let e=this.status;return e>=200&&e<300}};function fO(e){return Array.isArray(e)?e[0]:e}async function fA(e,t,a){let r,i=(e.method??"GET").toUpperCase(),n=`http://${fO(e.headers.host)??fO(e.headers[":authority"])??"localhost"}${e.url??"/"}`,o=new Headers;for(let[t,a]of Object.entries(e.headers))if(!(void 0===a||t.startsWith(":")))if(Array.isArray(a))for(let e of a)o.append(t,e);else o.set(t,a);if("GET"!==i&&"HEAD"!==i)if(void 0===t){let t=new TextDecoder,a="";for await(let r of e)a+="string"==typeof r?r:t.decode(r,{stream:!0});(a+=t.decode()).length>0&&(r=a)}else{let e=JSON.stringify(t);o.delete("content-encoding"),o.delete("transfer-encoding"),void 0===e?o.delete("content-length"):(r=e,o.set("content-length",String(new TextEncoder().encode(e).byteLength)))}return new Request(n,{method:i,headers:o,...a?.signal!==void 0&&{signal:a.signal},...void 0!==r&&{body:r}})}["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(e=>{Object.defineProperty(fP.prototype,e,{get(){return this[fR]()[e]}})}),["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(fP.prototype,e,{value:function(){return this[fR]()[e]()}})}),Object.defineProperty(fP.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,a){let r={status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[fE]};return`Response (lightweight) ${a(r,{...t,depth:null==e?null:e-1})}`}}),Object.setPrototypeOf(fP,fT),Object.setPrototypeOf(fP.prototype,fT.prototype),void 0===global.crypto&&(global.crypto=fh),Symbol("outgoingEnded"),Symbol("incomingDraining");var fI=i(5711),fq=i.n(fI);let fN=t("node:crypto"),fz="This MCP server was bootstrapped with xmcp.",fM={cursor:`
239
239
  <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
240
240
  <g clip-path="url(#cursor)">
241
241
  <path d="M18.1937 4.73376L10.1872 0.111231C9.93007 -0.0372398 9.61283 -0.0372398 9.35573 0.111231L1.34956 4.73376C1.13344 4.85855 1 5.08934 1 5.33929V14.6606C1 14.9106 1.13344 15.1414 1.34956 15.2662L9.3561 19.8887C9.6132 20.0372 9.93044 20.0372 10.1875 19.8887L18.1941 15.2662C18.4102 15.1414 18.5436 14.9106 18.5436 14.6606V5.33929C18.5436 5.08934 18.4102 4.85855 18.1941 4.73376H18.1937ZM17.6908 5.71291L9.96164 19.1001C9.90939 19.1903 9.77145 19.1535 9.77145 19.049V10.2832C9.77145 10.108 9.67785 9.94603 9.526 9.85808L1.9348 5.47536C1.84459 5.42311 1.88143 5.28517 1.98592 5.28517H17.4442C17.6637 5.28517 17.8009 5.5231 17.6912 5.71329H17.6908V5.71291Z" fill="currentColor" />
@@ -8,6 +8,9 @@ declare module "xmcp/plugins/x402" {
8
8
  type PaidHandler = import("../plugins/x402/index").PaidHandler;
9
9
  }
10
10
  declare module "xmcp/cloudflare" {
11
+ const image: typeof import("../runtime/utils/content").image;
12
+ const audio: typeof import("../runtime/utils/content").audio;
13
+ const embeddedResource: typeof import("../runtime/utils/content").embeddedResource;
11
14
  const apiKeyAuthMiddleware: typeof import("../runtime/platforms/cloudflare/middlewares/api-key").cloudflareApiKeyAuthMiddleware;
12
15
  const jwtAuthMiddleware: typeof import("../runtime/platforms/cloudflare/middlewares/jwt").cloudflareJwtAuthMiddleware;
13
16
  type JWTAuthMiddlewareConfig = import("../runtime/platforms/cloudflare/middlewares/jwt").CloudflareJWTAuthMiddlewareConfig;
@@ -1,4 +1,7 @@
1
1
  import { UIMetadata } from "./ui-meta";
2
+ import type { CompleteResourceTemplateCallback } from "@modelcontextprotocol/server";
3
+ /** Completion callbacks keyed by the resource's URI template parameters. */
4
+ export type ResourceCompletions = Record<string, CompleteResourceTemplateCallback>;
2
5
  export interface ResourceMetadata {
3
6
  name: string;
4
7
  title?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "xmcp",
3
3
  "description": "The MCP framework",
4
- "version": "1.2.0",
4
+ "version": "1.3.0",
5
5
  "author": {
6
6
  "name": "xmcp",
7
7
  "email": "support@xmcp.dev",
@@ -44,6 +44,10 @@
44
44
  "require": "./dist/index.js",
45
45
  "default": "./dist/index.js"
46
46
  },
47
+ "./node": {
48
+ "types": "./dist/node.d.ts",
49
+ "node": "./dist/node.js"
50
+ },
47
51
  "./host-bridge": {
48
52
  "types": "./dist/host-bridge.d.ts",
49
53
  "import": "./dist/host-bridge.js",
@@ -71,6 +75,9 @@
71
75
  },
72
76
  "typesVersions": {
73
77
  "*": {
78
+ "node": [
79
+ "dist/node.d.ts"
80
+ ],
74
81
  "host-bridge": [
75
82
  "dist/host-bridge.d.ts"
76
83
  ],
@@ -162,7 +169,7 @@
162
169
  "analyze": "cross-env GENERATE_STATS=true pnpm build && pnpm tsx scripts/analyze-rspack-stats.ts",
163
170
  "bench": "tsx bench/run.mts",
164
171
  "test:config": "pnpm --dir ../compiler test:config",
165
- "test:adapters": "node --import tsx --test src/runtime/adapters/fastify/__tests__/*.test.ts",
172
+ "test:adapters": "node --import tsx --test src/runtime/adapters/*/__tests__/*.test.ts",
166
173
  "test:runtime": "node --import tsx --test src/runtime/utils/__tests__/*.test.ts src/runtime/utils/ui/__tests__/*.test.ts"
167
174
  }
168
175
  }