@mcp-use/cli 4.0.2-canary.2 → 4.0.2-canary.4
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/bin.js +1 -1
- package/dist/{chunk-XHPZPKHH.js → chunk-6Y2L4EIY.js} +4 -4
- package/dist/chunk-AUVTUYMK.js +1 -0
- package/dist/commands/dev.js +25 -25
- package/dist/commands/start.js +1 -1
- package/dist/dist-WKBHGU46.js +1 -0
- package/dist/index.js +1 -1
- package/dist/{start-7S5RBWJP.js → start-Z5UXFGTP.js} +1 -1
- package/package.json +3 -2
- package/dist/chunk-N35NYWRW.js +0 -1
- package/dist/tunnel-ROVTBKBW.js +0 -1
package/dist/commands/start.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunk-WOT6VMZA.js";async function e(t){return(await import("../start-
|
|
1
|
+
import"../chunk-WOT6VMZA.js";async function e(t){return(await import("../start-Z5UXFGTP.js")).runStart(t)}export{e as runStart};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk-AUVTUYMK.js";import"./chunk-WOT6VMZA.js";export{b as createTunnelManager,a as tunnelApiBase};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-6Y2L4EIY.js";import"./chunk-RXKUVCL7.js";import"./chunk-WOT6VMZA.js";export{a as main};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import{a as E}from"./chunk-4EER3N42.js";import{c as g,d as v}from"./chunk-RXKUVCL7.js";import{c as I}from"./chunk-OMRWADFK.js";import"./chunk-WOT6VMZA.js";import{readFile as M}from"fs/promises";import{join as d}from"path";import{pathToFileURL as R}from"url";var k=".mcp-use",L="build",N="manifest.json";async function H(t){let o=d(t.cwd,k,L),s=d(o,N),c;try{c=await M(s,"utf8")}catch{throw new Error(`No production build found (missing ${s}).
|
|
2
2
|
Run \`mcp-use build\` first, then \`mcp-use start\`.`)}let a;try{let n=JSON.parse(c);if(typeof n.entryPoint!="string"||n.entryPoint==="")throw new Error("missing entryPoint");a=n.entryPoint}catch(n){let r=n instanceof Error?n.message:String(n);throw new Error(`Invalid build manifest at ${s} (${r}).
|
|
3
3
|
Re-run \`mcp-use build\`.`)}process.env.NODE_ENV??="production",I(t.cwd,"production");let i=d(o,a),u=await import(R(i).href);if(!("default"in u)||u.default===void 0)throw new Error(`The built entry (${i}) has no default export.
|
|
4
|
-
The server entry must \`export default\` its MCPServer instance (see the mcp-use entry contract).`);let e=u.default;if(!A(e))throw new Error(`The default export of ${i} is not an MCPServer: it has no listen() method. Export the MCPServer instance as the default export.`);let S=typeof e.port=="number"?e.port:void 0,U=typeof e.host=="string"?e.host:void 0,h=g(t.port,process.env,S),y=v(t.host,process.env,U),l=await(t.withInspector===!0?_(e,h,y):e.listen(h,{host:y})),m=typeof l?.port=="number"?l.port:h,b=typeof l?.url=="string"?l.url:`http://localhost:${m}`,p,w;if(t.tunnel===!0)try{let{createTunnelManager:n}=await import("./
|
|
4
|
+
The server entry must \`export default\` its MCPServer instance (see the mcp-use entry contract).`);let e=u.default;if(!A(e))throw new Error(`The default export of ${i} is not an MCPServer: it has no listen() method. Export the MCPServer instance as the default export.`);let S=typeof e.port=="number"?e.port:void 0,U=typeof e.host=="string"?e.host:void 0,h=g(t.port,process.env,S),y=v(t.host,process.env,U),l=await(t.withInspector===!0?_(e,h,y):e.listen(h,{host:y})),m=typeof l?.port=="number"?l.port:h,b=typeof l?.url=="string"?l.url:`http://localhost:${m}`,p,w;if(t.tunnel===!0)try{let{createTunnelManager:n}=await import("./dist-WKBHGU46.js");p=n(d(t.cwd,k,"state","tunnel.json"));let r=await p.start(m),P=new URL(b);w=new URL(`${P.pathname}${P.search}`,`${r.url}/`).toString()}catch(n){try{await p?.stop()}catch{}try{await e.close?.()}catch{}throw n}return{port:m,url:b,...w!==void 0&&{tunnelUrl:w},close:async()=>{let n;try{await p?.stop()}catch(r){n=r}try{await e.close?.()}catch(r){n??=r}if(n!==void 0)throw n}}}async function _(t,o,s){let{mountInspector:c}=await x(),a=typeof t.basePath=="string"?t.basePath:"/mcp",i=c({basePath:a,devMode:!1,oauthProxyAllowLoopback:!1,manufactChatUrl:process.env.MANUFACT_CHAT_URL});return t.app.use("*",async(f,u)=>{if(E(f.req.raw,a))return i(f.req.raw);await u()}),t.listen(o,{host:s})}async function x(){let t;try{t=await import("@mcp-use/inspector")}catch(o){throw O(o)?new Error("Built-in Inspector is unavailable; reinstall mcp-use to restore it."):o}if(typeof t.mountInspector!="function")throw new Error("The installed @mcp-use/inspector is incompatible: its package entry does not export mountInspector(). Reinstall mcp-use.");return{mountInspector:t.mountInspector}}function A(t){return typeof t=="object"&&t!==null&&typeof t.listen=="function"}function O(t){return t!==null&&typeof t=="object"&&"code"in t&&(t.code==="ERR_MODULE_NOT_FOUND"||t.code==="MODULE_NOT_FOUND")}export{H as runStart};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-use/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.2-canary.
|
|
4
|
+
"version": "4.0.2-canary.4",
|
|
5
5
|
"description": "Prebuilt CLI, development server, and build pipeline for mcp-use",
|
|
6
6
|
"author": "mcp-use, Inc.",
|
|
7
7
|
"license": "MIT",
|
|
@@ -69,7 +69,8 @@
|
|
|
69
69
|
"typescript": "^5.9.3",
|
|
70
70
|
"vitest": "^4.1.9",
|
|
71
71
|
"zod": "^4.4.3",
|
|
72
|
-
"@mcp-use/client": "2.0.2-canary.2"
|
|
72
|
+
"@mcp-use/client": "2.0.2-canary.2",
|
|
73
|
+
"@mcp-use/tunnel": "0.2.0-canary.0"
|
|
73
74
|
},
|
|
74
75
|
"publishConfig": {
|
|
75
76
|
"access": "public"
|
package/dist/chunk-N35NYWRW.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import Y from"http";import{mkdir as D,readFile as H,writeFile as X}from"fs/promises";import{dirname as z}from"path";var J="https://api.tunnel.mcp-use.run",Q=3e4,$=64*1024,w=256*1024,K=1024*1024,O=100,j=25e3,W=5,G=1,V=2,L=3,Z=4,ee=5,te=6,T=36;function x(){return process.env.MCP_USE_TUNNEL_API??J}var v=1e3,F=3e4,ne=new Set(["connection","keep-alive","proxy-authenticate","proxy-authorization","proxy-connection","te","trailer","transfer-encoding","upgrade"]);function M(s){return new Promise(i=>{setTimeout(i,s)})}function C(s){process.env.MCP_USE_TUNNEL_DEBUG==="1"&&console.log(`[mcp-use] ${s}`)}function B(s){return typeof s=="string"&&/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(s)}function U(s,i=!1){let u={};for(let[o,d]of Object.entries(s)){let l=o.toLowerCase();d===void 0||ne.has(l)||i&&(l==="host"||l==="content-length")||(u[l]=typeof d=="number"?String(d):d)}return u}function P(s,i,u){let o=new TextEncoder().encode(i);if(o.byteLength!==T)throw new Error("Invalid tunnel request identifier");let d=new Uint8Array(1+T+u.byteLength);return d[0]=s,d.set(o,1),d.set(u,1+T),d}function re(s){let i=Buffer.from(s);if(i.byteLength<1+T||i.byteLength>1+T+w)return;let u=i.subarray(1,1+T).toString("ascii");if(B(u))return{kind:i[0]??0,requestId:u,body:i.subarray(1+T)}}function N(s){let i=new Uint8Array(s.byteLength);return i.set(s),i}async function oe(s){for(;s.readyState===WebSocket.OPEN&&s.bufferedAmount>K;)await M(5);if(s.readyState!==WebSocket.OPEN)throw new Error("Tunnel socket closed while applying backpressure")}function b(s,i){let u=JSON.stringify(i);if(Buffer.byteLength(u)>$)throw new Error("Tunnel control message exceeds 64 KiB");s.send(u)}async function se(s){let i=await s.text(),u={};try{u=JSON.parse(i)}catch{}if(!s.ok)throw new Error(u.error??`Tunnel relay returned HTTP ${s.status}`);return u}async function ie(s){let i=await fetch(new URL("/api/tunnels/request",x()),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(s===void 0?{}:{subdomain:s}),signal:AbortSignal.timeout(1e4)}),u=await se(i);if(typeof u.tunnel_id!="string"||typeof u.token!="string"||typeof u.connect_url!="string"||typeof u.public_url!="string")throw new Error("Tunnel relay returned an invalid reservation");return u}async function A(s){if(s.token!==void 0)try{await fetch(new URL(`/api/tunnels/${encodeURIComponent(s.subdomain)}`,x()),{method:"DELETE",headers:{authorization:`Bearer ${s.token}`},signal:AbortSignal.timeout(2e3)})}catch{}}async function ae(s,i,u){let o=new WebSocket(i.connect_url);o.binaryType="arraybuffer";let d=new Map,l=new Map,f=!1,g=!1,y=!1,_,q=(n,e)=>{let t=d.get(n);if(t!==void 0&&(d.delete(n),t.request.destroy(),t.response?.destroy(),o.readyState===WebSocket.OPEN))try{b(o,{type:"response-error",requestId:n,message:e instanceof Error?e.message:String(e)})}catch{}},I=n=>{if(!B(n.requestId)||d.has(n.requestId)||d.size>=O||typeof n.method!="string"||typeof n.path!="string"||!n.path.startsWith("/")){o.close(1008,"Invalid request");return}let e=U(n.headers,!0),t=n.headers["x-forwarded-host"];typeof t=="string"&&(e.host=t);let r=Y.request({hostname:"127.0.0.1",port:s,method:n.method,path:n.path,headers:e}),c={request:r};d.set(n.requestId,c),r.on("response",a=>{c.response=a,(async()=>{b(o,{type:"response-start",requestId:n.requestId,status:a.statusCode??502,headers:U(a.headers)});for await(let S of a){let p=Buffer.from(S);for(let R=0;R<p.byteLength;R+=w)await oe(o),o.send(P(V,n.requestId,p.subarray(R,R+w)))}d.has(n.requestId)&&(d.delete(n.requestId),b(o,{type:"response-end",requestId:n.requestId}))})().catch(S=>{q(n.requestId,S)})}),r.on("error",a=>{q(n.requestId,a)})},E=(n,e=1e3,t="")=>{let r=l.get(n);if(r!==void 0){l.delete(n);try{r.socket.close(e,t.slice(0,123))}catch{r.socket.close()}}},m=(n,e,t)=>{let r=l.get(n);if(r!==void 0){if(!r.open){if(r.queuedBytes+t.byteLength>K){E(n,1009,"WebSocket buffer limit reached"),b(o,{type:"websocket-error",requestId:n,message:"WebSocket buffer limit reached"});return}r.queue.push({kind:e,body:t}),r.queuedBytes+=t.byteLength;return}r.socket.send(e===L?t.toString("utf8"):N(t))}},h=n=>{if(!B(n.requestId)||l.has(n.requestId)||d.size+l.size>=O||typeof n.path!="string"||!n.path.startsWith("/")||n.protocols!==void 0&&(!Array.isArray(n.protocols)||n.protocols.some(c=>typeof c!="string"||!/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/.test(c)))){o.close(1008,"Invalid WebSocket request");return}let e=new URL(n.path,`ws://127.0.0.1:${s}`);if(e.origin!==`ws://127.0.0.1:${s}`){o.close(1008,"Invalid WebSocket path");return}let t=new WebSocket(e,n.protocols??[]);t.binaryType="arraybuffer";let r={socket:t,open:!1,queue:[],queuedBytes:0};l.set(n.requestId,r),t.addEventListener("open",()=>{if(l.get(n.requestId)===r){r.open=!0;for(let c of r.queue)t.send(c.kind===L?c.body.toString("utf8"):N(c.body));r.queue=[],r.queuedBytes=0,b(o,{type:"websocket-ready",requestId:n.requestId,...t.protocol!==""&&{protocol:t.protocol}})}}),t.addEventListener("message",c=>{if(o.readyState===WebSocket.OPEN){if(typeof c.data=="string"){let a=Buffer.from(c.data);if(a.byteLength>w){E(n.requestId,1009,"WebSocket message too large");return}o.send(P(ee,n.requestId,a))}else if(c.data instanceof ArrayBuffer){let a=Buffer.from(c.data);if(a.byteLength>w){E(n.requestId,1009,"WebSocket message too large");return}o.send(P(te,n.requestId,a))}}}),t.addEventListener("close",c=>{l.get(n.requestId)===r&&(l.delete(n.requestId),o.readyState===WebSocket.OPEN&&b(o,{type:"websocket-close",requestId:n.requestId,code:c.code,reason:c.reason}))}),t.addEventListener("error",()=>{l.get(n.requestId)===r&&o.readyState===WebSocket.OPEN&&b(o,{type:"websocket-error",requestId:n.requestId,message:"Local WebSocket connection failed"})})},k=new Promise((n,e)=>{let t=setTimeout(()=>{o.close(),e(new Error("Tunnel setup timed out"))},Q);o.addEventListener("open",()=>{b(o,{type:"authenticate",token:i.token})}),o.addEventListener("message",r=>{if(r.data instanceof ArrayBuffer){let p=re(r.data);if(p===void 0){o.close(1003,"Invalid body frame");return}p.kind===G?d.get(p.requestId)?.request.write(p.body):p.kind===L||p.kind===Z?m(p.requestId,p.kind,p.body):o.close(1003,"Invalid body frame");return}if(typeof r.data!="string"){o.close(1003,"Invalid message");return}let c=r.data;if(Buffer.byteLength(c)>$){o.close(1009,"Control message too large");return}let a;try{a=JSON.parse(c)}catch{o.close(1003,"Invalid JSON");return}if(a.type==="auth-required")return;if(a.type==="ready"){f||(f=!0,clearTimeout(t),a.keepalive===!0&&(_=setInterval(()=>{if(o.readyState===WebSocket.OPEN){if(y){o.close(1011,"Tunnel keepalive timed out");return}y=!0,b(o,{type:"ping"})}},j),_.unref()),n());return}if(a.type==="pong"){y=!1;return}if(a.type==="request-start"){I(a);return}if(a.type==="websocket-open"){h(a);return}if(!B(a.requestId)){o.close(1008,"Invalid request identifier");return}let S=d.get(a.requestId);if(a.type==="request-end")S?.request.end();else if(a.type==="cancel"&&S!==void 0)d.delete(a.requestId),S.request.destroy(),S.response?.destroy();else if(a.type==="websocket-close"){let p=Number.isInteger(a.code)&&(a.code??0)>=1e3&&(a.code??0)<=4999?a.code:1e3;E(a.requestId,p,a.reason??"")}else o.close(1003,"Unsupported message")}),o.addEventListener("error",()=>{f||(clearTimeout(t),e(new Error("Tunnel WebSocket connection failed")))},{once:!0})});return o.addEventListener("close",n=>{_!==void 0&&clearInterval(_);for(let[e,t]of d)d.delete(e),t.request.destroy(),t.response?.destroy();for(let e of l.keys())E(e,1011,"Tunnel disconnected");!g&&f&&u(n)}),await k,Object.defineProperty(o,"__mcpUseIntentionalClose",{value:()=>{g=!0}}),{url:i.public_url,subdomain:i.tunnel_id,token:i.token,socket:o,reservation:i}}function ue(s){let i=s.__mcpUseIntentionalClose;i?.()}function fe(s){let i,u=null,o,d=!1,l,f=v,g,y=0,_=async()=>{try{let e=await H(s,"utf8"),t=JSON.parse(e);return typeof t.subdomain=="string"?{subdomain:t.subdomain,...typeof t.token=="string"&&{token:t.token},...typeof t.connect_url=="string"&&{connect_url:t.connect_url},...typeof t.public_url=="string"&&{public_url:t.public_url}}:void 0}catch{return}},q=async e=>{try{await D(z(s),{recursive:!0}),await X(s,JSON.stringify(e,null,2),{encoding:"utf8",mode:384})}catch(t){console.warn(`[mcp-use] failed to save tunnel state: ${t instanceof Error?t.message:String(t)}`)}},I=()=>{},E=e=>e?.token!==void 0&&e.connect_url!==void 0&&e.public_url!==void 0?{tunnel_id:e.subdomain,token:e.token,connect_url:e.connect_url,public_url:e.public_url}:void 0,m=e=>({subdomain:e.tunnel_id,token:e.token,connect_url:e.connect_url,public_url:e.public_url}),h=async e=>{await q(m(e.reservation))},k=async(e,t)=>ae(e,t,r=>{i=void 0,u=null;let c=r.code===1008||r.reason==="Tunnel expired"||r.reason==="Tunnel deleted";g=c?void 0:t,C(`tunnel connection closed (${r.code}${r.reason===""?"":`: ${r.reason}`}); ${c?"allocating a replacement":"reattaching"}`),I()}),n=async(e,t)=>{console.log(`[mcp-use] starting tunnel for port ${e}\u2026`);let r=await ie(t);return k(e,r)};return I=()=>{d||o===void 0||u!==null||l!==void 0||(l=(async()=>{for(;!d&&o!==void 0&&u===null;)try{if(g!==void 0&&y<W)try{let r=await k(o,g);i=r,u=r.url,y=0,f=v,await h(r),C("tunnel reattached");return}catch(r){if(y+=1,C(`tunnel reattach attempt ${y} failed: ${r instanceof Error?r.message:String(r)}`),y<W){await M(f),f=Math.min(f*2,F);continue}}let e=await _();e!==void 0&&await A(e),g=void 0,y=0;let t;try{t=await n(o,e?.subdomain)}catch(r){if(e?.subdomain===void 0)throw r;console.log(`[mcp-use] tunnel "${e.subdomain}" unavailable, requesting a new one\u2026`),t=await n(o)}i=t,u=t.url,await h(t),f=v;return}catch(e){console.warn(`[mcp-use] tunnel restart failed: ${e instanceof Error?e.message:String(e)}`),await M(f),f=Math.min(f*2,F)}})().finally(()=>{l=void 0}))},{status(){return{url:u}},async start(e){if(d=!1,o=e,i!==void 0&&u!==null)return{url:u,subdomain:i.subdomain};let t=await _(),r,c=E(t);if(c!==void 0)try{r=await k(e,c)}catch{await A(m(c)),r=await n(e,c.tunnel_id).catch(async()=>(console.log(`[mcp-use] tunnel "${c.tunnel_id}" unavailable, requesting a new one\u2026`),n(e)))}else{t!==void 0&&await A(t);try{r=await n(e,t?.subdomain)}catch(a){if(t?.subdomain===void 0)throw a;console.log(`[mcp-use] tunnel "${t.subdomain}" unavailable, requesting a new one\u2026`),r=await n(e)}}return i=r,u=r.url,g=r.reservation,y=0,await h(r),{url:r.url,subdomain:r.subdomain}},async stop(){d=!0,l!==void 0&&await l;let e=i,t=e?.reservation??g;i=void 0,u=null,o=void 0,f=v,g=void 0,y=0,t!==void 0&&await A(m(t)),e!==void 0&&(ue(e.socket),e.socket.close(1e3,"Client shutdown"))}}}export{fe as a};
|
package/dist/tunnel-ROVTBKBW.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"./chunk-N35NYWRW.js";import"./chunk-WOT6VMZA.js";export{a as createTunnelManager};
|