xmcp 1.7.1 → 1.7.2
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.
- package/dist/client.js +1 -1
- package/dist/index.js +1 -1
- package/dist/runtime/adapter-express.js +1 -1
- package/dist/runtime/adapter-fastify.js +1 -1
- package/dist/runtime/adapter-fetch-cloudflare.js +1 -1
- package/dist/runtime/adapter-fetch.js +1 -1
- package/dist/runtime/adapter-nestjs.js +1 -1
- package/dist/runtime/adapter-nextjs.js +1 -1
- package/dist/runtime/cloudflare-worker.js +1 -1
- package/dist/runtime/http.js +11 -11
- package/dist/runtime/stdio.js +1 -1
- package/dist/runtime/utils/transformers/resource.d.ts +3 -3
- package/dist/runtime/vercel.js +1 -1
- package/package.json +1 -1
package/dist/runtime/stdio.js
CHANGED
|
@@ -203,7 +203,7 @@ Please re-run the build so the framework can regenerate the bundle.`);let c=l.js
|
|
|
203
203
|
<div id="root"></div>
|
|
204
204
|
${t}
|
|
205
205
|
</body>
|
|
206
|
-
</html>`);return{contents:[{uri:i.uri,text:d,mimeType:n,_meta:i._meta}]}}catch(t){throw console.error(`React failed for ${i.name}:`,t),t}let s=i.handler({},r);if(s instanceof Promise&&(s=await s),"string"==typeof s)return{contents:[{uri:i.uri,text:s,mimeType:n,_meta:i._meta}]};if(s&&"object"==typeof s&&"_meta"in s&&!("content"in s))return{contents:[{uri:i.uri,text:"",mimeType:n,_meta:i._meta}]};if(s&&"object"==typeof s&&"content"in s&&Array.isArray(s.content)){let t=s.content.find(t=>"text"===t.type);if(t&&"text"===t.type&&"string"==typeof t.text)return{contents:[{uri:i.uri,text:t.text,mimeType:n,_meta:i._meta}]}}return{contents:[{uri:i.uri,text:"",mimeType:n,_meta:i._meta}]}};u?.(i.name,i.uri),t.registerResource(i.name,i.uri,s,l)}),o.forEach((r,a)=>{let i={name:hJ(a),description:"No description provided"},{default:n,metadata:o,schema:s,complete:l}=r;if("object"==typeof o&&null!==o&&Object.assign(i,o),!1===i.enabled)return;let c={};hH(s)?c=s:null!=s&&console.warn(`Invalid schema for resource "${i.name}" at ${a}. Expected Record<string, z.ZodType>`);let d=h2(a);if(!d)return void console.warn(`Skipping resource "${i.name}" at ${a}: Invalid file path format`);let p=d.uriTemplate;i.mimeType&&i.mimeType.includes("html")&&(p=p.endsWith(".html")?p:`${p}.html`);let m=function(t,r,a={}){let i=h2(r);if(!i)throw Error(`Invalid resource file path: ${r}. Must follow (scheme)/path/[param] convention.`);return async(r,n)=>{let o=t(function(t,r,a){let i={},n={};if(0===r.parameters.length)return n;let o=r.uriTemplate.split("://")[1]||"",s=t.split("://")[1]||"",l=o.split("/"),c=s.split("/");for(let t=0;t<l.length&&t<c.length;t++){let r=l[t],a=c[t],n=r.match(/^\{(.+)\}$/);n&&(i[n[1]]=a)}for(let t of r.parameters){let r=i[t],o=a[t];if(void 0===r)throw Error(`Missing required parameter: ${t}`);if(!o){n[t]=r;continue}try{n[t]=o.parse(r)}catch(a){throw Error(`Invalid parameter "${t}": ${r}. Validation error: ${a instanceof Error?a.message:String(a)}`)}}return n}(r.href,i,a),n);if(o instanceof Promise&&(o=await o),"string"==typeof o)return{contents:[{uri:r.href,text:o}]};if(!o||"object"!=typeof o||!Array.isArray(o.contents)){let t=null===o?"null":typeof o,r=void 0===o?"undefined":null===o?"null":"object"==typeof o?JSON.stringify(o,null,2):String(o);throw Error(`Resource handler must return a ReadResourceResult or string. Got ${t}: ${r}
|
|
206
|
+
</html>`);return{contents:[{uri:i.uri,text:d,mimeType:n,_meta:i._meta}]}}catch(t){throw console.error(`React failed for ${i.name}:`,t),t}let s=i.handler({},r);if(s instanceof Promise&&(s=await s),"string"==typeof s)return{contents:[{uri:i.uri,text:s,mimeType:n,_meta:i._meta}]};if(s&&"object"==typeof s&&"_meta"in s&&!("content"in s))return{contents:[{uri:i.uri,text:"",mimeType:n,_meta:i._meta}]};if(s&&"object"==typeof s&&"content"in s&&Array.isArray(s.content)){let t=s.content.find(t=>"text"===t.type);if(t&&"text"===t.type&&"string"==typeof t.text)return{contents:[{uri:i.uri,text:t.text,mimeType:n,_meta:i._meta}]}}return{contents:[{uri:i.uri,text:"",mimeType:n,_meta:i._meta}]}};u?.(i.name,i.uri),t.registerResource(i.name,i.uri,s,l)}),o.forEach((r,a)=>{let i={name:hJ(a),description:"No description provided"},{default:n,metadata:o,schema:s,complete:l}=r;if("object"==typeof o&&null!==o&&Object.assign(i,o),!1===i.enabled)return;let c={};hH(s)?c=s:null!=s&&console.warn(`Invalid schema for resource "${i.name}" at ${a}. Expected Record<string, z.ZodType>`);let d=h2(a);if(!d)return void console.warn(`Skipping resource "${i.name}" at ${a}: Invalid file path format`);let p=d.uriTemplate;i.mimeType&&i.mimeType.includes("html")&&(p=p.endsWith(".html")?p:`${p}.html`);let m=function(t,r,a={}){let i=h2(r);if(!i)throw Error(`Invalid resource file path: ${r}. Must follow (scheme)/path/[param] convention.`);return async(r,n)=>{let o=t(function(t,r,a){let i={},n={};if(0===r.parameters.length)return n;let o=r.uriTemplate.split("://")[1]||"",s=t.split("://")[1]||"",l=o.split("/"),c=s.split("/");for(let t=0;t<l.length&&t<c.length;t++){let r=l[t],a=c[t],n=r.match(/^\{(.+)\}$/);n&&(i[n[1]]=a)}for(let t of r.parameters){let r=i[t],o=a[t];if(void 0===r)throw Error(`Missing required parameter: ${t}`);if(!o){n[t]=r;continue}try{n[t]=o.parse(r)}catch(a){throw Error(`Invalid parameter "${t}": ${r}. Validation error: ${a instanceof Error?a.message:String(a)}`)}}return n}(r.href,i,a),n);if(o instanceof Promise&&(o=await o),cZ(o))return o;if("string"==typeof o)return{contents:[{uri:r.href,text:o}]};if(!o||"object"!=typeof o||!Array.isArray(o.contents)){let t=null===o?"null":typeof o,r=void 0===o?"undefined":null===o?"null":"object"==typeof o?JSON.stringify(o,null,2):String(o);throw Error(`Resource handler must return a ReadResourceResult, InputRequiredResult, or string. Got ${t}: ${r}
|
|
207
207
|
|
|
208
208
|
Expected ReadResourceResult format:
|
|
209
209
|
{
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { ReadResourceResult, ServerContext } from "@modelcontextprotocol/server";
|
|
1
|
+
import { InputRequiredResult, ReadResourceResult, ServerContext } from "@modelcontextprotocol/server";
|
|
2
2
|
import { ZodRawShape } from "zod/v3";
|
|
3
3
|
/**
|
|
4
4
|
* Type for the original resource handler that users write
|
|
5
5
|
*/
|
|
6
|
-
export type UserResourceHandler = (args: ZodRawShape, extra?: ServerContext) => ReadResourceResult | string | Promise<ReadResourceResult | string>;
|
|
6
|
+
export type UserResourceHandler = (args: ZodRawShape, extra?: ServerContext) => ReadResourceResult | InputRequiredResult | string | Promise<ReadResourceResult | InputRequiredResult | string>;
|
|
7
7
|
/**
|
|
8
8
|
* Type for the transformed handler that the MCP server expects (direct resources)
|
|
9
9
|
*/
|
|
10
|
-
export type McpResourceHandler = (uri: URL, extra: ServerContext) => ReadResourceResult | Promise<ReadResourceResult>;
|
|
10
|
+
export type McpResourceHandler = (uri: URL, extra: ServerContext) => ReadResourceResult | InputRequiredResult | Promise<ReadResourceResult | InputRequiredResult>;
|
|
11
11
|
/**
|
|
12
12
|
* Transforms a user's resource handler into an MCP-compatible handler.
|
|
13
13
|
*
|
package/dist/runtime/vercel.js
CHANGED
|
@@ -219,7 +219,7 @@ Please re-run the build so the framework can regenerate the bundle.`);let l=c.js
|
|
|
219
219
|
<div id="root"></div>
|
|
220
220
|
${t}
|
|
221
221
|
</body>
|
|
222
|
-
</html>`);return{contents:[{uri:r.uri,text:u,mimeType:i,_meta:r._meta}]}}catch(t){throw console.error(`React failed for ${r.name}:`,t),t}let s=r.handler({},a);if(s instanceof Promise&&(s=await s),"string"==typeof s)return{contents:[{uri:r.uri,text:s,mimeType:i,_meta:r._meta}]};if(s&&"object"==typeof s&&"_meta"in s&&!("content"in s))return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]};if(s&&"object"==typeof s&&"content"in s&&Array.isArray(s.content)){let t=s.content.find(t=>"text"===t.type);if(t&&"text"===t.type&&"string"==typeof t.text)return{contents:[{uri:r.uri,text:t.text,mimeType:i,_meta:r._meta}]}}return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]}};p?.(r.name,r.uri),t.registerResource(r.name,r.uri,s,c)}),o.forEach((a,r)=>{let i={name:hu(r),description:"No description provided"},{default:n,metadata:o,schema:s,complete:c}=a;if("object"==typeof o&&null!==o&&Object.assign(i,o),!1===i.enabled)return;let l={};hp(s)?l=s:null!=s&&console.warn(`Invalid schema for resource "${i.name}" at ${r}. Expected Record<string, z.ZodType>`);let u=h_(r);if(!u)return void console.warn(`Skipping resource "${i.name}" at ${r}: Invalid file path format`);let d=u.uriTemplate;i.mimeType&&i.mimeType.includes("html")&&(d=d.endsWith(".html")?d:`${d}.html`);let m=function(t,a,r={}){let i=h_(a);if(!i)throw Error(`Invalid resource file path: ${a}. Must follow (scheme)/path/[param] convention.`);return async(a,n)=>{let o=t(function(t,a,r){let i={},n={};if(0===a.parameters.length)return n;let o=a.uriTemplate.split("://")[1]||"",s=t.split("://")[1]||"",c=o.split("/"),l=s.split("/");for(let t=0;t<c.length&&t<l.length;t++){let a=c[t],r=l[t],n=a.match(/^\{(.+)\}$/);n&&(i[n[1]]=r)}for(let t of a.parameters){let a=i[t],o=r[t];if(void 0===a)throw Error(`Missing required parameter: ${t}`);if(!o){n[t]=a;continue}try{n[t]=o.parse(a)}catch(r){throw Error(`Invalid parameter "${t}": ${a}. Validation error: ${r instanceof Error?r.message:String(r)}`)}}return n}(a.href,i,r),n);if(o instanceof Promise&&(o=await o),"string"==typeof o)return{contents:[{uri:a.href,text:o}]};if(!o||"object"!=typeof o||!Array.isArray(o.contents)){let t=null===o?"null":typeof o,a=void 0===o?"undefined":null===o?"null":"object"==typeof o?JSON.stringify(o,null,2):String(o);throw Error(`Resource handler must return a ReadResourceResult or string. Got ${t}: ${a}
|
|
222
|
+
</html>`);return{contents:[{uri:r.uri,text:u,mimeType:i,_meta:r._meta}]}}catch(t){throw console.error(`React failed for ${r.name}:`,t),t}let s=r.handler({},a);if(s instanceof Promise&&(s=await s),"string"==typeof s)return{contents:[{uri:r.uri,text:s,mimeType:i,_meta:r._meta}]};if(s&&"object"==typeof s&&"_meta"in s&&!("content"in s))return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]};if(s&&"object"==typeof s&&"content"in s&&Array.isArray(s.content)){let t=s.content.find(t=>"text"===t.type);if(t&&"text"===t.type&&"string"==typeof t.text)return{contents:[{uri:r.uri,text:t.text,mimeType:i,_meta:r._meta}]}}return{contents:[{uri:r.uri,text:"",mimeType:i,_meta:r._meta}]}};p?.(r.name,r.uri),t.registerResource(r.name,r.uri,s,c)}),o.forEach((a,r)=>{let i={name:hu(r),description:"No description provided"},{default:n,metadata:o,schema:s,complete:c}=a;if("object"==typeof o&&null!==o&&Object.assign(i,o),!1===i.enabled)return;let l={};hp(s)?l=s:null!=s&&console.warn(`Invalid schema for resource "${i.name}" at ${r}. Expected Record<string, z.ZodType>`);let u=h_(r);if(!u)return void console.warn(`Skipping resource "${i.name}" at ${r}: Invalid file path format`);let d=u.uriTemplate;i.mimeType&&i.mimeType.includes("html")&&(d=d.endsWith(".html")?d:`${d}.html`);let m=function(t,a,r={}){let i=h_(a);if(!i)throw Error(`Invalid resource file path: ${a}. Must follow (scheme)/path/[param] convention.`);return async(a,n)=>{let o=t(function(t,a,r){let i={},n={};if(0===a.parameters.length)return n;let o=a.uriTemplate.split("://")[1]||"",s=t.split("://")[1]||"",c=o.split("/"),l=s.split("/");for(let t=0;t<c.length&&t<l.length;t++){let a=c[t],r=l[t],n=a.match(/^\{(.+)\}$/);n&&(i[n[1]]=r)}for(let t of a.parameters){let a=i[t],o=r[t];if(void 0===a)throw Error(`Missing required parameter: ${t}`);if(!o){n[t]=a;continue}try{n[t]=o.parse(a)}catch(r){throw Error(`Invalid parameter "${t}": ${a}. Validation error: ${r instanceof Error?r.message:String(r)}`)}}return n}(a.href,i,r),n);if(o instanceof Promise&&(o=await o),lG(o))return o;if("string"==typeof o)return{contents:[{uri:a.href,text:o}]};if(!o||"object"!=typeof o||!Array.isArray(o.contents)){let t=null===o?"null":typeof o,a=void 0===o?"undefined":null===o?"null":"object"==typeof o?JSON.stringify(o,null,2):String(o);throw Error(`Resource handler must return a ReadResourceResult, InputRequiredResult, or string. Got ${t}: ${a}
|
|
223
223
|
|
|
224
224
|
Expected ReadResourceResult format:
|
|
225
225
|
{
|