@mcp-use/cli 4.0.0-beta.7 → 4.0.0-beta.8
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 -38
- package/dist/chunk-YVHLRRIT.js +38 -0
- package/dist/commands/dev.js +2 -2
- package/dist/commands/start.js +1 -4
- package/dist/index.js +1 -0
- package/dist/start-CGEGBZOH.js +4 -0
- package/package.json +2 -2
- package/types/index.d.ts +18 -1
package/dist/bin.js
CHANGED
|
@@ -1,39 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as
|
|
3
|
-
|
|
4
|
-
Usage: mcp-use <command> [options]
|
|
5
|
-
|
|
6
|
-
Commands:
|
|
7
|
-
dev Start the dev server
|
|
8
|
-
build Build the server into .mcp-use/build
|
|
9
|
-
typecheck Refresh MCP types and run the project's TypeScript compiler
|
|
10
|
-
start Serve the production build from .mcp-use/build
|
|
11
|
-
login Authenticate the cloud CLI
|
|
12
|
-
logout Delete local cloud credentials
|
|
13
|
-
whoami Show the authenticated cloud identity
|
|
14
|
-
org Manage the active organization
|
|
15
|
-
servers Manage cloud servers and environment variables
|
|
16
|
-
deployments Manage cloud deployments and logs
|
|
17
|
-
deploy Deploy the current GitHub project
|
|
18
|
-
client Connect to and invoke MCP servers
|
|
19
|
-
skills Install maintained coding-agent skills
|
|
20
|
-
screenshot Capture an MCP Apps view
|
|
21
|
-
|
|
22
|
-
Options:
|
|
23
|
-
-p, --port <n> Port to serve on (dev/start; default: $PORT or 3000)
|
|
24
|
-
--host <host> Host to bind (dev/start; default: $HOST or 127.0.0.1)
|
|
25
|
-
--entry <path> Server entry module (dev/build/typecheck only)
|
|
26
|
-
--path <directory> Project root (default: current directory)
|
|
27
|
-
--mcp-dir <dir> Directory containing the MCP entry and views/
|
|
28
|
-
--views-dir <dir> Views directory (default: views/ or <mcp-dir>/views/)
|
|
29
|
-
--source-maps Emit source maps in build output (build only)
|
|
30
|
-
--inline Embed view JS and CSS in MCP resources (build only)
|
|
31
|
-
-- <tsc options> Forward remaining options to TypeScript (typecheck only)
|
|
32
|
-
--with-inspector Mount Inspector on the production listener (start only)
|
|
33
|
-
--tunnel Expose the server through a public tunnel (dev/start only)
|
|
34
|
-
--no-open Do not auto-open the inspector in a browser (dev only)
|
|
35
|
-
--no-inspector Start dev without loading the optional Inspector
|
|
36
|
-
-h, --help Show this help
|
|
37
|
-
-v, --version Print the version`;async function l(n){if(n.length===1&&["--version","-v"].includes(n[0]??""))return console.log(u()),0;if(n.some(t=>t==="--help"||t==="-h")){let t=n[0];if(t===void 0||t==="--help"||t==="-h")return console.log(i),0}let e=n[0];if(e==="login"||e==="logout"||e==="whoami"){let{runIdentity:t}=await import("./commands/identity.js");return t(e,n.slice(1))}if(e==="org"){let{runOrganizations:t}=await import("./commands/organizations.js");return t(n.slice(1))}if(e==="servers"){let{runServers:t}=await import("./commands/servers.js");return t(n.slice(1))}if(e==="deployments"){let{runDeployments:t}=await import("./commands/deployments.js");return t(n.slice(1))}if(e==="deploy"){let{runDeploy:t}=await import("./commands/deploy.js");return t(n.slice(1))}if(e==="client"){let{runClient:t}=await import("./commands/client.js");return t(n.slice(1))}if(e==="skills"){let{runSkills:t}=await import("./commands/skills.js");return t(n.slice(1))}if(e==="screenshot"){let{runScreenshot:t}=await import("./commands/screenshot.js");return t(n.slice(1))}let r;try{r=c(n)}catch(t){return console.error(t instanceof Error?t.message:String(t)),2}if(r.version)return console.log(u()),0;if(r.help)return console.log(i),0;switch(r.command){case"start":return d(r);case"dev":case"build":return m(r.command,r);case"typecheck":return p(r);case void 0:return console.error(i),2;default:return console.error(`Unknown command: ${r.command}
|
|
38
|
-
|
|
39
|
-
${i}`),2}}async function p(n){try{let{runTypecheck:e}=await import("./commands/typecheck.js");return await e({cwd:s(process.cwd(),n.path??"."),...n.entry!==void 0&&{entry:n.entry},...n.mcpDir!==void 0&&{mcpDir:n.mcpDir},...n.passthrough.length>0&&{tscArgs:n.passthrough}})}catch(e){return console.error(e instanceof Error?e.message:String(e)),1}}async function d(n){let e;try{let{runStart:o}=await import("./commands/start.js");e=await o({cwd:s(process.cwd(),n.path??"."),port:n.port,host:n.host,...n.inspector===!0&&{withInspector:!0},tunnel:n.tunnel})}catch(o){return console.error(o instanceof Error?o.message:String(o)),1}console.log(`mcp-use server running at ${e.url}`),e.tunnelUrl!==void 0&&console.log(`mcp-use public MCP URL: ${e.tunnelUrl}`);let r=!1,t=()=>{r||(r=!0,e.close().then(()=>process.exit(0),o=>{console.error(o instanceof Error?o.message:String(o)),process.exit(1)}))};return process.once("SIGINT",t),process.once("SIGTERM",t),0}async function m(n,e){let r={cwd:s(process.cwd(),e.path??"."),...e.entry!==void 0&&{entry:e.entry},...e.mcpDir!==void 0&&{mcpDir:e.mcpDir},...e.viewsDir!==void 0&&{viewsDir:e.viewsDir},...e.port!==void 0&&{port:e.port},...e.host!==void 0&&{host:e.host},...e.tunnel&&{tunnel:!0},...!e.open&&{open:!1},...e.inspector===!1&&{inspector:!1},...e.sourceMaps&&{sourceMaps:!0},...e.inline&&{inline:!0}};try{if(n==="dev"){let{runDev:t}=await import("./commands/dev.js");await t(r)}else{let{runBuild:t}=await import("./commands/build.js");await t(r)}return 0}catch(t){return console.error(t instanceof Error?t.message:String(t)),1}}function u(){return"2.0.0-beta.32"}l(process.argv.slice(2)).then(n=>{process.exitCode=n},n=>{console.error(n instanceof Error?n.message:String(n)),process.exitCode=1});
|
|
2
|
+
import{a as n}from"./chunk-YVHLRRIT.js";import"./chunk-USIKTT3N.js";n(process.argv.slice(2),{frameworkVersion:"4.0.0-beta.7"}).then(e=>{process.exitCode=e},e=>{console.error(e instanceof Error?e.message:String(e)),process.exitCode=1});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import{a as c}from"./chunk-USIKTT3N.js";import{resolve as s}from"path";var i=`mcp-use \u2014 run MCP servers built with mcp-use
|
|
2
|
+
|
|
3
|
+
Usage: mcp-use <command> [options]
|
|
4
|
+
|
|
5
|
+
Commands:
|
|
6
|
+
dev Start the dev server
|
|
7
|
+
build Build the server into .mcp-use/build
|
|
8
|
+
typecheck Refresh MCP types and run the project's TypeScript compiler
|
|
9
|
+
start Serve the production build from .mcp-use/build
|
|
10
|
+
login Authenticate the cloud CLI
|
|
11
|
+
logout Delete local cloud credentials
|
|
12
|
+
whoami Show the authenticated cloud identity
|
|
13
|
+
org Manage the active organization
|
|
14
|
+
servers Manage cloud servers and environment variables
|
|
15
|
+
deployments Manage cloud deployments and logs
|
|
16
|
+
deploy Deploy the current GitHub project
|
|
17
|
+
client Connect to and invoke MCP servers
|
|
18
|
+
skills Install maintained coding-agent skills
|
|
19
|
+
screenshot Capture an MCP Apps view
|
|
20
|
+
|
|
21
|
+
Options:
|
|
22
|
+
-p, --port <n> Port to serve on (dev/start; default: $PORT or 3000)
|
|
23
|
+
--host <host> Host to bind (dev/start; default: $HOST or 127.0.0.1)
|
|
24
|
+
--entry <path> Server entry module (dev/build/typecheck only)
|
|
25
|
+
--path <directory> Project root (default: current directory)
|
|
26
|
+
--mcp-dir <dir> Directory containing the MCP entry and views/
|
|
27
|
+
--views-dir <dir> Views directory (default: views/ or <mcp-dir>/views/)
|
|
28
|
+
--source-maps Emit source maps in build output (build only)
|
|
29
|
+
--inline Embed view JS and CSS in MCP resources (build only)
|
|
30
|
+
-- <tsc options> Forward remaining options to TypeScript (typecheck only)
|
|
31
|
+
--with-inspector Mount Inspector on the production listener (start only)
|
|
32
|
+
--tunnel Expose the server through a public tunnel (dev/start only)
|
|
33
|
+
--no-open Do not auto-open the inspector in a browser (dev only)
|
|
34
|
+
--no-inspector Start dev without loading the optional Inspector
|
|
35
|
+
-h, --help Show this help
|
|
36
|
+
-v, --version Print the version`;async function l(t,n={frameworkVersion:"unknown"}){if(t.length===1&&["--version","-v"].includes(t[0]??""))return console.log(n.frameworkVersion),0;if(t.some(e=>e==="--help"||e==="-h")){let e=t[0];if(e===void 0||e==="--help"||e==="-h")return console.log(i),0}let o=t[0];if(o==="login"||o==="logout"||o==="whoami"){let{runIdentity:e}=await import("./commands/identity.js");return e(o,t.slice(1))}if(o==="org"){let{runOrganizations:e}=await import("./commands/organizations.js");return e(t.slice(1))}if(o==="servers"){let{runServers:e}=await import("./commands/servers.js");return e(t.slice(1))}if(o==="deployments"){let{runDeployments:e}=await import("./commands/deployments.js");return e(t.slice(1))}if(o==="deploy"){let{runDeploy:e}=await import("./commands/deploy.js");return e(t.slice(1))}if(o==="client"){let{runClient:e}=await import("./commands/client.js");return e(t.slice(1))}if(o==="skills"){let{runSkills:e}=await import("./commands/skills.js");return e(t.slice(1))}if(o==="screenshot"){let{runScreenshot:e}=await import("./commands/screenshot.js");return e(t.slice(1))}let r;try{r=c(t)}catch(e){return console.error(e instanceof Error?e.message:String(e)),2}if(r.version)return console.log(n.frameworkVersion),0;if(r.help)return console.log(i),0;switch(r.command){case"start":return a(r);case"dev":case"build":return p(r.command,r);case"typecheck":return u(r);case void 0:return console.error(i),2;default:return console.error(`Unknown command: ${r.command}
|
|
37
|
+
|
|
38
|
+
${i}`),2}}async function u(t){try{let{runTypecheck:n}=await import("./commands/typecheck.js");return await n({cwd:s(process.cwd(),t.path??"."),...t.entry!==void 0&&{entry:t.entry},...t.mcpDir!==void 0&&{mcpDir:t.mcpDir},...t.passthrough.length>0&&{tscArgs:t.passthrough}})}catch(n){return console.error(n instanceof Error?n.message:String(n)),1}}async function a(t){let n;try{let{runStart:e}=await import("./commands/start.js");n=await e({cwd:s(process.cwd(),t.path??"."),port:t.port,host:t.host,...t.inspector===!0&&{withInspector:!0},tunnel:t.tunnel})}catch(e){return console.error(e instanceof Error?e.message:String(e)),1}console.log(`mcp-use server running at ${n.url}`),n.tunnelUrl!==void 0&&console.log(`mcp-use public MCP URL: ${n.tunnelUrl}`);let o=!1,r=()=>{o||(o=!0,n.close().then(()=>process.exit(0),e=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)}))};return process.once("SIGINT",r),process.once("SIGTERM",r),0}async function p(t,n){let o={cwd:s(process.cwd(),n.path??"."),...n.entry!==void 0&&{entry:n.entry},...n.mcpDir!==void 0&&{mcpDir:n.mcpDir},...n.viewsDir!==void 0&&{viewsDir:n.viewsDir},...n.port!==void 0&&{port:n.port},...n.host!==void 0&&{host:n.host},...n.tunnel&&{tunnel:!0},...!n.open&&{open:!1},...n.inspector===!1&&{inspector:!1},...n.sourceMaps&&{sourceMaps:!0},...n.inline&&{inline:!0}};try{if(t==="dev"){let{runDev:r}=await import("./commands/dev.js");await r(o)}else{let{runBuild:r}=await import("./commands/build.js");await r(o)}return 0}catch(r){return console.error(r instanceof Error?r.message:String(r)),1}}export{l as a};
|
package/dist/commands/dev.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as
|
|
2
|
-
`,t)}}while(
|
|
1
|
+
import{a as Y,b as Q}from"../chunk-N7BU45K6.js";import{b as te}from"../chunk-OVFUQAEG.js";import{b as z,c as K}from"../chunk-USIKTT3N.js";import{a as ne,b as re,c as oe,d as T,f as x,g as se,i as ie}from"../chunk-ALPMVGHI.js";import{b as Z,c as ee,d as A}from"../chunk-7G4TXPP4.js";import{a as L,b as X}from"../chunk-DB3E6LBX.js";import{spawn as je}from"child_process";import{createServer as ke}from"http";import{networkInterfaces as Ce}from"os";import{join as $e,resolve as Ee}from"path";import Le from"@tailwindcss/vite";import Ae from"@vitejs/plugin-react";import{createServer as Te,createServerModuleRunner as xe}from"vite";import{InMemoryServerEventBus as Ve,localhostAllowedHostnames as Fe,localhostAllowedOrigins as Be,validateHostHeader as Ne,validateOriginHeader as We}from"@modelcontextprotocol/server";import{connect as Re,createServer as be}from"net";var ae=100,Me=300,Ie=new Set(["127.0.0.1","localhost","::1"]);function Se(e,r){return new Promise(o=>{let n=be();n.unref(),n.once("error",()=>o(!1)),n.listen({port:e,host:r},()=>{n.close(()=>o(!0))})})}function ce(e,r){return new Promise(o=>{let n=Re({port:e,host:r});n.setTimeout(Me),n.once("connect",()=>{n.destroy(),o(!0)}),n.once("timeout",()=>{n.destroy(),o(!1)}),n.once("error",()=>{n.destroy(),o(!1)})})}async function _e(e){return await ce(e,"127.0.0.1")||await ce(e,"::1")}async function le(e,r){for(let o=e;o<e+ae;o++)if(await Se(o,r)&&!(Ie.has(r)&&await _e(o)))return{port:o,requested:e};throw new Error(`No free port found between ${e} and ${e+ae-1} on ${r}.`)}function de(e,r){let o=()=>{let n=e.getBasePath(),{url:c}=e.tunnel.status();return{mcpUrl:c!==null?`${c.replace(/\/+$/,"")}${n}`:null,port:e.port,fromCli:!0,tunnelUrl:c}};return async n=>{let c=e.getBasePath(),l=`${c}/inspector/api/dev/info`,d=`${c}/inspector/api/dev/start-tunnel`,u=`${c}/inspector/api/dev/stop-tunnel`,w=new URL(n.url).pathname;if(n.method==="GET"&&w===l)return Response.json(o());if(n.method==="POST"&&w===d)try{return await e.tunnel.start(e.port),Response.json({ok:!0,restarting:!1})}catch(g){let _=g instanceof Error?g.message:"Failed to start tunnel";return Response.json({error:_},{status:500})}return n.method==="POST"&&w===u?(await e.tunnel.stop(),Response.json({ok:!0})):r(n)}}import{readFileSync as He}from"fs";import{createRequire as De}from"module";import{join as Oe}from"path";import{pathToFileURL as Ue}from"url";async function fe(e){let r=Oe(e,"package.json"),o=JSON.parse(He(r,"utf8"));if([o.dependencies,o.devDependencies,o.optionalDependencies].some(l=>l!==null&&typeof l=="object"&&"@mcp-use/inspector"in l)){let l=De(r);try{let d=l.resolve("@mcp-use/inspector");return ue(await import(Ue(d).href))}catch(d){if(!pe(d))throw d}}try{return ue(await import("@mcp-use/inspector"))}catch(l){if(pe(l))return{installed:!1};throw l}}function ue(e){if(typeof e.mountInspector!="function")throw new Error("The installed @mcp-use/inspector is incompatible: its package entry does not export mountInspector(). Update the development dependency.");return{installed:!0,module:e}}function pe(e){let r=e!==null&&typeof e=="object"&&"code"in e?String(e.code):void 0;return r==="ERR_MODULE_NOT_FOUND"||r==="MODULE_NOT_FOUND"}function Ge(e){let[r,o]=process.platform==="darwin"?["open",[e]]:process.platform==="win32"?["cmd",["/c","start","",e]]:["xdg-open",[e]];try{let n=je(r,o,{stdio:"ignore",detached:!0});n.on("error",()=>{}),n.unref()}catch{}}function qe(){for(let e of Object.values(Ce()))for(let r of e??[])if(!r.internal&&r.family==="IPv4")return r.address}function Je(e){if(e!==void 0)try{return new URL(`http://${e}`).hostname.replace(/^\[|\]$/g,"")}catch{return}}function ze(e){let r=e.getHeader("Vary"),o=typeof r=="string"?r:Array.isArray(r)?r.join(", "):r!==void 0?String(r):"";o.split(",").map(n=>n.trim().toLowerCase()).includes("origin")||e.setHeader("Vary",o===""?"Origin":`${o}, Origin`)}function Ke(e,r,o){if(o.tunnelActive){r.setHeader("Access-Control-Allow-Origin","*");return}if(!o.localhostBind)return;let n=e.headers.origin;if(n==="null"){r.setHeader("Access-Control-Allow-Origin","null");return}if(typeof n!="string"||n==="")return;let c=We(n,Be());!c.ok||c.origin===void 0||(r.setHeader("Access-Control-Allow-Origin",c.origin),ze(r))}function Xe(e){let r=e.default;if(r===null||typeof r!="object")throw new Error("The server entry must default-export the MCPServer instance (`export default server`) and never call listen() itself \u2014 `mcp-use dev` owns the socket.");let o=r;if(typeof o.fetch!="function")throw new Error("The entry's default export has no fetch() \u2014 it must be the MCPServer instance (`export default server`).");return o}async function Ye(e){process.env.MCP_USE_DEV_CLI="1";let r=oe(e.cwd),o=new Ve(t=>{console.error("[mcp-use] notification delivery failed:",t)});ee(e.cwd,"development");let n=K(e.host),c=["127.0.0.1","localhost","::1"].includes(n),l=n==="0.0.0.0"||n==="::",d=ke(),{port:u,requested:w}=await le(z(e.port),n);u!==w&&console.log(`[mcp-use] port ${w} is taken, using ${u}`),process.env.PORT=String(u);let g=process.env.MCP_URL===void 0&&(n==="127.0.0.1"||n==="localhost"||n==="::1")?`http://localhost:${u}`:void 0,_=e.mcpDir===void 0?e.cwd:Ee(e.cwd,e.mcpDir),V=e.entry===void 0?L(_):L(e.cwd,e.entry),H=await X(e.cwd,V);(H==="created"||H==="updated")&&console.log(`[mcp-use] ${H} mcp-env.d.ts`);let I=e.viewsDir??(e.mcpDir===void 0?void 0:$e(e.mcpDir,"views")),p=T(e.cwd,I),P=p.length>0,me=ne(e.cwd),D=["127.0.0.1","localhost","0.0.0.0","::","::1"].includes(n)?"localhost":n,y=`http://${D.includes(":")?`[${D}]`:D}:${u}`,f=await Te({root:e.cwd,configFile:P?me:!1,envDir:!1,logLevel:"warn",cacheDir:r.cache,resolve:{tsconfigPaths:!0,alias:{tailwindcss:re()}},plugins:P?[A(e.cwd),Le(),ie({getViews:()=>p,dev:{reactRefresh:!0}}),Ae()]:[A(e.cwd)],server:{middlewareMode:!0,...P&&{origin:y},cors:!1,hmr:P?{server:d}:!1},ssr:{...Z(e.cwd)}}),O=f.environments.ssr,R=xe(O,{hmr:!1,sourcemapInterceptor:"node"}),F=async()=>{let t=async()=>{let i=await R.import(V),a=Xe(i);if(p.length>0){let v=se(p);if(typeof a.__primeViews!="function")throw new Error("Loaded MCPServer instance does not support __primeViews.");a.__primeViews(v,{dev:!0,projectRoot:e.cwd})}return a};if(g===void 0)return t();let s=process.env.MCP_URL;try{return process.env.MCP_URL=g,await t()}finally{s===void 0?delete process.env.MCP_URL:process.env.MCP_URL=s}},U,m;try{let t=await F();t.__setEventBus(o),t.__mount(),U=async s=>t.fetch(s),m=t.basePath??"/mcp"}catch(t){throw await R.close(),await f.close(),t}let j,b,B,N=t=>{if(j===void 0||B===t)return;let s=j.mountInspector({basePath:t,autoConnectUrl:`${y}${t}`,oauthProxyAllowLoopback:c||l,devMode:!0,manufactChatUrl:process.env.MANUFACT_CHAT_URL});if(typeof s!="function")throw new Error("The installed @mcp-use/inspector is incompatible: mountInspector() did not return a Fetch handler.");b=s,B=t};try{if(e.inspector!==!1){let t=await fe(e.cwd);t.installed&&(j=t.module,N(m))}}catch(t){throw await R.close(),await f.close(),t}let k=!1,C=!1,W=()=>{if(k){C=!0;return}k=!0,(async()=>{do{C=!1;try{R.evaluatedModules.clear();let t=await F();t.__setEventBus(o),t.__mount();let s=async a=>t.fetch(a),i=t.basePath??"/mcp";N(i),U=s,m=i,o.publish({kind:"tools_list_changed"}),o.publish({kind:"prompts_list_changed"}),o.publish({kind:"resources_list_changed"}),console.log("[mcp-use] reloaded server entry")}catch(t){console.error(`[mcp-use] reload failed \u2014 keeping the previous server:
|
|
2
|
+
`,t)}}while(C);k=!1})()},$=t=>{if(x(t,e.cwd,I))return;let s=O.moduleGraph.getModulesByFile(t);if(!(s===void 0||s.size===0)){for(let i of s)O.moduleGraph.invalidateModule(i);W()}},ve=t=>{if(!x(t,e.cwd,I))return;let s=p;p=T(e.cwd,I),(s.length!==p.length||s.some((a,v)=>a.name!==p[v]?.name||a.entryPath!==p[v]?.entryPath))&&W()},S=t=>{ve(t),$(t)};f.watcher.on("change",$),f.watcher.on("add",S),f.watcher.on("unlink",S);let h=te(r.tunnel);d.prependListener("upgrade",t=>{let s=h.status().url;if(s===null)return;let i=new URL(s).hostname;t.headers.host?.split(":")[0]===i&&(t.headers.host=`localhost:${u}`)});let he=(t,s)=>{let i=h.status().url,a=i!==null?new URL(i).hostname:null,v=a!==null?[a]:[],M=Ne(t.headers.host,[...Fe(),...v]);return M.ok?!1:(s.writeHead(403,{"content-type":"application/json"}),s.end(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:M.message},id:null})),!0)},G=async()=>{f.watcher.off("change",$),f.watcher.off("add",S),f.watcher.off("unlink",S),await h.stop(),await new Promise(t=>d.close(()=>t())),await R.close(),await f.close()},we=de({getBasePath:()=>m,port:u,tunnel:h},t=>b!==void 0&&Y(t,m)?b(t):U(t)),{toNodeHandler:ge}=await import("../node-bridge-JJIA6K5P.js"),q=ge({fetch:we}),Pe=(t,s)=>{if(c&&he(t,s))return;let i=t.url??"/",a=new URL(i,"http://127.0.0.1").pathname,v=h.status().url,M=v===null?null:new URL(v).hostname,E=Je(t.headers.host);if((M!==null&&E===M||l&&E!==void 0&&!["localhost","127.0.0.1","::1"].includes(E))&&Q(a,m)){s.writeHead(404,{"content-type":"text/plain; charset=utf-8"}),s.end("Not Found");return}let J=P&&p.length>0,ye=t.method==="GET"&&(a.startsWith("/@")||a.startsWith("/node_modules/")||a.startsWith("/.mcp-use/")||J&&a.startsWith("/views/"));J&&ye?(Ke(t,s,{tunnelActive:h.status().url!==null,localhostBind:c}),f.middlewares(t,s,()=>{q(t,s)})):q(t,s)};if(d.on("request",Pe),await new Promise((t,s)=>{d.once("error",s),d.listen(u,n,()=>t())}),console.log("[mcp-use] dev server ready"),p.length>0&&console.log(` \u279C Views: ${p.map(t=>t.name).join(", ")}`),console.log(` \u279C MCP endpoint: ${y}${m}`),b!==void 0?console.log(` \u279C Inspector: ${y}${m}/inspector`):e.inspector!==!1&&console.warn("[mcp-use] Built-in Inspector is unavailable; reinstall mcp-use to restore visual testing."),n==="0.0.0.0"||n==="::"){let t=qe();t!==void 0&&console.log(` \u279C Network: http://${t}:${u}${m}`)}if(c||console.warn(`[mcp-use] --host ${n} serves beyond this machine without Host validation or authentication \u2014 anyone with network access can call the MCP endpoint and dev routes.`),e.tunnel===!0)try{let{url:t}=await h.start(u);console.log(` \u279C Tunnel: ${t}${m}`)}catch(t){throw await G(),t}b!==void 0&&e.open!==!1&&process.stdout.isTTY===!0&&Ge(`${y}${m}/inspector`),await new Promise(t=>{let s=!1,i=()=>{s||(s=!0,process.off("SIGINT",i),process.off("SIGTERM",i),(async()=>(await G(),t()))())};process.on("SIGINT",i),process.on("SIGTERM",i),e.signal!==void 0&&(e.signal.aborted?i():e.signal.addEventListener("abort",i,{once:!0}))})}export{Ye as runDev};
|
package/dist/commands/start.js
CHANGED
|
@@ -1,4 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Run \`mcp-use build\` first, then \`mcp-use start\`.`)}let i;try{let n=JSON.parse(c);if(typeof n.entryPoint!="string"||n.entryPoint==="")throw new Error("missing entryPoint");i=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",E(t.cwd,"production");let a=d(o,i),u=await import(R(a).href);if(!("default"in u)||u.default===void 0)throw new Error(`The built entry (${a}) 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(!D(e))throw new Error(`The default export of ${a} is not an MCPServer: it has no listen() method. Export the MCPServer instance as the default export.`);let k=typeof e.port=="number"?e.port:void 0,M=typeof e.host=="string"?e.host:void 0,h=g(t.port,process.env,k),y=S(t.host,process.env,M),l=await(t.withInspector===!0?O(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-AQ2WE7EL.js");p=n(d(t.cwd,I,"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 O(t,o,s){let{mountInspector:c}=await _(),i=typeof t.basePath=="string"?t.basePath:"/mcp",a=c({basePath:i,devMode:!1,oauthProxyAllowLoopback:!1});return t.app.use("*",async(f,u)=>{if(v(f.req.raw,i))return a(f.req.raw);await u()}),t.listen(o,{host:s})}async function _(){let t;try{t=await import("@mcp-use/inspector")}catch(o){throw F(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 D(t){return typeof t=="object"&&t!==null&&typeof t.listen=="function"}function F(t){return t!==null&&typeof t=="object"&&"code"in t&&(t.code==="ERR_MODULE_NOT_FOUND"||t.code==="MODULE_NOT_FOUND")}export{N as runStart};
|
|
1
|
+
async function e(t){return(await import("../start-CGEGBZOH.js")).runStart(t)}export{e as runStart};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-YVHLRRIT.js";import"./chunk-USIKTT3N.js";export{a as main};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as E}from"./chunk-N7BU45K6.js";import{b as g,c as v}from"./chunk-USIKTT3N.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-AQ2WE7EL.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.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.8",
|
|
5
5
|
"description": "Prebuilt CLI, development server, and build pipeline for mcp-use",
|
|
6
6
|
"author": "mcp-use, Inc.",
|
|
7
7
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
27
27
|
"types": "./types/index.d.ts",
|
|
28
|
-
"import": "./dist/
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
package/types/index.d.ts
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
/** Options supplied by the public framework binary. @internal */
|
|
2
|
+
export interface CliMainOptions {
|
|
3
|
+
/** Version reported by the binary that owns the CLI invocation. */
|
|
4
|
+
frameworkVersion: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Run the prebuilt mcp-use command dispatcher without process side effects.
|
|
9
|
+
*
|
|
10
|
+
* @param argv - Command-line arguments excluding the executable and script.
|
|
11
|
+
* @param options - Invocation metadata owned by the calling package.
|
|
12
|
+
* @returns The process exit code.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare function main(
|
|
16
|
+
argv: readonly string[],
|
|
17
|
+
options: CliMainOptions
|
|
18
|
+
): Promise<number>;
|