@mcp-use/cli 4.0.2-canary.1 → 4.0.2-canary.3

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.
Files changed (37) hide show
  1. package/dist/bin.js +1 -1
  2. package/dist/{chunk-JAWUXU2E.js → chunk-23BW3OXH.js} +5 -5
  3. package/dist/chunk-AUVTUYMK.js +1 -0
  4. package/dist/{chunk-VUVLJMYY.js → chunk-DODFSHJ5.js} +1 -1
  5. package/dist/{chunk-ISAAAHEM.js → chunk-F22D552R.js} +5 -5
  6. package/dist/{chunk-3XW44DRS.js → chunk-JHCVAC2M.js} +1 -1
  7. package/dist/chunk-JRCSP5WH.js +4 -0
  8. package/dist/{chunk-FLGSKQGU.js → chunk-LUVZUL5C.js} +1 -1
  9. package/dist/chunk-WOT6VMZA.js +1 -0
  10. package/dist/commands/build.js +5 -5
  11. package/dist/commands/client.js +1 -1
  12. package/dist/commands/deploy.js +1 -1
  13. package/dist/commands/deployments.js +1 -1
  14. package/dist/commands/dev.js +81 -2
  15. package/dist/commands/identity.js +1 -1
  16. package/dist/commands/organizations.js +1 -1
  17. package/dist/commands/screenshot.js +1 -1
  18. package/dist/commands/servers.js +1 -1
  19. package/dist/commands/start.js +1 -1
  20. package/dist/commands/typecheck.js +1 -1
  21. package/dist/dist-WKBHGU46.js +1 -0
  22. package/dist/index.js +1 -1
  23. package/dist/next-server-shims.js +1 -1
  24. package/dist/start-Z5UXFGTP.js +4 -0
  25. package/dist/third-party-licenses/modelcontextprotocol-core-LICENSE +216 -0
  26. package/dist/third-party-licenses/modelcontextprotocol-server-LICENSE +216 -0
  27. package/dist/third-party-licenses/zod-LICENSE +21 -0
  28. package/package.json +16 -4
  29. package/dist/chunk-F5XPOFT7.js +0 -1
  30. package/dist/chunk-ICHICRCP.js +0 -4
  31. package/dist/node-bridge-WOT2W5YZ.js +0 -1
  32. package/dist/start-PIY244P7.js +0 -4
  33. package/dist/tunnel-FOJUZGIJ.js +0 -1
  34. /package/dist/{chunk-N7BU45K6.js → chunk-4EER3N42.js} +0 -0
  35. /package/dist/{chunk-7G4TXPP4.js → chunk-OMRWADFK.js} +0 -0
  36. /package/dist/{chunk-STQ3SGCH.js → chunk-RXKUVCL7.js} +0 -0
  37. /package/dist/{chunk-LNASFQWW.js → chunk-S3WHXP7I.js} +0 -0
@@ -1,4 +1,4 @@
1
- import{b as u,c as b,d as g,e as z,f as P,g as p}from"../chunk-3XW44DRS.js";import{a as d,b as s,c as w,d as y,e as l,f as v,g as _,h as C}from"../chunk-VUVLJMYY.js";import"../chunk-LNASFQWW.js";import{parseArgs as f}from"util";import{createInterface as E}from"readline/promises";var O="mcp-use-cli",I=1800*1e3,T=`Usage: mcp-use login [options]
1
+ import{b as u,c as b,d as g,e as z,f as P,g as p}from"../chunk-JHCVAC2M.js";import{a as d,b as s,c as w,d as y,e as l,f as v,g as _,h as C}from"../chunk-DODFSHJ5.js";import"../chunk-S3WHXP7I.js";import"../chunk-WOT6VMZA.js";import{parseArgs as f}from"util";import{createInterface as E}from"readline/promises";var O="mcp-use-cli",I=1800*1e3,T=`Usage: mcp-use login [options]
2
2
 
3
3
  Authenticate the cloud CLI.
4
4
 
@@ -1,4 +1,4 @@
1
- import{c as h,d as f,f as w,g as z}from"../chunk-3XW44DRS.js";import{a as r,d as m,e as u,f as p}from"../chunk-VUVLJMYY.js";import"../chunk-LNASFQWW.js";import{parseArgs as j}from"util";var E=`Usage: mcp-use org <command> [options]
1
+ import{c as h,d as f,f as w,g as z}from"../chunk-JHCVAC2M.js";import{a as r,d as m,e as u,f as p}from"../chunk-DODFSHJ5.js";import"../chunk-S3WHXP7I.js";import"../chunk-WOT6VMZA.js";import{parseArgs as j}from"util";var E=`Usage: mcp-use org <command> [options]
2
2
 
3
3
  Manage the active cloud organization.
4
4
 
@@ -1,4 +1,4 @@
1
- import{b as B,c as H,d as R}from"../chunk-ISAAAHEM.js";import{a as c,b as s,d as T,e as _,f as M}from"../chunk-VUVLJMYY.js";import"../chunk-LNASFQWW.js";import{spawn as $}from"child_process";import{access as j,mkdtemp as F,rm as A,writeFile as G}from"fs/promises";import{createServer as V}from"net";import{tmpdir as J}from"os";import{basename as q,join as W,resolve as z}from"path";import{parseArgs as K}from"util";import{fileURLToPath as X}from"url";var Q=`Usage: mcp-use screenshot (--server <name> | --mcp <url>) --tool <name> [args...] [options]
1
+ import{b as B,c as H,d as R}from"../chunk-F22D552R.js";import{a as c,b as s,d as T,e as _,f as M}from"../chunk-DODFSHJ5.js";import"../chunk-S3WHXP7I.js";import"../chunk-WOT6VMZA.js";import{spawn as $}from"child_process";import{access as j,mkdtemp as F,rm as A,writeFile as G}from"fs/promises";import{createServer as V}from"net";import{tmpdir as J}from"os";import{basename as q,join as W,resolve as z}from"path";import{parseArgs as K}from"util";import{fileURLToPath as X}from"url";var Q=`Usage: mcp-use screenshot (--server <name> | --mcp <url>) --tool <name> [args...] [options]
2
2
 
3
3
  Call a view-backed MCP tool and capture its rendered MCP App as PNG.
4
4
 
@@ -1,4 +1,4 @@
1
- import{h as p}from"../chunk-3XW44DRS.js";import{a as u,d as E,e as d,f as $,g as w}from"../chunk-VUVLJMYY.js";import"../chunk-LNASFQWW.js";import{parseArgs as g}from"util";var R=`Usage: mcp-use servers <command> [options]
1
+ import{h as p}from"../chunk-JHCVAC2M.js";import{a as u,d as E,e as d,f as $,g as w}from"../chunk-DODFSHJ5.js";import"../chunk-S3WHXP7I.js";import"../chunk-WOT6VMZA.js";import{parseArgs as g}from"util";var R=`Usage: mcp-use servers <command> [options]
2
2
 
3
3
  Manage cloud servers and environment variables.
4
4
 
@@ -1 +1 @@
1
- async function e(t){return(await import("../start-PIY244P7.js")).runStart(t)}export{e as runStart};
1
+ import"../chunk-WOT6VMZA.js";async function e(t){return(await import("../start-Z5UXFGTP.js")).runStart(t)}export{e as runStart};
@@ -1 +1 @@
1
- import{a as p,b as a}from"../chunk-FLGSKQGU.js";import{spawn as d}from"child_process";import{createRequire as u}from"module";import{dirname as l,join as m,resolve as y}from"path";async function f(e){let n=performance.now(),t=e.mcpDir===void 0?e.cwd:y(e.cwd,e.mcpDir),s=e.entry===void 0?p(t):p(e.cwd,e.entry),r=await a(e.cwd,s);r==="created"||r==="updated"?console.log(`[mcp-use] ${r} mcp-env.d.ts`):r==="user-owned"&&console.warn("[mcp-use] mcp-env.d.ts is user-owned; leaving it unchanged");let c=w(e.cwd),o=await g(c,e.cwd,e.tscArgs??[]);if(o===0){let i=Math.round(performance.now()-n);console.log(`[mcp-use] no type errors (${i}ms)`)}return o}function w(e){let n=u(m(e,"package.json"));try{let t=n.resolve("typescript/package.json");return m(l(t),"bin","tsc")}catch{throw new Error(`TypeScript is not installed in ${e}. Install it with npm install --save-dev typescript.`)}}function g(e,n,t){return new Promise((s,r)=>{let c=d(process.execPath,[e,...t,"--noEmit"],{cwd:n,stdio:"inherit"});c.once("error",r),c.once("close",(o,i)=>{s(o??(i==="SIGINT"?130:1))})})}export{f as runTypecheck};
1
+ import{a as p,b as a}from"../chunk-LUVZUL5C.js";import"../chunk-WOT6VMZA.js";import{spawn as d}from"child_process";import{createRequire as u}from"module";import{dirname as l,join as m,resolve as y}from"path";async function f(e){let n=performance.now(),t=e.mcpDir===void 0?e.cwd:y(e.cwd,e.mcpDir),s=e.entry===void 0?p(t):p(e.cwd,e.entry),r=await a(e.cwd,s);r==="created"||r==="updated"?console.log(`[mcp-use] ${r} mcp-env.d.ts`):r==="user-owned"&&console.warn("[mcp-use] mcp-env.d.ts is user-owned; leaving it unchanged");let c=w(e.cwd),o=await g(c,e.cwd,e.tscArgs??[]);if(o===0){let i=Math.round(performance.now()-n);console.log(`[mcp-use] no type errors (${i}ms)`)}return o}function w(e){let n=u(m(e,"package.json"));try{let t=n.resolve("typescript/package.json");return m(l(t),"bin","tsc")}catch{throw new Error(`TypeScript is not installed in ${e}. Install it with npm install --save-dev typescript.`)}}function g(e,n,t){return new Promise((s,r)=>{let c=d(process.execPath,[e,...t,"--noEmit"],{cwd:n,stdio:"inherit"});c.once("error",r),c.once("close",(o,i)=>{s(o??(i==="SIGINT"?130:1))})})}export{f as runTypecheck};
@@ -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-JAWUXU2E.js";import"./chunk-STQ3SGCH.js";export{a as main};
1
+ import{a}from"./chunk-23BW3OXH.js";import"./chunk-RXKUVCL7.js";import"./chunk-WOT6VMZA.js";export{a as main};
@@ -1 +1 @@
1
- function a(){}function d(){}function u(){}function l(){}function p(){}function x(e){return e}async function f(){return new Headers}var i={get:()=>{},getAll:()=>[],has:()=>!1,set:()=>{},delete:()=>{}};async function g(){return i}async function R(){return{isEnabled:!1,enable(){},disable(){}}}function c(e){let n=new Error(`redirect(${String(e)}) called outside Next.js`);throw Object.assign(n,{digest:`NEXT_REDIRECT;${String(e)}`}),n}var w=c;function h(){let e=new Error("notFound() called outside Next.js");throw Object.assign(e,{digest:"NEXT_NOT_FOUND"}),e}var v={push:"push",replace:"replace"},o=class e extends Response{static json(n,t){let r=new Headers(t?.headers);return r.set("content-type","application/json"),new e(JSON.stringify(n),{...t,headers:r})}static redirect(n,t=302){return new e(null,{status:t,headers:{location:String(n)}})}static next(){return new e(null)}static rewrite(){return new e(null)}},s=class extends Request{nextUrl;cookies=i;constructor(n,t){super(n,t),this.nextUrl=new URL(typeof n=="string"?n:n instanceof URL?n.href:n.url)}};function y(){return{ua:"",browser:{},device:{},engine:{},os:{},cpu:{},isBot:!1}}export{s as NextRequest,o as NextResponse,v as RedirectType,g as cookies,R as draftMode,f as headers,h as notFound,w as permanentRedirect,c as redirect,a as revalidatePath,d as revalidateTag,x as unstable_cache,l as unstable_cacheLife,p as unstable_cacheTag,u as unstable_noStore,y as userAgent};
1
+ import"./chunk-WOT6VMZA.js";function a(){}function d(){}function u(){}function l(){}function p(){}function x(e){return e}async function f(){return new Headers}var i={get:()=>{},getAll:()=>[],has:()=>!1,set:()=>{},delete:()=>{}};async function g(){return i}async function R(){return{isEnabled:!1,enable(){},disable(){}}}function c(e){let n=new Error(`redirect(${String(e)}) called outside Next.js`);throw Object.assign(n,{digest:`NEXT_REDIRECT;${String(e)}`}),n}function w(e){return c(e)}function h(){let e=new Error("notFound() called outside Next.js");throw Object.assign(e,{digest:"NEXT_NOT_FOUND"}),e}var v={push:"push",replace:"replace"},o=class e extends Response{static json(n,t){let r=new Headers(t?.headers);return r.set("content-type","application/json"),new e(JSON.stringify(n),{...t,headers:r})}static redirect(n,t=302){return new e(null,{status:t,headers:{location:String(n)}})}static next(){return new e(null)}static rewrite(){return new e(null)}},s=class extends Request{nextUrl;cookies=i;constructor(n,t){super(n,t),this.nextUrl=new URL(typeof n=="string"?n:n instanceof URL?n.href:n.url)}};function y(){return{ua:"",browser:{},device:{},engine:{},os:{},cpu:{},isBot:!1}}export{s as NextRequest,o as NextResponse,v as RedirectType,g as cookies,R as draftMode,f as headers,h as notFound,w as permanentRedirect,c as redirect,a as revalidatePath,d as revalidateTag,x as unstable_cache,l as unstable_cacheLife,p as unstable_cacheTag,u as unstable_noStore,y as userAgent};
@@ -0,0 +1,4 @@
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
+ 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
+ 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("./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};
@@ -0,0 +1,216 @@
1
+ The MCP project is undergoing a licensing transition from the MIT License to the Apache License, Version 2.0 ("Apache-2.0"). All new code and specification contributions to the project are licensed under Apache-2.0. Documentation contributions (excluding specifications) are licensed under CC-BY-4.0.
2
+
3
+ Contributions for which relicensing consent has been obtained are licensed under Apache-2.0. Contributions made by authors who originally licensed their work under the MIT License and who have not yet granted explicit permission to relicense remain licensed under the MIT License.
4
+
5
+ No rights beyond those granted by the applicable original license are conveyed for such contributions.
6
+
7
+ ---
8
+
9
+ Apache License
10
+ Version 2.0, January 2004
11
+ http://www.apache.org/licenses/
12
+
13
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
14
+
15
+ 1. Definitions.
16
+
17
+ "License" shall mean the terms and conditions for use, reproduction,
18
+ and distribution as defined by Sections 1 through 9 of this document.
19
+
20
+ "Licensor" shall mean the copyright owner or entity authorized by
21
+ the copyright owner that is granting the License.
22
+
23
+ "Legal Entity" shall mean the union of the acting entity and all
24
+ other entities that control, are controlled by, or are under common
25
+ control with that entity. For the purposes of this definition,
26
+ "control" means (i) the power, direct or indirect, to cause the
27
+ direction or management of such entity, whether by contract or
28
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
29
+ outstanding shares, or (iii) beneficial ownership of such entity.
30
+
31
+ "You" (or "Your") shall mean an individual or Legal Entity
32
+ exercising permissions granted by this License.
33
+
34
+ "Source" form shall mean the preferred form for making modifications,
35
+ including but not limited to software source code, documentation
36
+ source, and configuration files.
37
+
38
+ "Object" form shall mean any form resulting from mechanical
39
+ transformation or translation of a Source form, including but
40
+ not limited to compiled object code, generated documentation,
41
+ and conversions to other media types.
42
+
43
+ "Work" shall mean the work of authorship, whether in Source or
44
+ Object form, made available under the License, as indicated by a
45
+ copyright notice that is included in or attached to the work
46
+ (an example is provided in the Appendix below).
47
+
48
+ "Derivative Works" shall mean any work, whether in Source or Object
49
+ form, that is based on (or derived from) the Work and for which the
50
+ editorial revisions, annotations, elaborations, or other modifications
51
+ represent, as a whole, an original work of authorship. For the purposes
52
+ of this License, Derivative Works shall not include works that remain
53
+ separable from, or merely link (or bind by name) to the interfaces of,
54
+ the Work and Derivative Works thereof.
55
+
56
+ "Contribution" shall mean any work of authorship, including
57
+ the original version of the Work and any modifications or additions
58
+ to that Work or Derivative Works thereof, that is intentionally
59
+ submitted to the Licensor for inclusion in the Work by the copyright
60
+ owner or by an individual or Legal Entity authorized to submit on behalf
61
+ of the copyright owner. For the purposes of this definition, "submitted"
62
+ means any form of electronic, verbal, or written communication sent
63
+ to the Licensor or its representatives, including but not limited to
64
+ communication on electronic mailing lists, source code control systems,
65
+ and issue tracking systems that are managed by, or on behalf of, the
66
+ Licensor for the purpose of discussing and improving the Work, but
67
+ excluding communication that is conspicuously marked or otherwise
68
+ designated in writing by the copyright owner as "Not a Contribution."
69
+
70
+ "Contributor" shall mean Licensor and any individual or Legal Entity
71
+ on behalf of whom a Contribution has been received by Licensor and
72
+ subsequently incorporated within the Work.
73
+
74
+ 2. Grant of Copyright License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ copyright license to reproduce, prepare Derivative Works of,
78
+ publicly display, publicly perform, sublicense, and distribute the
79
+ Work and such Derivative Works in Source or Object form.
80
+
81
+ 3. Grant of Patent License. Subject to the terms and conditions of
82
+ this License, each Contributor hereby grants to You a perpetual,
83
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
84
+ (except as stated in this section) patent license to make, have made,
85
+ use, offer to sell, sell, import, and otherwise transfer the Work,
86
+ where such license applies only to those patent claims licensable
87
+ by such Contributor that are necessarily infringed by their
88
+ Contribution(s) alone or by combination of their Contribution(s)
89
+ with the Work to which such Contribution(s) was submitted. If You
90
+ institute patent litigation against any entity (including a
91
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
92
+ or a Contribution incorporated within the Work constitutes direct
93
+ or contributory patent infringement, then any patent licenses
94
+ granted to You under this License for that Work shall terminate
95
+ as of the date such litigation is filed.
96
+
97
+ 4. Redistribution. You may reproduce and distribute copies of the
98
+ Work or Derivative Works thereof in any medium, with or without
99
+ modifications, and in Source or Object form, provided that You
100
+ meet the following conditions:
101
+
102
+ (a) You must give any other recipients of the Work or
103
+ Derivative Works a copy of this License; and
104
+
105
+ (b) You must cause any modified files to carry prominent notices
106
+ stating that You changed the files; and
107
+
108
+ (c) You must retain, in the Source form of any Derivative Works
109
+ that You distribute, all copyright, patent, trademark, and
110
+ attribution notices from the Source form of the Work,
111
+ excluding those notices that do not pertain to any part of
112
+ the Derivative Works; and
113
+
114
+ (d) If the Work includes a "NOTICE" text file as part of its
115
+ distribution, then any Derivative Works that You distribute must
116
+ include a readable copy of the attribution notices contained
117
+ within such NOTICE file, excluding those notices that do not
118
+ pertain to any part of the Derivative Works, in at least one
119
+ of the following places: within a NOTICE text file distributed
120
+ as part of the Derivative Works; within the Source form or
121
+ documentation, if provided along with the Derivative Works; or,
122
+ within a display generated by the Derivative Works, if and
123
+ wherever such third-party notices normally appear. The contents
124
+ of the NOTICE file are for informational purposes only and
125
+ do not modify the License. You may add Your own attribution
126
+ notices within Derivative Works that You distribute, alongside
127
+ or as an addendum to the NOTICE text from the Work, provided
128
+ that such additional attribution notices cannot be construed
129
+ as modifying the License.
130
+
131
+ You may add Your own copyright statement to Your modifications and
132
+ may provide additional or different license terms and conditions
133
+ for use, reproduction, or distribution of Your modifications, or
134
+ for any such Derivative Works as a whole, provided Your use,
135
+ reproduction, and distribution of the Work otherwise complies with
136
+ the conditions stated in this License.
137
+
138
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
139
+ any Contribution intentionally submitted for inclusion in the Work
140
+ by You to the Licensor shall be under the terms and conditions of
141
+ this License, without any additional terms or conditions.
142
+ Notwithstanding the above, nothing herein shall supersede or modify
143
+ the terms of any separate license agreement you may have executed
144
+ with Licensor regarding such Contributions.
145
+
146
+ 6. Trademarks. This License does not grant permission to use the trade
147
+ names, trademarks, service marks, or product names of the Licensor,
148
+ except as required for reasonable and customary use in describing the
149
+ origin of the Work and reproducing the content of the NOTICE file.
150
+
151
+ 7. Disclaimer of Warranty. Unless required by applicable law or
152
+ agreed to in writing, Licensor provides the Work (and each
153
+ Contributor provides its Contributions) on an "AS IS" BASIS,
154
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
155
+ implied, including, without limitation, any warranties or conditions
156
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
157
+ PARTICULAR PURPOSE. You are solely responsible for determining the
158
+ appropriateness of using or redistributing the Work and assume any
159
+ risks associated with Your exercise of permissions under this License.
160
+
161
+ 8. Limitation of Liability. In no event and under no legal theory,
162
+ whether in tort (including negligence), contract, or otherwise,
163
+ unless required by applicable law (such as deliberate and grossly
164
+ negligent acts) or agreed to in writing, shall any Contributor be
165
+ liable to You for damages, including any direct, indirect, special,
166
+ incidental, or consequential damages of any character arising as a
167
+ result of this License or out of the use or inability to use the
168
+ Work (including but not limited to damages for loss of goodwill,
169
+ work stoppage, computer failure or malfunction, or any and all
170
+ other commercial damages or losses), even if such Contributor
171
+ has been advised of the possibility of such damages.
172
+
173
+ 9. Accepting Warranty or Additional Liability. While redistributing
174
+ the Work or Derivative Works thereof, You may choose to offer,
175
+ and charge a fee for, acceptance of support, warranty, indemnity,
176
+ or other liability obligations and/or rights consistent with this
177
+ License. However, in accepting such obligations, You may act only
178
+ on Your own behalf and on Your sole responsibility, not on behalf
179
+ of any other Contributor, and only if You agree to indemnify,
180
+ defend, and hold each Contributor harmless for any liability
181
+ incurred by, or claims asserted against, such Contributor by reason
182
+ of your accepting any such warranty or additional liability.
183
+
184
+ END OF TERMS AND CONDITIONS
185
+
186
+ ---
187
+
188
+ MIT License
189
+
190
+ Copyright (c) 2024-2025 Model Context Protocol a Series of LF Projects, LLC.
191
+
192
+ Permission is hereby granted, free of charge, to any person obtaining a copy
193
+ of this software and associated documentation files (the "Software"), to deal
194
+ in the Software without restriction, including without limitation the rights
195
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
196
+ copies of the Software, and to permit persons to whom the Software is
197
+ furnished to do so, subject to the following conditions:
198
+
199
+ The above copyright notice and this permission notice shall be included in all
200
+ copies or substantial portions of the Software.
201
+
202
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
203
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
204
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
205
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
206
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
207
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
208
+ SOFTWARE.
209
+
210
+ ---
211
+
212
+ Creative Commons Attribution 4.0 International (CC-BY-4.0)
213
+
214
+ Documentation in this project (excluding specifications) is licensed under
215
+ CC-BY-4.0. See https://creativecommons.org/licenses/by/4.0/legalcode for
216
+ the full license text.
@@ -0,0 +1,216 @@
1
+ The MCP project is undergoing a licensing transition from the MIT License to the Apache License, Version 2.0 ("Apache-2.0"). All new code and specification contributions to the project are licensed under Apache-2.0. Documentation contributions (excluding specifications) are licensed under CC-BY-4.0.
2
+
3
+ Contributions for which relicensing consent has been obtained are licensed under Apache-2.0. Contributions made by authors who originally licensed their work under the MIT License and who have not yet granted explicit permission to relicense remain licensed under the MIT License.
4
+
5
+ No rights beyond those granted by the applicable original license are conveyed for such contributions.
6
+
7
+ ---
8
+
9
+ Apache License
10
+ Version 2.0, January 2004
11
+ http://www.apache.org/licenses/
12
+
13
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
14
+
15
+ 1. Definitions.
16
+
17
+ "License" shall mean the terms and conditions for use, reproduction,
18
+ and distribution as defined by Sections 1 through 9 of this document.
19
+
20
+ "Licensor" shall mean the copyright owner or entity authorized by
21
+ the copyright owner that is granting the License.
22
+
23
+ "Legal Entity" shall mean the union of the acting entity and all
24
+ other entities that control, are controlled by, or are under common
25
+ control with that entity. For the purposes of this definition,
26
+ "control" means (i) the power, direct or indirect, to cause the
27
+ direction or management of such entity, whether by contract or
28
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
29
+ outstanding shares, or (iii) beneficial ownership of such entity.
30
+
31
+ "You" (or "Your") shall mean an individual or Legal Entity
32
+ exercising permissions granted by this License.
33
+
34
+ "Source" form shall mean the preferred form for making modifications,
35
+ including but not limited to software source code, documentation
36
+ source, and configuration files.
37
+
38
+ "Object" form shall mean any form resulting from mechanical
39
+ transformation or translation of a Source form, including but
40
+ not limited to compiled object code, generated documentation,
41
+ and conversions to other media types.
42
+
43
+ "Work" shall mean the work of authorship, whether in Source or
44
+ Object form, made available under the License, as indicated by a
45
+ copyright notice that is included in or attached to the work
46
+ (an example is provided in the Appendix below).
47
+
48
+ "Derivative Works" shall mean any work, whether in Source or Object
49
+ form, that is based on (or derived from) the Work and for which the
50
+ editorial revisions, annotations, elaborations, or other modifications
51
+ represent, as a whole, an original work of authorship. For the purposes
52
+ of this License, Derivative Works shall not include works that remain
53
+ separable from, or merely link (or bind by name) to the interfaces of,
54
+ the Work and Derivative Works thereof.
55
+
56
+ "Contribution" shall mean any work of authorship, including
57
+ the original version of the Work and any modifications or additions
58
+ to that Work or Derivative Works thereof, that is intentionally
59
+ submitted to the Licensor for inclusion in the Work by the copyright
60
+ owner or by an individual or Legal Entity authorized to submit on behalf
61
+ of the copyright owner. For the purposes of this definition, "submitted"
62
+ means any form of electronic, verbal, or written communication sent
63
+ to the Licensor or its representatives, including but not limited to
64
+ communication on electronic mailing lists, source code control systems,
65
+ and issue tracking systems that are managed by, or on behalf of, the
66
+ Licensor for the purpose of discussing and improving the Work, but
67
+ excluding communication that is conspicuously marked or otherwise
68
+ designated in writing by the copyright owner as "Not a Contribution."
69
+
70
+ "Contributor" shall mean Licensor and any individual or Legal Entity
71
+ on behalf of whom a Contribution has been received by Licensor and
72
+ subsequently incorporated within the Work.
73
+
74
+ 2. Grant of Copyright License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ copyright license to reproduce, prepare Derivative Works of,
78
+ publicly display, publicly perform, sublicense, and distribute the
79
+ Work and such Derivative Works in Source or Object form.
80
+
81
+ 3. Grant of Patent License. Subject to the terms and conditions of
82
+ this License, each Contributor hereby grants to You a perpetual,
83
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
84
+ (except as stated in this section) patent license to make, have made,
85
+ use, offer to sell, sell, import, and otherwise transfer the Work,
86
+ where such license applies only to those patent claims licensable
87
+ by such Contributor that are necessarily infringed by their
88
+ Contribution(s) alone or by combination of their Contribution(s)
89
+ with the Work to which such Contribution(s) was submitted. If You
90
+ institute patent litigation against any entity (including a
91
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
92
+ or a Contribution incorporated within the Work constitutes direct
93
+ or contributory patent infringement, then any patent licenses
94
+ granted to You under this License for that Work shall terminate
95
+ as of the date such litigation is filed.
96
+
97
+ 4. Redistribution. You may reproduce and distribute copies of the
98
+ Work or Derivative Works thereof in any medium, with or without
99
+ modifications, and in Source or Object form, provided that You
100
+ meet the following conditions:
101
+
102
+ (a) You must give any other recipients of the Work or
103
+ Derivative Works a copy of this License; and
104
+
105
+ (b) You must cause any modified files to carry prominent notices
106
+ stating that You changed the files; and
107
+
108
+ (c) You must retain, in the Source form of any Derivative Works
109
+ that You distribute, all copyright, patent, trademark, and
110
+ attribution notices from the Source form of the Work,
111
+ excluding those notices that do not pertain to any part of
112
+ the Derivative Works; and
113
+
114
+ (d) If the Work includes a "NOTICE" text file as part of its
115
+ distribution, then any Derivative Works that You distribute must
116
+ include a readable copy of the attribution notices contained
117
+ within such NOTICE file, excluding those notices that do not
118
+ pertain to any part of the Derivative Works, in at least one
119
+ of the following places: within a NOTICE text file distributed
120
+ as part of the Derivative Works; within the Source form or
121
+ documentation, if provided along with the Derivative Works; or,
122
+ within a display generated by the Derivative Works, if and
123
+ wherever such third-party notices normally appear. The contents
124
+ of the NOTICE file are for informational purposes only and
125
+ do not modify the License. You may add Your own attribution
126
+ notices within Derivative Works that You distribute, alongside
127
+ or as an addendum to the NOTICE text from the Work, provided
128
+ that such additional attribution notices cannot be construed
129
+ as modifying the License.
130
+
131
+ You may add Your own copyright statement to Your modifications and
132
+ may provide additional or different license terms and conditions
133
+ for use, reproduction, or distribution of Your modifications, or
134
+ for any such Derivative Works as a whole, provided Your use,
135
+ reproduction, and distribution of the Work otherwise complies with
136
+ the conditions stated in this License.
137
+
138
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
139
+ any Contribution intentionally submitted for inclusion in the Work
140
+ by You to the Licensor shall be under the terms and conditions of
141
+ this License, without any additional terms or conditions.
142
+ Notwithstanding the above, nothing herein shall supersede or modify
143
+ the terms of any separate license agreement you may have executed
144
+ with Licensor regarding such Contributions.
145
+
146
+ 6. Trademarks. This License does not grant permission to use the trade
147
+ names, trademarks, service marks, or product names of the Licensor,
148
+ except as required for reasonable and customary use in describing the
149
+ origin of the Work and reproducing the content of the NOTICE file.
150
+
151
+ 7. Disclaimer of Warranty. Unless required by applicable law or
152
+ agreed to in writing, Licensor provides the Work (and each
153
+ Contributor provides its Contributions) on an "AS IS" BASIS,
154
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
155
+ implied, including, without limitation, any warranties or conditions
156
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
157
+ PARTICULAR PURPOSE. You are solely responsible for determining the
158
+ appropriateness of using or redistributing the Work and assume any
159
+ risks associated with Your exercise of permissions under this License.
160
+
161
+ 8. Limitation of Liability. In no event and under no legal theory,
162
+ whether in tort (including negligence), contract, or otherwise,
163
+ unless required by applicable law (such as deliberate and grossly
164
+ negligent acts) or agreed to in writing, shall any Contributor be
165
+ liable to You for damages, including any direct, indirect, special,
166
+ incidental, or consequential damages of any character arising as a
167
+ result of this License or out of the use or inability to use the
168
+ Work (including but not limited to damages for loss of goodwill,
169
+ work stoppage, computer failure or malfunction, or any and all
170
+ other commercial damages or losses), even if such Contributor
171
+ has been advised of the possibility of such damages.
172
+
173
+ 9. Accepting Warranty or Additional Liability. While redistributing
174
+ the Work or Derivative Works thereof, You may choose to offer,
175
+ and charge a fee for, acceptance of support, warranty, indemnity,
176
+ or other liability obligations and/or rights consistent with this
177
+ License. However, in accepting such obligations, You may act only
178
+ on Your own behalf and on Your sole responsibility, not on behalf
179
+ of any other Contributor, and only if You agree to indemnify,
180
+ defend, and hold each Contributor harmless for any liability
181
+ incurred by, or claims asserted against, such Contributor by reason
182
+ of your accepting any such warranty or additional liability.
183
+
184
+ END OF TERMS AND CONDITIONS
185
+
186
+ ---
187
+
188
+ MIT License
189
+
190
+ Copyright (c) 2024-2025 Model Context Protocol a Series of LF Projects, LLC.
191
+
192
+ Permission is hereby granted, free of charge, to any person obtaining a copy
193
+ of this software and associated documentation files (the "Software"), to deal
194
+ in the Software without restriction, including without limitation the rights
195
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
196
+ copies of the Software, and to permit persons to whom the Software is
197
+ furnished to do so, subject to the following conditions:
198
+
199
+ The above copyright notice and this permission notice shall be included in all
200
+ copies or substantial portions of the Software.
201
+
202
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
203
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
204
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
205
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
206
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
207
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
208
+ SOFTWARE.
209
+
210
+ ---
211
+
212
+ Creative Commons Attribution 4.0 International (CC-BY-4.0)
213
+
214
+ Documentation in this project (excluding specifications) is licensed under
215
+ CC-BY-4.0. See https://creativecommons.org/licenses/by/4.0/legalcode for
216
+ the full license text.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Colin McDonnell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
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.1",
4
+ "version": "4.0.2-canary.3",
5
5
  "description": "Prebuilt CLI, development server, and build pipeline for mcp-use",
6
6
  "author": "mcp-use, Inc.",
7
7
  "license": "MIT",
@@ -57,16 +57,28 @@
57
57
  }
58
58
  },
59
59
  "devDependencies": {
60
+ "@modelcontextprotocol/client": "2.0.0",
60
61
  "@modelcontextprotocol/server": "2.0.0",
62
+ "@types/node": "^22.20.0",
63
+ "@types/react": "^19.2.17",
64
+ "@types/react-dom": "^19.2.3",
65
+ "react": "^19.2.7",
66
+ "react-dom": "^19.2.7",
61
67
  "rimraf": "^6.1.3",
62
68
  "tsup": "^8.5.1",
63
- "typescript": "^5.9.3"
69
+ "typescript": "^5.9.3",
70
+ "vitest": "^4.1.9",
71
+ "zod": "^4.4.3",
72
+ "@mcp-use/client": "2.0.2-canary.2",
73
+ "@mcp-use/tunnel": "0.2.0-canary.0"
64
74
  },
65
75
  "publishConfig": {
66
76
  "access": "public"
67
77
  },
68
78
  "scripts": {
69
- "build": "rimraf dist && tsup --config tsup.config.ts && node scripts/verify-package.mjs",
70
- "test": "node --test tests/proxy.test.mjs"
79
+ "build": "rimraf dist && tsup --config tsup.config.ts && node scripts/copy-third-party-licenses.mjs && node scripts/verify-package.mjs",
80
+ "test": "node --test tests/proxy.test.mjs && vitest run",
81
+ "test:run": "npm run typecheck && npm test",
82
+ "typecheck": "tsc -p tsconfig.test.json"
71
83
  }
72
84
  }
@@ -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,x=1024*1024,O=100,j=25e3,W=5,G=1,V=2,L=3,Z=4,ee=5,te=6,T=36;function K(){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>x;)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",K()),{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)}`,K()),{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>x){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{K as a,fe as b};
@@ -1,4 +0,0 @@
1
- import{a as f,b as l,d as m}from"./chunk-7G4TXPP4.js";import{existsSync as V}from"fs";import{join as _}from"path";import{fileURLToPath as I}from"url";var h=["vite.config.ts","vite.config.js","vite.config.mts","vite.config.cjs"];function C(t){for(let e of h){let r=_(t,e);if(V(r))return r}return!1}function O(){return I(import.meta.resolve("tailwindcss/index.css"))}import{join as s}from"path";var x=".mcp-use",E="manifest.json";function k(t){let e=s(t,x),r=s(e,"build");return{projectRoot:t,workspace:e,build:r,generated:s(e,"generated"),cache:s(e,"cache"),state:s(e,"state"),cloud:s(e,"cloud"),buildManifest:s(r,E),tunnel:s(e,"state","tunnel.json")}}import{existsSync as g,readdirSync as D}from"fs";import{isAbsolute as R,join as P,resolve as y}from"path";import S from"@vitejs/plugin-react";var T="views",a="virtual:mcp-use/views/",c=`\0${a}`;function d(t,e){let r=e??T;return R(r)?r:y(t,r)}function G(t,e){let r=d(t,e);if(!g(r))return[];let n=[];for(let i of D(r,{withFileTypes:!0})){if(!i.isDirectory())continue;let o=P(r,i.name,"view.tsx");g(o)&&n.push({name:i.name,entryPath:o})}return n.sort((i,o)=>i.name.localeCompare(o.name)),n}function A(t){return`${a}${t}`}function M(t){return`/@id/__x00__${a}${t}`}function K(t,e,r){let n=d(e,r);return t===n||t.startsWith(`${n}/`)}function Z(t){let e={};for(let r of t)e[r.name]={kind:"external",entry:M(r.name),css:[],scripts:["/@vite/client"]};return e}async function q(t,e,r){let{createServer:n}=await import("vite");return n({root:t,configFile:r,envDir:!1,logLevel:"warn",cacheDir:e,resolve:{tsconfigPaths:!0,alias:f(t)},oxc:{jsx:{runtime:"automatic"}},plugins:[m(t),S()],server:{middlewareMode:!0,hmr:!1,ws:!1},ssr:{...l(t)}})}var u="virtual:mcp-use/tailwind.css",v=`\0${u}`,p="virtual:mcp-use/csp-runtime",w=`\0${p}`,b=["react","react-dom"],U={exclude:["mcp-use/react"],include:["react","react-dom","react-dom/client"]};function Y(t){return{name:"mcp-use-views",config(){return{resolve:{dedupe:b},optimizeDeps:U}},applyToEnvironment(e){return e.name==="client"},resolveId(e){if(e===p)return w;if(e===u)return v;if(e.startsWith(a))return`\0${e}`},load(e){if(e===w)return["globalThis.__zod_globalConfig ??= {};","globalThis.__zod_globalConfig.jitless = true;",""].join(`
2
- `);if(e===v)return['@import "tailwindcss";',"@custom-variant dark (&:where(.dark, .dark *, [data-theme=dark], [data-theme=dark] *));"].join(`
3
- `);if(!e.startsWith(c))return;let r=e.slice(c.length),n=t.getViews().find(o=>o.name===r);if(n===void 0)return;let i=[];return i.push(`import ${JSON.stringify(p)};`),t.dev?.reactRefresh===!0&&i.push('import "@vitejs/plugin-react/preamble";'),i.push(`import ${JSON.stringify(u)};`),i.push('import { bootstrapView } from "mcp-use/react";',`import * as viewModule from ${JSON.stringify(n.entryPath)};`,"bootstrapView(viewModule);"),t.dev!==void 0&&i.push("if (import.meta.hot) {"," import.meta.hot.accept();","}"),i.push(""),i.join(`
4
- `)}}}export{C as a,O as b,k as c,d,G as e,A as f,K as g,Z as h,q as i,b as j,U as k,Y as l};
@@ -1 +0,0 @@
1
- var w=new WeakSet,b=new WeakMap;function p(e,d){if(e.body===null)return!1;if(w.has(e))return!0;let r=d===void 0?void 0:b.get(d);return r!==void 0&&r.body!==null&&r.body===e.body}function H(e,d){return async(r,o,f)=>{typeof f=="function"&&(f=void 0);let c=!1,s=new AbortController;o.on("close",()=>{c||s.abort()}),o.destroyed===!0&&s.abort();let u,n;try{u=await m(r,f,{signal:s.signal}),n=await e.fetch(u,{...r.auth!==void 0&&{authInfo:r.auth},...f!==void 0&&{parsedBody:f}})}catch(t){try{d?.onerror?.(t instanceof Error?t:new Error(String(t)))}catch{}n=A(k(f))}let i={};for(let[t,l]of n.headers)i[t]=l;if(o.writeHead(n.status,i),n.body===null){c=!0,o.end();return}if(p(n,u)){try{let t=new Uint8Array(await n.arrayBuffer());c=!0,o.end(t)}catch{c=!0,o.end()}return}let a,h=()=>{a?.(),a=void 0},R=()=>new Promise(t=>{a=t});o.on("drain",h);let y=new Promise(t=>{s.signal.addEventListener("abort",()=>t(),{once:!0})});try{for await(let t of n.body){if(s.signal.aborted)break;let l=t instanceof Uint8Array?t:new Uint8Array(t);o.write(l)===!1&&await Promise.race([R(),y])}}catch{}c=!0,o.end()}}async function m(e,d,r){let o=(e.method??"GET").toUpperCase(),c=`http://${g(e.headers.host)??g(e.headers[":authority"])??"localhost"}${e.url??"/"}`,s=new Headers;for(let[n,i]of Object.entries(e.headers))if(!(i===void 0||n.startsWith(":")))if(Array.isArray(i))for(let a of i)s.append(n,a);else s.set(n,i);let u;if(o!=="GET"&&o!=="HEAD")if(d===void 0){let n=new TextDecoder,i="";for await(let a of e)i+=typeof a=="string"?a:n.decode(a,{stream:!0});i+=n.decode(),i.length>0&&(u=i)}else{let n=JSON.stringify(d);s.delete("content-encoding"),s.delete("transfer-encoding"),n===void 0?s.delete("content-length"):(u=n,s.set("content-length",String(new TextEncoder().encode(n).byteLength)))}return new Request(c,{method:o,headers:s,...r?.signal!==void 0&&{signal:r.signal},...u!==void 0&&{body:u}})}function g(e){return Array.isArray(e)?e[0]:e}function k(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let{method:d,id:r}=e;return typeof d!="string"?null:typeof r=="string"||typeof r=="number"?r:null}function A(e){return Response.json({jsonrpc:"2.0",error:{code:-32603,message:"Internal server error"},id:e},{status:500})}export{H as toNodeHandler,m as toWebRequest};
@@ -1,4 +0,0 @@
1
- import{a as E}from"./chunk-N7BU45K6.js";import{c as g,d as v}from"./chunk-STQ3SGCH.js";import{c as I}from"./chunk-7G4TXPP4.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
- 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
- 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("./tunnel-FOJUZGIJ.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};