@mcp-use/cli 4.0.0-beta.8 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- import{mkdir as U,readFile as L,writeFile as O}from"fs/promises";import{spawn as R}from"child_process";import{dirname as z}from"path";var D="https://local.mcp-use.run";function W(){return process.env.MCP_USE_TUNNEL_API??D}var y=1e3,q=3e4;function H(h){let i,o=null,u,l,d=!1,c,m=y,M=e=>new Promise(n=>{setTimeout(n,e)}),$=()=>{i!==void 0&&"markShutdown"in i&&typeof i.markShutdown=="function"&&i.markShutdown()},b=async e=>{try{await fetch(`${W()}/api/tunnels/${e}`,{method:"DELETE",signal:AbortSignal.timeout(2e3)})}catch{}},P=async()=>{try{let e=await L(h,"utf8"),n=JSON.parse(e);return typeof n.subdomain=="string"?n.subdomain:void 0}catch{return}},_=async e=>{try{await U(z(h),{recursive:!0}),await O(h,JSON.stringify({subdomain:e},null,2),"utf8")}catch(n){console.warn(`[mcp-use] failed to save tunnel subdomain: ${n instanceof Error?n.message:String(n)}`)}},E=()=>{},w=(e,n)=>new Promise((t,f)=>{console.log(`[mcp-use] starting tunnel for port ${e}\u2026`);let k=process.env.npm_config_user_agent??"",[F,x]=k.startsWith("pnpm/")?["pnpm",["--silent","dlx","@mcp-use/tunnel",String(e)]]:k.startsWith("bun/")?["bunx",["@mcp-use/tunnel",String(e)]]:["npx",["--yes","--prefer-offline","@mcp-use/tunnel",String(e)]];n!==void 0&&x.push("--subdomain",n);let a=R(F,x,{stdio:["ignore","pipe","pipe"],shell:process.platform==="win32"}),p=!1,S=!1,I=()=>{S=!0};a.markShutdown=I,a.stdout.on("data",r=>{let s=r.toString(),N=s.includes("Shutting down")||s.includes("\u{1F6D1}"),C=s.includes("\u2716")||s.includes("Error:");!S&&!N&&!C&&process.stdout.write(s);let v=s.match(/https?:\/\/([a-z0-9-]+\.[a-z0-9.-]+)/i);if(v!==null&&!p){let B=v[0],A=v[1]??"",g=A.match(/^([a-z0-9-]+)\./i)?.[1]??A.split(".")[0]??"";/^[a-z0-9-]+$/i.test(g)||(console.warn(`[mcp-use] warning: extracted subdomain "${g}" does not match expected format`),g=""),p=!0,clearTimeout(T),t({url:B,subdomain:g,process:a})}}),a.stderr.on("data",r=>{let s=r.toString();!S&&!s.includes("INFO")&&!s.includes("bore_cli")&&!s.includes("Shutting down")&&!/npm warn Unknown (?:env|project|user|builtin) config/.test(s)&&process.stderr.write(r)}),a.on("error",r=>{p||(clearTimeout(T),f(new Error(`Failed to start tunnel: ${r.message}`)))}),a.on("exit",r=>{r!==0&&r!==null&&!p&&(clearTimeout(T),f(new Error(`Tunnel process exited with code ${r}`))),i===a&&(i=void 0,o=null,d?u=void 0:E())});let T=setTimeout(()=>{p||(a.kill(),f(new Error("Tunnel setup timed out")))},3e4)});return E=()=>{d||l===void 0||o!==null||c===void 0&&(c=(async()=>{for(;!d&&l!==void 0&&o===null;){console.log("[mcp-use] tunnel disconnected, restarting\u2026");let e=u??await P();try{e!==void 0&&await b(e);let n;try{n=await w(l,e)}catch(t){if(e!==void 0)console.log(`[mcp-use] subdomain "${e}" unavailable, requesting a new one\u2026`),n=await w(l,void 0);else throw t}i=n.process,o=n.url,u=n.subdomain,await _(n.subdomain),m=y;return}catch(n){console.warn(`[mcp-use] tunnel restart failed: ${n instanceof Error?n.message:String(n)}`),await M(m),m=Math.min(m*2,q)}}})().finally(()=>{c=void 0}))},{status(){return{url:o}},async start(e){if(d=!1,l=e,o!==null)return{url:o,subdomain:u??""};let n=await P();n!==void 0&&(console.log(`[mcp-use] found existing subdomain: ${n}`),await b(n));let t;try{t=await w(e,n)}catch(f){if(n!==void 0)console.log(`[mcp-use] subdomain "${n}" unavailable, requesting a new one\u2026`),t=await w(e,void 0);else throw f}return i=t.process,o=t.url,u=t.subdomain,await _(t.subdomain),{url:t.url,subdomain:t.subdomain}},async stop(){d=!0,$(),c!==void 0&&await c,u!==void 0&&await b(u),i!==void 0&&(i.kill("SIGINT"),i=void 0),l=void 0,o=null,u=void 0,m=y}}}export{W as a,H as b};
@@ -1,38 +0,0 @@
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};
@@ -1 +0,0 @@
1
- import{b as o,i as g,j as c,k as l,l as f}from"./chunk-LHNHT6HO.js";import{join as C}from"path";var d=C(f,"config.json");function p(){return(process.env.MCP_USE_CLOUD_API_URL??"https://cloud.manufact.com/api/v1").replace(/\/+$/,"").replace(/\/api\/v1$/,"")+"/api/v1"}function z(){return p().replace(/\/api\/v1$/,"")}async function m(){return g(d,{})}async function I(i){await c(d,i)}async function O(){await l(d)}function _(i,t){let n=i.filter(e=>e.id===t||e.slug===t);if(n.length!==1)throw new o(n.length===0?"organization_not_found":"organization_ambiguous",`Organization not found: ${t}`);return n[0]}var s=class i{#n;#t;constructor(t,n){this.#n=t,this.#t=n}static async create(t){let n=await m(),e=process.env.MCP_USE_API_KEY??n.apiKey;if(e===void 0||e==="")throw new o("not_authenticated","Not logged in. Run `mcp-use login`.");return new i(e,t??n.orgId)}static withApiKey(t){return new i(t)}async request(t,n={}){let e=n.organizationId??this.#t,r=await fetch(`${p()}${t}`,{...n,headers:{Accept:"application/json","x-api-key":this.#n,...e!==void 0?{"x-profile-id":e}:{},...n.body!==void 0?{"Content-Type":"application/json"}:{},...n.headers}}),u=await r.text(),a;try{a=u===""?void 0:JSON.parse(u)}catch{a=u}if(!r.ok)throw new o(r.status===401?"not_authenticated":r.status===403?"forbidden":"cloud_api_error",h(a)??`Cloud API request failed (${r.status}).`,{status:r.status});return a}async identity(){let t=await this.request("/test-auth");return{userId:t.user_id,email:t.email,organizations:t.profiles.map(n=>({id:n.id,name:n.profile_name,slug:n.slug,role:n.role})),defaultOrganizationId:t.default_profile_id}}async setDefaultOrganization(t){await this.request(`/organizations/${t}/set-default`,{method:"POST"})}};async function P(i){let t=await m(),n=await(await s.create()).identity(),e=i!==void 0?_(n.organizations,i):n.organizations.find(r=>r.id===(t.orgId??n.defaultOrganizationId));if(e===void 0)throw new o("organization_required","No active organization. Run `mcp-use org use <id-or-slug>`.");return{api:await s.create(e.id),organizationId:e.id}}function h(i){if(typeof i=="string"&&i!=="")return i;if(!(i===null||typeof i!="object"))for(let t of["message","error","detail"]){let n=i[t];if(typeof n=="string"&&n!=="")return n}}export{z as a,m as b,I as c,O as d,_ as e,s as f,P as g};
@@ -1 +0,0 @@
1
- import{a as o,d,e as u,h as m}from"../chunk-LHNHT6HO.js";import{spawn as f}from"child_process";import{resolve as w}from"path";import{parseArgs as g}from"util";async function I(r){let i=r.includes("--json");try{if(r[0]!=="add")throw new o("Usage: mcp-use skills add [options]");let{values:s}=g({args:[...r.slice(1)],allowPositionals:!1,strict:!0,options:{path:{type:"string",short:"p",default:process.cwd()},agent:{type:"string",multiple:!0},skill:{type:"string",multiple:!0},json:{type:"boolean"}}}),e=w(s.path??process.cwd());if(!await m(e))throw new o(`Directory not found: ${e}`);let n=s.agent??["all"],l=new Set(["cursor","claude-code","codex","all"]);for(let t of n)if(!l.has(t))throw new o(`Invalid agent: ${t}`);let a=n.includes("all")?["cursor","claude-code","codex"]:[...new Set(n)],c=["--yes","skills","add","mcp-use/mcp-use","--yes",...a.flatMap(t=>["-a",t]),...(s.skill??[]).flatMap(t=>["--skill",t])],p=await h("npx",c,e);return p!==0?p:(d({installed:!0,path:e,agents:a,skills:s.skill??"maintained"},i,"Installed mcp-use skills."),0)}catch(s){return u(s instanceof TypeError?new o(s.message):s,i)}}function h(r,i,s){return new Promise((e,n)=>{let l=f(r,i,{cwd:s,stdio:"inherit",shell:process.platform==="win32"});l.once("error",n),l.once("exit",(a,c)=>{e(c==="SIGINT"?130:a??1)})})}export{I as runSkills};
@@ -1 +0,0 @@
1
- function b(e,c){return async(a,i,d)=>{typeof d=="function"&&(d=void 0);let l=!1,t=new AbortController;i.on("close",()=>{l||t.abort()}),i.destroyed===!0&&t.abort();let s;try{let n=await w(a,d,{signal:t.signal});s=await e.fetch(n,{...a.auth!==void 0&&{authInfo:a.auth},...d!==void 0&&{parsedBody:d}})}catch(n){try{c?.onerror?.(n instanceof Error?n:new Error(String(n)))}catch{}s=y(m(d))}let r={};for(let[n,f]of s.headers)r[n]=f;if(i.writeHead(s.status,r),s.body===null){l=!0,i.end();return}let o,u=()=>{o?.(),o=void 0},h=()=>new Promise(n=>{o=n});i.on("drain",u);let p=new Promise(n=>{t.signal.addEventListener("abort",()=>n(),{once:!0})});try{for await(let n of s.body){if(t.signal.aborted)break;let f=n instanceof Uint8Array?n:new Uint8Array(n);i.write(f)===!1&&await Promise.race([h(),p])}}catch{}l=!0,i.end()}}async function w(e,c,a){let i=(e.method??"GET").toUpperCase(),l=`http://${g(e.headers.host)??g(e.headers[":authority"])??"localhost"}${e.url??"/"}`,t=new Headers;for(let[r,o]of Object.entries(e.headers))if(!(o===void 0||r.startsWith(":")))if(Array.isArray(o))for(let u of o)t.append(r,u);else t.set(r,o);let s;if(i!=="GET"&&i!=="HEAD")if(c===void 0){let r=new TextDecoder,o="";for await(let u of e)o+=typeof u=="string"?u:r.decode(u,{stream:!0});o+=r.decode(),o.length>0&&(s=o)}else{let r=JSON.stringify(c);t.delete("content-encoding"),t.delete("transfer-encoding"),r===void 0?t.delete("content-length"):(s=r,t.set("content-length",String(new TextEncoder().encode(r).byteLength)))}return new Request(l,{method:i,headers:t,...a?.signal!==void 0&&{signal:a.signal},...s!==void 0&&{body:s}})}function g(e){return Array.isArray(e)?e[0]:e}function m(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let{method:c,id:a}=e;return typeof c!="string"?null:typeof a=="string"||typeof a=="number"?a:null}function y(e){return Response.json({jsonrpc:"2.0",error:{code:-32603,message:"Internal server error"},id:e},{status:500})}export{b as toNodeHandler,w as toWebRequest};
@@ -1 +0,0 @@
1
- import{a,b}from"./chunk-OVFUQAEG.js";export{b as createTunnelManager,a as tunnelApiBase};