@mcp-use/cli 4.0.0-beta.2 → 4.0.0-beta.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.
- package/dist/api-5C5J73XS.js +23 -0
- package/dist/bin.js +2 -2
- package/dist/build-BL3SCD2Q.js +23 -0
- package/dist/chunk-4Q7KWFEW.js +65 -0
- package/dist/chunk-4WKUTVLA.js +1 -0
- package/dist/chunk-7LRTFWC6.js +205 -0
- package/dist/chunk-AMCCKJH2.js +1 -0
- package/dist/chunk-HU2QUJ7M.js +1 -0
- package/dist/chunk-N7GIB7UG.js +2 -0
- package/dist/chunk-V2YAB5J5.js +20 -0
- package/dist/chunk-YAUVPOKC.js +618 -0
- package/dist/chunk-ZWRDP37E.js +1 -0
- package/dist/commands/build.js +5 -5
- package/dist/commands/client.js +1 -1
- package/dist/commands/deploy.js +1 -1
- package/dist/commands/deployments.js +1 -1
- package/dist/commands/dev.js +2 -2
- package/dist/commands/identity.js +1 -1
- package/dist/commands/organizations.js +1 -1
- package/dist/commands/screenshot.js +1 -1
- package/dist/commands/servers.js +1 -1
- package/dist/commands/skills.js +1 -1
- package/dist/commands/start.js +1 -1
- package/dist/dist-ATUXZA3G.js +1 -0
- package/dist/dist-DSLOT2HN.js +139 -0
- package/dist/false-AWHO5BNV.js +1 -0
- package/dist/jiti-IZ2GHWFT.js +1 -0
- package/dist/lexer-DQCqS3nf-TWOGUR6Y.js +3 -0
- package/dist/main-25QSIQDF.js +1 -0
- package/dist/next-server-shims.js +1 -1
- package/dist/node-7FETFLWX.js +1 -0
- package/dist/node-bridge-P3XTCFXS.js +1 -0
- package/dist/postcss-YNTG32JE.js +33 -0
- package/dist/postcss-import-VHSC6LGV.js +5 -0
- package/package.json +6 -2
- package/dist/chunk-33YPDBCS.js +0 -4
- package/dist/node-bridge-JJIA6K5P.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var g=Object.create;var f=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var m=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(b,c)=>(typeof require<"u"?require:b)[c]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var n=(a,b)=>()=>(b||a((b={exports:{}}).exports,b),b.exports);var l=(a,b,c,e)=>{if(b&&typeof b=="object"||typeof b=="function")for(let d of i(b))!k.call(a,d)&&d!==c&&f(a,d,{get:()=>b[d],enumerable:!(e=h(b,d))||e.enumerable});return a};var o=(a,b,c)=>(c=a!=null?g(j(a)):{},l(b||!a||!a.__esModule?f(c,"default",{value:a,enumerable:!0}):c,a));export{m as a,n as b,o as c};
|
package/dist/commands/build.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
`)),n}function ae(){let e=process.env.MCP_ASSETS_URL;if(!(e===void 0||e.trim()===""))try{return
|
|
3
|
-
`)}}return{kind:"external",entry:g.replace(/^\/+/,""),css:u!==void 0?[u.replace(/^\/+/,"")]:[]}}async function le(e){let t=performance.now();
|
|
4
|
-
`);let h=Math.round(performance.now()-t);console.log(`[mcp-use] built ${y(e.cwd,n)} \u2192 ${y(e.cwd,r.build)}/${p} (${h}ms)`);return}await
|
|
5
|
-
`);let
|
|
1
|
+
import{a as P,b as U,c as A,d as V,e as L,f as F,g as _,h as C,i as N,l as j,m as O}from"../chunk-7LRTFWC6.js";import"../chunk-HU2QUJ7M.js";import{K as v,v as S}from"../chunk-YAUVPOKC.js";import"../chunk-N7GIB7UG.js";import"../chunk-V2YAB5J5.js";import"../chunk-AMCCKJH2.js";import{a as M,b as x,c as B,d as $}from"../chunk-7G4TXPP4.js";import"../chunk-ZWRDP37E.js";import{randomBytes as W}from"crypto";import{existsSync as ee}from"fs";import{cp as te,mkdir as R,rm as re,writeFile as E}from"fs/promises";import{join as f,relative as y,resolve as ne}from"path";var Q="/mcp",X="http://localhost:3000";async function k(e,t){let i=S(e,{hmr:!1,sourcemapInterceptor:"node"}),n=process.env.MCP_URL;try{n===void 0&&(process.env.MCP_URL=X);let o=(await i.import(t)).default;if(o===null||typeof o!="object")throw new Error("The server entry must default-export the MCPServer instance.");return o.basePath??Q}finally{n===void 0?delete process.env.MCP_URL:process.env.MCP_URL=n,await i.close()}}async function T(e,t,i){let n=S(e,{hmr:!1,sourcemapInterceptor:"node"});try{let o=(await n.import(t)).default;if(o===null||typeof o!="object")throw new Error("The server entry must default-export the MCPServer instance.");if(typeof o.__primeViews!="function")throw new Error("The entry's default export does not support __primeViews.");o.__primeViews(i),o.getHandler()}finally{await n.close()}}function Z(e){return e.replace(/\/+$/,"")}function q(e){return Z(e)}import{hostHeaderValidationResponse as ge,originValidationResponse as we}from"@modelcontextprotocol/server";function H(e,t){let i=t.replace(/^\/+/,"");return e==="/"?`/${i}`:`${e}/${i}`}function I(e,t){return`${H(e,`_mcp-use/views/${t}`)}/`}var p="index.js",ie="entry-wrapper.ts",se=100*1024*1024;async function J(e,t){let i=f(e,"public");ee(i)&&await te(i,t,{recursive:!0})}async function oe(e,t,i){let n=f(e,ie);await R(e,{recursive:!0});let r=JSON.stringify(i);return await E(n,[`import server from ${JSON.stringify(t)};`,'import { registerViews } from "mcp-use";',`server[registerViews](${r});`,"export default server;",""].join(`
|
|
2
|
+
`)),n}function ae(){let e=process.env.MCP_ASSETS_URL;if(!(e===void 0||e.trim()===""))try{return q(new URL(e).href.replace(/\/$/,""))}catch{return}}function D(e,t,i,n){let r=e.replace(/^\/+/,"");return`${i}${I(n,t)}${r}`}function ce(e,t,i,n){return e.kind!=="external"?e:{...e,entry:D(e.entry,t,i,n),css:e.css.map(r=>D(r,t,i,n)),...e.scripts!==void 0&&{scripts:e.scripts.map(r=>D(r,t,i,n))}}}async function ue(e,t){let i=f(t.viewsOutDir,e.name),n=await v({root:t.cwd,configFile:t.userViteConfig,envDir:!1,publicDir:!1,logLevel:"warn",cacheDir:t.cacheDir,resolve:{tsconfigPaths:!0,alias:{tailwindcss:L()}},plugins:[P(),U(),O({getViews:()=>[e]})],build:{outDir:i,emptyOutDir:!0,write:!t.inline,target:"es2022",sourcemap:t.inline?!1:t.sourceMaps,minify:!0,cssCodeSplit:!1,chunkSizeWarningLimit:1e3,assetsInlineLimit:se,rollupOptions:{input:{[e.name]:N(e.name)},output:{format:"es",codeSplitting:!t.inline,entryFileNames:"assets/[name]-[hash].js",chunkFileNames:"assets/[name]-[hash].js",assetFileNames:"assets/[name]-[hash][extname]"}}},base:"./"}),r=Array.isArray(n)?n[0]:n;if(r===void 0||!("output"in r))throw new Error(`Client build for view "${e.name}" produced no output.`);let o=r.output,m=Array.isArray(o)?o:Object.values(o),g,u,l,c=[];for(let a of m){if(typeof a!="object"||a===null||!("fileName"in a)||typeof a.fileName!="string")continue;let s=a;s.type==="chunk"&&s.isEntry===!0?(g=s.fileName,l=s.code):s.type==="asset"&&s.fileName.endsWith(".css")&&(u=s.fileName,typeof s.source=="string"?c.push(s.source):s.source instanceof Uint8Array&&c.push(new TextDecoder().decode(s.source)))}if(g===void 0)throw new Error(`Client build produced no entry chunk for view "${e.name}".`);if(t.inline){if(l===void 0)throw new Error(`Client build produced no entry source for view "${e.name}".`);return{kind:"inline",js:l,css:c.join(`
|
|
3
|
+
`)}}return{kind:"external",entry:g.replace(/^\/+/,""),css:u!==void 0?[u.replace(/^\/+/,"")]:[]}}async function le(e){let t=performance.now();B(e.cwd,"production");let i=e.mcpDir===void 0?e.cwd:ne(e.cwd,e.mcpDir),n=e.entry===void 0?A(i):A(e.cwd,e.entry);await F(e.cwd,n)&&console.log("[mcp-use] created mcp-env.d.ts");let r=_(e.cwd),o=e.viewsDir??(e.mcpDir===void 0?void 0:f(e.mcpDir,"views")),m=C(e.cwd,o),g=V(e.cwd),u=e.sourceMaps===!0,l=e.inline===!0;if(m.length===0){await v({root:e.cwd,configFile:!1,envDir:!1,publicDir:!1,logLevel:"warn",cacheDir:r.cache,resolve:{tsconfigPaths:!0,alias:M(e.cwd)},plugins:[$(e.cwd)],build:{ssr:n,outDir:r.build,emptyOutDir:!0,target:"node22",sourcemap:u,minify:!1,rollupOptions:{output:{format:"es",entryFileNames:p}}},ssr:{...x(e.cwd),target:"node"}}),await J(e.cwd,f(r.build,"views/public"));let d={buildId:W(8).toString("hex"),entryPoint:p,createdAt:new Date().toISOString(),views:{}};await R(r.build,{recursive:!0}),await E(r.buildManifest,`${JSON.stringify(d,null,2)}
|
|
4
|
+
`);let h=Math.round(performance.now()-t);console.log(`[mcp-use] built ${y(e.cwd,n)} \u2192 ${y(e.cwd,r.build)}/${p} (${h}ms)`);return}await re(r.build,{recursive:!0,force:!0});let c=f(r.build,"views");await R(c,{recursive:!0});let a=await j(e.cwd,r.cache,!1),w,s={},b=ae();try{w=await k(a.environments.ssr,n);for(let d of m){let h=await ue(d,{cwd:e.cwd,cacheDir:r.cache,viewsOutDir:c,userViteConfig:g,sourceMaps:u,inline:l});b!==void 0&&!l&&(h=ce(h,d.name,b,w)),s[d.name]=h}b!==void 0&&!l&&(console.log(`[mcp-use] MCP_ASSETS_URL set \u2014 manifest uses CDN URLs; upload ${y(e.cwd,c)}/ to your asset host.`),w!=="/mcp"&&console.log(`[mcp-use] CDN manifest uses basePath ${w} from server entry`)),await J(e.cwd,f(c,"public")),await T(a.environments.ssr,n,s)}finally{await a.close()}let z=await oe(r.cache,n,s);await v({root:e.cwd,configFile:!1,envDir:!1,publicDir:!1,logLevel:"warn",cacheDir:r.cache,resolve:{tsconfigPaths:!0,alias:M(e.cwd)},plugins:[$(e.cwd)],build:{ssr:z,outDir:r.build,emptyOutDir:!1,target:"node22",sourcemap:u,minify:!1,rollupOptions:{output:{format:"es",entryFileNames:p}}},ssr:{...x(e.cwd),target:"node"}});let Y={buildId:W(8).toString("hex"),entryPoint:p,createdAt:new Date().toISOString(),views:s};await R(r.build,{recursive:!0}),await E(r.buildManifest,`${JSON.stringify(Y,null,2)}
|
|
5
|
+
`);let G=Math.round(performance.now()-t),K=m.map(d=>d.name).join(", ");console.log(`[mcp-use] built ${y(e.cwd,n)} + views (${K}) \u2192 ${y(e.cwd,r.build)}/${p} (${G}ms)`)}export{le as runBuild};
|
package/dist/commands/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d}from"../chunk-N6R74JIF.js";import"../chunk-LHNHT6HO.js";export{c as openDirectConnection,b as openSavedConnection,d as parseMcpArguments,a as runClient};
|
|
1
|
+
import{a,b,c,d}from"../chunk-N6R74JIF.js";import"../chunk-LHNHT6HO.js";import"../chunk-ZWRDP37E.js";export{c as openDirectConnection,b as openSavedConnection,d as parseMcpArguments,a as runClient};
|
package/dist/commands/deploy.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as O}from"../chunk-ZELLSKD2.js";import{a as c,b as d,c as k,d as R,e as _,f as E,g as U,h as j,i as A,j as L}from"../chunk-LHNHT6HO.js";import{execFile as N}from"child_process";import{readFile as D}from"fs/promises";import{basename as J,isAbsolute as S,join as F,relative as H,resolve as v}from"path";import{promisify as G,parseArgs as M}from"util";var W=G(N);async function nt(n){let e=k(n);try{let{values:t,positionals:o}=M({args:[...n],allowPositionals:!0,strict:!0,options:{org:{type:"string"},name:{type:"string"},branch:{type:"string"},"root-dir":{type:"string"},region:{type:"string"},env:{type:"string",multiple:!0},"env-file":{type:"string"},"build-command":{type:"string"},"start-command":{type:"string"},dockerfile:{type:"string"},new:{type:"boolean"},open:{type:"boolean"},yes:{type:"boolean"},json:{type:"boolean"}}});if(o.length>1)throw new c("Usage: mcp-use deploy [path] [options]");let r=v(o[0]??process.cwd()),a=await b(r,["rev-parse","--show-toplevel"]),i=await b(a,["remote","get-url","origin"]),s=B(i),g=t.branch??await b(a,["branch","--show-current"]);if(g==="")throw new d("detached_head","Cannot infer a branch from detached HEAD; pass --branch.");z(a,t["root-dir"],"--root-dir"),z(a,t.dockerfile,"--dockerfile");let{api:l,organizationId:f}=await O(t.org),I=F(r,".mcp-use","cloud","link.json"),p=await A(I,null),q=t.new===!0||p===null;if(t.new===!0&&!await E("Create a new cloud server for this project?",{yes:t.yes===!0,json:e}))return 0;let u,w,h;if(!q&&p!==null){if(p.organizationId!==f)throw new d("organization_mismatch","The linked server belongs to another organization. Pass --new to create one.");u=p.serverId,w=p.serverSlug,h=(await l.request("/deployments",{method:"POST",body:JSON.stringify({serverId:u,branch:g,trigger:"manual"})})).id}else{let y=await l.request(`/github/installations?organizationId=${encodeURIComponent(f)}`),$=await K(l,y.installations,s);if($===void 0)throw new d("github_access_required",`The mcp-use GitHub App cannot access ${s}. Configure repository access in the cloud dashboard and retry.`);let P=await Q(r,t["env-file"],t.env??[]),m=await l.request("/servers",{method:"POST",body:JSON.stringify({type:"github",organizationId:f,installationId:$.installationId,name:t.name??J(s),repoFullName:s,branch:g,...t["root-dir"]!==void 0?{rootDir:t["root-dir"]}:{},...t.region!==void 0?{region:t.region}:{},...t["build-command"]!==void 0?{buildCommand:t["build-command"]}:{},...t["start-command"]!==void 0?{startCommand:t["start-command"]}:{},...t.dockerfile!==void 0?{dockerfilePath:t.dockerfile}:{},...Object.keys(P).length>0?{env:P}:{}})});if(m.deploymentId===null)throw new d("deployment_not_created","Server was created but no deployment was started.",{serverId:m.server.id});u=m.server.id,w=m.server.slug,h=m.deploymentId,await L(I,{organizationId:f,serverId:u,serverSlug:w,repository:s})}let C=`${process.env.MCP_USE_CLOUD_WEB_URL??"https://manufact.com"}/${encodeURIComponent(w??u)}`,x={serverId:u,deploymentId:h,status:"pending",webUrl:C};return t.open===!0&&U(C),R(x,e,`Deployment ${h} started for ${s}.`),0}catch(t){return _(t instanceof TypeError?new c(t.message):t,e)}}async function b(n,e){try{let{stdout:t}=await W("git",e,{cwd:n});return t.trim()}catch{throw new d("git_required",`Could not run git ${e.join(" ")} in ${n}.`)}}function B(n){let e=n.match(/github\.com[/:]([^/\s]+)\/([^/\s]+?)(?:\.git)?$/);if(e?.[1]===void 0||e[2]===void 0)throw new d("unsupported_remote","The origin remote must be a GitHub repository.");return`${e[1]}/${e[2]}`}async function K(n,e,t){let[o,r]=t.split("/"),a=[...e].sort((i,s)=>{let g=i.account?.login?.toLowerCase()===o.toLowerCase(),l=s.account?.login?.toLowerCase()===o.toLowerCase();return Number(l)-Number(g)});for(let i of a)try{if((await n.request(`/github/installations/${encodeURIComponent(i.installationId)}/repos/${encodeURIComponent(o)}/${encodeURIComponent(r)}/access`)).hasAccess)return i}catch{}}function z(n,e,t){if(e===void 0)return;if(S(e))throw new c(`${t} must be repository-relative.`);let o=v(n,e),r=H(n,o);if(r.startsWith("..")||S(r))throw new c(`${t} must not escape the repository.`)}async function Q(n,e,t){let o={};if(e!==void 0){let r=v(n,e);if(!await j(r))throw new c(`Environment file not found: ${e}`);for(let a of(await D(r,"utf8")).split(/\r?\n/)){let i=a.trim();i===""||i.startsWith("#")||T(o,i)}}for(let r of t)T(o,r);return o}function T(n,e){let t=e.indexOf("=");if(t<=0)throw new c(`Invalid environment value: ${e}`);n[e.slice(0,t)]=e.slice(t+1)}export{nt as runDeploy};
|
|
1
|
+
import{g as O}from"../chunk-ZELLSKD2.js";import{a as c,b as d,c as k,d as R,e as _,f as E,g as U,h as j,i as A,j as L}from"../chunk-LHNHT6HO.js";import"../chunk-ZWRDP37E.js";import{execFile as N}from"child_process";import{readFile as D}from"fs/promises";import{basename as J,isAbsolute as S,join as F,relative as H,resolve as v}from"path";import{promisify as G,parseArgs as M}from"util";var W=G(N);async function nt(n){let e=k(n);try{let{values:t,positionals:o}=M({args:[...n],allowPositionals:!0,strict:!0,options:{org:{type:"string"},name:{type:"string"},branch:{type:"string"},"root-dir":{type:"string"},region:{type:"string"},env:{type:"string",multiple:!0},"env-file":{type:"string"},"build-command":{type:"string"},"start-command":{type:"string"},dockerfile:{type:"string"},new:{type:"boolean"},open:{type:"boolean"},yes:{type:"boolean"},json:{type:"boolean"}}});if(o.length>1)throw new c("Usage: mcp-use deploy [path] [options]");let r=v(o[0]??process.cwd()),a=await b(r,["rev-parse","--show-toplevel"]),i=await b(a,["remote","get-url","origin"]),s=B(i),g=t.branch??await b(a,["branch","--show-current"]);if(g==="")throw new d("detached_head","Cannot infer a branch from detached HEAD; pass --branch.");z(a,t["root-dir"],"--root-dir"),z(a,t.dockerfile,"--dockerfile");let{api:l,organizationId:f}=await O(t.org),I=F(r,".mcp-use","cloud","link.json"),p=await A(I,null),q=t.new===!0||p===null;if(t.new===!0&&!await E("Create a new cloud server for this project?",{yes:t.yes===!0,json:e}))return 0;let u,w,h;if(!q&&p!==null){if(p.organizationId!==f)throw new d("organization_mismatch","The linked server belongs to another organization. Pass --new to create one.");u=p.serverId,w=p.serverSlug,h=(await l.request("/deployments",{method:"POST",body:JSON.stringify({serverId:u,branch:g,trigger:"manual"})})).id}else{let y=await l.request(`/github/installations?organizationId=${encodeURIComponent(f)}`),$=await K(l,y.installations,s);if($===void 0)throw new d("github_access_required",`The mcp-use GitHub App cannot access ${s}. Configure repository access in the cloud dashboard and retry.`);let P=await Q(r,t["env-file"],t.env??[]),m=await l.request("/servers",{method:"POST",body:JSON.stringify({type:"github",organizationId:f,installationId:$.installationId,name:t.name??J(s),repoFullName:s,branch:g,...t["root-dir"]!==void 0?{rootDir:t["root-dir"]}:{},...t.region!==void 0?{region:t.region}:{},...t["build-command"]!==void 0?{buildCommand:t["build-command"]}:{},...t["start-command"]!==void 0?{startCommand:t["start-command"]}:{},...t.dockerfile!==void 0?{dockerfilePath:t.dockerfile}:{},...Object.keys(P).length>0?{env:P}:{}})});if(m.deploymentId===null)throw new d("deployment_not_created","Server was created but no deployment was started.",{serverId:m.server.id});u=m.server.id,w=m.server.slug,h=m.deploymentId,await L(I,{organizationId:f,serverId:u,serverSlug:w,repository:s})}let C=`${process.env.MCP_USE_CLOUD_WEB_URL??"https://manufact.com"}/${encodeURIComponent(w??u)}`,x={serverId:u,deploymentId:h,status:"pending",webUrl:C};return t.open===!0&&U(C),R(x,e,`Deployment ${h} started for ${s}.`),0}catch(t){return _(t instanceof TypeError?new c(t.message):t,e)}}async function b(n,e){try{let{stdout:t}=await W("git",e,{cwd:n});return t.trim()}catch{throw new d("git_required",`Could not run git ${e.join(" ")} in ${n}.`)}}function B(n){let e=n.match(/github\.com[/:]([^/\s]+)\/([^/\s]+?)(?:\.git)?$/);if(e?.[1]===void 0||e[2]===void 0)throw new d("unsupported_remote","The origin remote must be a GitHub repository.");return`${e[1]}/${e[2]}`}async function K(n,e,t){let[o,r]=t.split("/"),a=[...e].sort((i,s)=>{let g=i.account?.login?.toLowerCase()===o.toLowerCase(),l=s.account?.login?.toLowerCase()===o.toLowerCase();return Number(l)-Number(g)});for(let i of a)try{if((await n.request(`/github/installations/${encodeURIComponent(i.installationId)}/repos/${encodeURIComponent(o)}/${encodeURIComponent(r)}/access`)).hasAccess)return i}catch{}}function z(n,e,t){if(e===void 0)return;if(S(e))throw new c(`${t} must be repository-relative.`);let o=v(n,e),r=H(n,o);if(r.startsWith("..")||S(r))throw new c(`${t} must not escape the repository.`)}async function Q(n,e,t){let o={};if(e!==void 0){let r=v(n,e);if(!await j(r))throw new c(`Environment file not found: ${e}`);for(let a of(await D(r,"utf8")).split(/\r?\n/)){let i=a.trim();i===""||i.startsWith("#")||T(o,i)}}for(let r of t)T(o,r);return o}function T(n,e){let t=e.indexOf("=");if(t<=0)throw new c(`Invalid environment value: ${e}`);n[e.slice(0,t)]=e.slice(t+1)}export{nt as runDeploy};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as d}from"../chunk-ZELLSKD2.js";import{a,c as m,d as u,e as g,f as y}from"../chunk-LHNHT6HO.js";import{parseArgs as w}from"util";async function T(n){let t=m(n);try{let e=n[0];if(e==="list")return await I(n.slice(1),t);if(e==="get")return await P(n.slice(1),t);if(e==="logs")return await S(n.slice(1),t);if(e==="restart")return await v(n.slice(1),t);if(e==="stop")return await R(n.slice(1),t);if(e==="delete")return await E(n.slice(1),t);throw new a("Usage: mcp-use deployments <list|get|logs|restart|stop|delete>")}catch(e){return g(e instanceof TypeError?new a(e.message):e,t)}}async function I(n,t){let{values:e}=w({args:[...n],allowPositionals:!1,strict:!0,options:{org:{type:"string"},server:{type:"string"},limit:{type:"string",default:"30"},skip:{type:"string",default:"0"},json:{type:"boolean"}}}),i=f(e.limit,"--limit",1,100),s=f(e.skip,"--skip",0),o=new URLSearchParams({limit:String(i),skip:String(s),...e.server!==void 0?{serverId:e.server}:{}}),{api:r}=await d(e.org),l=await r.request(`/deployments?${o}`);return u(l,t),0}async function P(n,t){let{positionals:e}=p(n,{json:{type:"boolean"}}),i=c(e,"mcp-use deployments get <deployment-id>"),{api:s}=await d(),o=await s.request(`/deployments/${encodeURIComponent(i)}`);return u(o,t),0}async function S(n,t){let{values:e,positionals:i}=p(n,{build:{type:"boolean"},follow:{type:"boolean"},json:{type:"boolean"}}),s=c(i,"mcp-use deployments logs <deployment-id>"),{api:o}=await d();if(e.build===!0)await $(o,s,e.follow===!0,t);else{let r=await o.request(`/deployments/${encodeURIComponent(s)}/logs?lines=500`);t?u({deploymentId:s,logs:r.logs},!0):process.stdout.write(r.logs.endsWith(`
|
|
1
|
+
import{g as d}from"../chunk-ZELLSKD2.js";import{a,c as m,d as u,e as g,f as y}from"../chunk-LHNHT6HO.js";import"../chunk-ZWRDP37E.js";import{parseArgs as w}from"util";async function T(n){let t=m(n);try{let e=n[0];if(e==="list")return await I(n.slice(1),t);if(e==="get")return await P(n.slice(1),t);if(e==="logs")return await S(n.slice(1),t);if(e==="restart")return await v(n.slice(1),t);if(e==="stop")return await R(n.slice(1),t);if(e==="delete")return await E(n.slice(1),t);throw new a("Usage: mcp-use deployments <list|get|logs|restart|stop|delete>")}catch(e){return g(e instanceof TypeError?new a(e.message):e,t)}}async function I(n,t){let{values:e}=w({args:[...n],allowPositionals:!1,strict:!0,options:{org:{type:"string"},server:{type:"string"},limit:{type:"string",default:"30"},skip:{type:"string",default:"0"},json:{type:"boolean"}}}),i=f(e.limit,"--limit",1,100),s=f(e.skip,"--skip",0),o=new URLSearchParams({limit:String(i),skip:String(s),...e.server!==void 0?{serverId:e.server}:{}}),{api:r}=await d(e.org),l=await r.request(`/deployments?${o}`);return u(l,t),0}async function P(n,t){let{positionals:e}=p(n,{json:{type:"boolean"}}),i=c(e,"mcp-use deployments get <deployment-id>"),{api:s}=await d(),o=await s.request(`/deployments/${encodeURIComponent(i)}`);return u(o,t),0}async function S(n,t){let{values:e,positionals:i}=p(n,{build:{type:"boolean"},follow:{type:"boolean"},json:{type:"boolean"}}),s=c(i,"mcp-use deployments logs <deployment-id>"),{api:o}=await d();if(e.build===!0)await $(o,s,e.follow===!0,t);else{let r=await o.request(`/deployments/${encodeURIComponent(s)}/logs?lines=500`);t?u({deploymentId:s,logs:r.logs},!0):process.stdout.write(r.logs.endsWith(`
|
|
2
2
|
`)?r.logs:`${r.logs}
|
|
3
3
|
`)}return 0}async function v(n,t){let{values:e,positionals:i}=p(n,{branch:{type:"string"},follow:{type:"boolean"},json:{type:"boolean"}}),s=c(i,"mcp-use deployments restart <deployment-id>"),{api:o}=await d(),r=await o.request(`/deployments/${encodeURIComponent(s)}`);if(r.serverId===void 0||r.serverId===null)throw new a(`Deployment ${s} is not attached to a server.`);let l=await o.request("/deployments",{method:"POST",body:JSON.stringify({serverId:r.serverId,branch:e.branch??r.gitBranch??void 0,trigger:"redeploy"})});return e.follow===!0?await $(o,l.id,!0,t):u(l,t,`Restarted as deployment ${l.id}.`),0}async function R(n,t){return b(n,t,"stop")}async function E(n,t){return b(n,t,"delete")}async function b(n,t,e){let{values:i,positionals:s}=p(n,{yes:{type:"boolean"},json:{type:"boolean"}}),o=c(s,`mcp-use deployments ${e} <deployment-id>`);if(!await y(`${e==="stop"?"Stop":"Delete"} deployment ${o}?`,{yes:i.yes===!0,json:t}))return 0;let{api:r}=await d();return await r.request(`/deployments/${encodeURIComponent(o)}${e==="stop"?"/stop":""}`,{method:e==="stop"?"POST":"DELETE"}),u({[e==="stop"?"stopped":"deleted"]:o},t,`${e==="stop"?"Stopped":"Deleted"} ${o}.`),0}async function $(n,t,e,i){let s=0,o=new Set(["running","failed","stopped"]),r=!0;for(;r;){let l=await n.request(`/deployments/${encodeURIComponent(t)}/build-logs?offset=${s}`);l.logs!==""&&(i?process.stdout.write(`${JSON.stringify({deploymentId:t,offset:s,logs:l.logs,status:l.status})}
|
|
4
4
|
`):process.stdout.write(l.logs.endsWith(`
|
package/dist/commands/dev.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as Z,b as ee}from"../chunk-N7BU45K6.js";import{b as Y,c as Q}from"../chunk-JAFV3QGS.js";import{a as W,b as re,c as oe,d as se,e as ie,f as G,h as z,i as ae,k as ce}from"../chunk-33YPDBCS.js";import{b as ne,c as te,d as B}from"../chunk-7G4TXPP4.js";import{spawn as je}from"child_process";import{createServer as Ne}from"http";import{networkInterfaces as Ve}from"os";import{join as Be,resolve as We}from"path";import Ge from"@tailwindcss/vite";import ze from"@vitejs/plugin-react";import{createServer as qe,createServerModuleRunner as Je}from"vite";import{InMemoryServerEventBus as Ke,localhostAllowedHostnames as Xe,localhostAllowedOrigins as Ye,validateHostHeader as Qe,validateOriginHeader as Ze}from"@modelcontextprotocol/server";import{connect as Se,createServer as Me}from"net";var le=100,Ie=300,Re=new Set(["127.0.0.1","localhost","::1"]);function ke(e,r){return new Promise(o=>{let t=Me();t.unref(),t.once("error",()=>o(!1)),t.listen({port:e,host:r},()=>{t.close(()=>o(!0))})})}function ue(e,r){return new Promise(o=>{let t=Se({port:e,host:r});t.setTimeout(Ie),t.once("connect",()=>{t.destroy(),o(!0)}),t.once("timeout",()=>{t.destroy(),o(!1)}),t.once("error",()=>{t.destroy(),o(!1)})})}async function Te(e){return await ue(e,"127.0.0.1")||await ue(e,"::1")}async function de(e,r){for(let o=e;o<e+le;o++)if(await ke(o,r)&&!(Re.has(r)&&await Te(o)))return{port:o,requested:e};throw new Error(`No free port found between ${e} and ${e+le-1} on ${r}.`)}function pe(e,r){let o=()=>{let t=e.getBasePath(),{url:a}=e.tunnel.status();return{mcpUrl:a!==null?`${a.replace(/\/+$/,"")}${t}`:null,port:e.port,fromCli:!0,tunnelUrl:a}};return async t=>{let a=e.getBasePath(),u=`${a}/inspector/api/dev/info`,d=`${a}/inspector/api/dev/start-tunnel`,p=`${a}/inspector/api/dev/stop-tunnel`,T=new URL(t.url).pathname;if(t.method==="GET"&&T===u)return Response.json(o());if(t.method==="POST"&&T===d)try{return await e.tunnel.start(e.port),Response.json({ok:!0,restarting:!1})}catch(E){let H=E instanceof Error?E.message:"Failed to start tunnel";return Response.json({error:H},{status:500})}return t.method==="POST"&&T===p?(await e.tunnel.stop(),Response.json({ok:!0})):r(t)}}import{readFileSync as _e}from"fs";import{createRequire as Ee}from"module";import{join as He}from"path";import{pathToFileURL as $e}from"url";async function we(e){let r=He(e,"package.json"),o=JSON.parse(_e(r,"utf8"));if([o.dependencies,o.devDependencies,o.optionalDependencies].some(u=>u!==null&&typeof u=="object"&&"@mcp-use/inspector"in u)){let u=Ee(r);try{let d=u.resolve("@mcp-use/inspector");return fe(await import($e(d).href))}catch(d){if(!me(d))throw d}}try{return fe(await import("@mcp-use/inspector"))}catch(u){if(me(u))return{installed:!1};throw u}}function fe(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 me(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"}import{mkdir as De,readFile as Oe,writeFile as xe}from"fs/promises";import{spawn as Ae}from"child_process";import{dirname as Ce}from"path";var Ue="https://local.mcp-use.run";function Le(){return process.env.MCP_USE_TUNNEL_API??Ue}var q=1e3,Fe=3e4;function he(e){let r,o=null,t,a,u=!1,d,p=q,T=c=>new Promise(i=>{setTimeout(i,c)}),E=()=>{r!==void 0&&"markShutdown"in r&&typeof r.markShutdown=="function"&&r.markShutdown()},H=async c=>{try{await fetch(`${Le()}/api/tunnels/${c}`,{method:"DELETE",signal:AbortSignal.timeout(2e3)})}catch{}},O=async()=>{try{let c=await Oe(e,"utf8"),i=JSON.parse(c);return typeof i.subdomain=="string"?i.subdomain:void 0}catch{return}},$=async c=>{try{await De(Ce(e),{recursive:!0}),await xe(e,JSON.stringify({subdomain:c},null,2),"utf8")}catch(i){console.warn(`[mcp-use] failed to save tunnel subdomain: ${i instanceof Error?i.message:String(i)}`)}},w=()=>{},M=(c,i)=>new Promise((f,b)=>{console.log(`[mcp-use] starting tunnel for port ${c}\u2026`);let g=process.env.npm_config_user_agent??"",[x,_]=g.startsWith("pnpm/")?["pnpm",["--silent","dlx","@mcp-use/tunnel",String(c)]]:g.startsWith("bun/")?["bunx",["@mcp-use/tunnel",String(c)]]:["npx",["--yes","--prefer-offline","@mcp-use/tunnel",String(c)]];i!==void 0&&_.push("--subdomain",i);let S=Ae(x,_,{stdio:["ignore","pipe","pipe"],shell:process.platform==="win32"}),I=!1,h=!1,A=()=>{h=!0};S.markShutdown=A,S.stdout.on("data",P=>{let v=P.toString(),C=v.includes("Shutting down")||v.includes("\u{1F6D1}"),U=v.includes("\u2716")||v.includes("Error:");!h&&!C&&!U&&process.stdout.write(v);let D=v.match(/https?:\/\/([a-z0-9-]+\.[a-z0-9.-]+)/i);if(D!==null&&!I){let L=D[0],N=D[1]??"",y=N.match(/^([a-z0-9-]+)\./i)?.[1]??N.split(".")[0]??"";/^[a-z0-9-]+$/i.test(y)||(console.warn(`[mcp-use] warning: extracted subdomain "${y}" does not match expected format`),y=""),I=!0,clearTimeout(R),f({url:L,subdomain:y,process:S})}}),S.stderr.on("data",P=>{let v=P.toString();!h&&!v.includes("INFO")&&!v.includes("bore_cli")&&!v.includes("Shutting down")&&!/npm warn Unknown (?:env|project|user|builtin) config/.test(v)&&process.stderr.write(P)}),S.on("error",P=>{I||(clearTimeout(R),b(new Error(`Failed to start tunnel: ${P.message}`)))}),S.on("exit",P=>{P!==0&&P!==null&&!I&&(clearTimeout(R),b(new Error(`Tunnel process exited with code ${P}`))),r===S&&(r=void 0,o=null,u?t=void 0:w())});let R=setTimeout(()=>{I||(S.kill(),b(new Error("Tunnel setup timed out")))},3e4)});return w=()=>{u||a===void 0||o!==null||d===void 0&&(d=(async()=>{for(;!u&&a!==void 0&&o===null;){console.log("[mcp-use] tunnel disconnected, restarting\u2026");let c=t??await O();try{c!==void 0&&await H(c);let i;try{i=await M(a,c)}catch(f){if(c!==void 0)console.log(`[mcp-use] subdomain "${c}" unavailable, requesting a new one\u2026`),i=await M(a,void 0);else throw f}r=i.process,o=i.url,t=i.subdomain,await $(i.subdomain),p=q;return}catch(i){console.warn(`[mcp-use] tunnel restart failed: ${i instanceof Error?i.message:String(i)}`),await T(p),p=Math.min(p*2,Fe)}}})().finally(()=>{d=void 0}))},{status(){return{url:o}},async start(c){if(u=!1,a=c,o!==null)return{url:o,subdomain:t??""};let i=await O();i!==void 0&&(console.log(`[mcp-use] found existing subdomain: ${i}`),await H(i));let f;try{f=await M(c,i)}catch(b){if(i!==void 0)console.log(`[mcp-use] subdomain "${i}" unavailable, requesting a new one\u2026`),f=await M(c,void 0);else throw b}return r=f.process,o=f.url,t=f.subdomain,await $(f.subdomain),{url:f.url,subdomain:f.subdomain}},async stop(){u=!0,E(),d!==void 0&&await d,t!==void 0&&await H(t),r!==void 0&&(r.kill("SIGINT"),r=void 0),a=void 0,o=null,t=void 0,p=q}}}function en(e){let[r,o]=process.platform==="darwin"?["open",[e]]:process.platform==="win32"?["cmd",["/c","start","",e]]:["xdg-open",[e]];try{let t=je(r,o,{stdio:"ignore",detached:!0});t.on("error",()=>{}),t.unref()}catch{}}function nn(){for(let e of Object.values(Ve()))for(let r of e??[])if(!r.internal&&r.family==="IPv4")return r.address}function tn(e){if(e!==void 0)try{return new URL(`http://${e}`).hostname.replace(/^\[|\]$/g,"")}catch{return}}function rn(e){let r=e.getHeader("Vary"),o=typeof r=="string"?r:Array.isArray(r)?r.join(", "):r!==void 0?String(r):"";o.split(",").map(t=>t.trim().toLowerCase()).includes("origin")||e.setHeader("Vary",o===""?"Origin":`${o}, Origin`)}function on(e,r,o){if(o.tunnelActive){r.setHeader("Access-Control-Allow-Origin","*");return}if(!o.localhostBind)return;let t=e.headers.origin;if(t==="null"){r.setHeader("Access-Control-Allow-Origin","null");return}if(typeof t!="string"||t==="")return;let a=Ze(t,Ye());!a.ok||a.origin===void 0||(r.setHeader("Access-Control-Allow-Origin",a.origin),rn(r))}function sn(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.getHandler!="function")throw new Error("The entry's default export has no getHandler() \u2014 it must be the MCPServer instance (`export default server`).");return o}async function an(e){process.env.MCP_USE_DEV_CLI="1";let r=ie(e.cwd),o=new Ke(n=>{console.error("[mcp-use] notification delivery failed:",n)});te(e.cwd,"development");let t=Q(e.host),a=["127.0.0.1","localhost","::1"].includes(t),u=t==="0.0.0.0"||t==="::",d=Ne(),{port:p,requested:T}=await de(Y(e.port),t);p!==T&&console.log(`[mcp-use] port ${T} is taken, using ${p}`),process.env.PORT=String(p);let E=process.env.MCP_URL===void 0&&(t==="127.0.0.1"||t==="localhost"||t==="::1")?`http://localhost:${p}`:void 0,H=e.mcpDir===void 0?e.cwd:We(e.cwd,e.mcpDir),O=e.entry===void 0?W(H):W(e.cwd,e.entry);await se(e.cwd,O)&&console.log("[mcp-use] created mcp-env.d.ts");let $=e.viewsDir??(e.mcpDir===void 0?void 0:Be(e.mcpDir,"views")),w=G(e.cwd,$),M=w.length>0,c=re(e.cwd),f=["127.0.0.1","localhost","0.0.0.0","::","::1"].includes(t)?"localhost":t,b=`http://${f.includes(":")?`[${f}]`:f}:${p}`,g=await qe({root:e.cwd,configFile:M?c:!1,envDir:!1,logLevel:"warn",cacheDir:r.cache,resolve:{tsconfigPaths:!0,alias:{tailwindcss:oe()}},plugins:M?[B(e.cwd),Ge(),ce({getViews:()=>w,dev:{reactRefresh:!0}}),ze()]:[B(e.cwd)],server:{middlewareMode:!0,...M&&{origin:b},cors:!1,hmr:M?{server:d}:!1},ssr:{...ne(e.cwd)}}),x=g.environments.ssr,_=Je(x,{hmr:!1,sourcemapInterceptor:"node"}),S=async()=>{let n=async()=>{let l=await _.import(O),m=sn(l);if(w.length>0){let k=ae(w);if(typeof m.__primeViews!="function")throw new Error("Loaded MCPServer instance does not support __primeViews.");m.__primeViews(k,{dev:!0,projectRoot:e.cwd})}return m};if(E===void 0)return n();let s=process.env.MCP_URL;try{return process.env.MCP_URL=E,await n()}finally{s===void 0?delete process.env.MCP_URL:process.env.MCP_URL=s}},I,h;try{let n=await S();I=n.getHandler({bus:o}),h=n.basePath??"/mcp"}catch(n){throw await _.close(),await g.close(),n}let A,R,P,v=n=>{if(A===void 0||P===n)return;let s=A.mountInspector({basePath:n,autoConnectUrl:`${b}${n}`,oauthProxyAllowLoopback:a||u,devMode:!0});if(typeof s!="function")throw new Error("The installed @mcp-use/inspector is incompatible: mountInspector() did not return a Fetch handler.");R=s,P=n};try{if(e.inspector!==!1){let n=await we(e.cwd);n.installed&&(A=n.module,v(h))}}catch(n){throw await _.close(),await g.close(),n}let C=!1,U=!1,D=()=>{if(C){U=!0;return}C=!0,(async()=>{do{U=!1;try{_.evaluatedModules.clear();let n=await S(),s=n.getHandler({bus:o}),l=n.basePath??"/mcp";v(l),I=s,h=l,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(n){console.error(`[mcp-use] reload failed \u2014 keeping the previous server:
|
|
2
|
-
`,n)}}while(U);C=!1})()},L=n=>{if(z(n,e.cwd,$))return;let s=x.moduleGraph.getModulesByFile(n);if(!(s===void 0||s.size===0)){for(let l of s)x.moduleGraph.invalidateModule(l);D()}},N=n=>{if(!z(n,e.cwd,$))return;let s=w;w=G(e.cwd,$),(s.length!==w.length||s.some((m,k)=>m.name!==w[k]?.name||m.entryPath!==w[k]?.entryPath))&&D()},F=n=>{N(n),L(n)};g.watcher.on("change",L),g.watcher.on("add",F),g.watcher.on("unlink",F);let y=
|
|
1
|
+
import{a as Z,b as ee}from"../chunk-N7BU45K6.js";import{b as Y,c as Q}from"../chunk-JAFV3QGS.js";import{a as se,b as ie,c as W,d as ae,e as ce,f as le,g as ue,h as G,j as z,k as de,m as pe}from"../chunk-7LRTFWC6.js";import"../chunk-HU2QUJ7M.js";import{H as oe,v as re}from"../chunk-YAUVPOKC.js";import"../chunk-N7GIB7UG.js";import"../chunk-V2YAB5J5.js";import"../chunk-AMCCKJH2.js";import{b as ne,c as te,d as B}from"../chunk-7G4TXPP4.js";import"../chunk-ZWRDP37E.js";import{spawn as We}from"child_process";import{createServer as Ge}from"http";import{networkInterfaces as ze}from"os";import{join as qe,resolve as Je}from"path";import{InMemoryServerEventBus as Ke,localhostAllowedHostnames as Xe,localhostAllowedOrigins as Ye,validateHostHeader as Qe,validateOriginHeader as Ze}from"@modelcontextprotocol/server";import{connect as ke,createServer as Te}from"net";var fe=100,_e=300,Ee=new Set(["127.0.0.1","localhost","::1"]);function He(e,r){return new Promise(o=>{let t=Te();t.unref(),t.once("error",()=>o(!1)),t.listen({port:e,host:r},()=>{t.close(()=>o(!0))})})}function me(e,r){return new Promise(o=>{let t=ke({port:e,host:r});t.setTimeout(_e),t.once("connect",()=>{t.destroy(),o(!0)}),t.once("timeout",()=>{t.destroy(),o(!1)}),t.once("error",()=>{t.destroy(),o(!1)})})}async function $e(e){return await me(e,"127.0.0.1")||await me(e,"::1")}async function we(e,r){for(let o=e;o<e+fe;o++)if(await He(o,r)&&!(Ee.has(r)&&await $e(o)))return{port:o,requested:e};throw new Error(`No free port found between ${e} and ${e+fe-1} on ${r}.`)}function he(e,r){let o=()=>{let t=e.getBasePath(),{url:a}=e.tunnel.status();return{mcpUrl:a!==null?`${a.replace(/\/+$/,"")}${t}`:null,port:e.port,fromCli:!0,tunnelUrl:a}};return async t=>{let a=e.getBasePath(),u=`${a}/inspector/api/dev/info`,d=`${a}/inspector/api/dev/start-tunnel`,p=`${a}/inspector/api/dev/stop-tunnel`,T=new URL(t.url).pathname;if(t.method==="GET"&&T===u)return Response.json(o());if(t.method==="POST"&&T===d)try{return await e.tunnel.start(e.port),Response.json({ok:!0,restarting:!1})}catch(E){let H=E instanceof Error?E.message:"Failed to start tunnel";return Response.json({error:H},{status:500})}return t.method==="POST"&&T===p?(await e.tunnel.stop(),Response.json({ok:!0})):r(t)}}import{readFileSync as De}from"fs";import{createRequire as Oe}from"module";import{join as xe}from"path";import{pathToFileURL as Ae}from"url";async function Pe(e){let r=xe(e,"package.json"),o=JSON.parse(De(r,"utf8"));if([o.dependencies,o.devDependencies,o.optionalDependencies].some(u=>u!==null&&typeof u=="object"&&"@mcp-use/inspector"in u)){let u=Oe(r);try{let d=u.resolve("@mcp-use/inspector");return ge(await import(Ae(d).href))}catch(d){if(!ve(d))throw d}}try{return ge(await import("@mcp-use/inspector"))}catch(u){if(ve(u))return{installed:!1};throw u}}function ge(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 ve(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"}import{mkdir as Ce,readFile as Ue,writeFile as Le}from"fs/promises";import{spawn as Fe}from"child_process";import{dirname as je}from"path";var Ne="https://local.mcp-use.run";function Ve(){return process.env.MCP_USE_TUNNEL_API??Ne}var q=1e3,Be=3e4;function ye(e){let r,o=null,t,a,u=!1,d,p=q,T=c=>new Promise(i=>{setTimeout(i,c)}),E=()=>{r!==void 0&&"markShutdown"in r&&typeof r.markShutdown=="function"&&r.markShutdown()},H=async c=>{try{await fetch(`${Ve()}/api/tunnels/${c}`,{method:"DELETE",signal:AbortSignal.timeout(2e3)})}catch{}},O=async()=>{try{let c=await Ue(e,"utf8"),i=JSON.parse(c);return typeof i.subdomain=="string"?i.subdomain:void 0}catch{return}},$=async c=>{try{await Ce(je(e),{recursive:!0}),await Le(e,JSON.stringify({subdomain:c},null,2),"utf8")}catch(i){console.warn(`[mcp-use] failed to save tunnel subdomain: ${i instanceof Error?i.message:String(i)}`)}},w=()=>{},M=(c,i)=>new Promise((f,b)=>{console.log(`[mcp-use] starting tunnel for port ${c}\u2026`);let g=process.env.npm_config_user_agent??"",[x,_]=g.startsWith("pnpm/")?["pnpm",["--silent","dlx","@mcp-use/tunnel",String(c)]]:g.startsWith("bun/")?["bunx",["@mcp-use/tunnel",String(c)]]:["npx",["--yes","--prefer-offline","@mcp-use/tunnel",String(c)]];i!==void 0&&_.push("--subdomain",i);let S=Fe(x,_,{stdio:["ignore","pipe","pipe"],shell:process.platform==="win32"}),I=!1,h=!1,A=()=>{h=!0};S.markShutdown=A,S.stdout.on("data",P=>{let v=P.toString(),C=v.includes("Shutting down")||v.includes("\u{1F6D1}"),U=v.includes("\u2716")||v.includes("Error:");!h&&!C&&!U&&process.stdout.write(v);let D=v.match(/https?:\/\/([a-z0-9-]+\.[a-z0-9.-]+)/i);if(D!==null&&!I){let L=D[0],N=D[1]??"",y=N.match(/^([a-z0-9-]+)\./i)?.[1]??N.split(".")[0]??"";/^[a-z0-9-]+$/i.test(y)||(console.warn(`[mcp-use] warning: extracted subdomain "${y}" does not match expected format`),y=""),I=!0,clearTimeout(R),f({url:L,subdomain:y,process:S})}}),S.stderr.on("data",P=>{let v=P.toString();!h&&!v.includes("INFO")&&!v.includes("bore_cli")&&!v.includes("Shutting down")&&!/npm warn Unknown (?:env|project|user|builtin) config/.test(v)&&process.stderr.write(P)}),S.on("error",P=>{I||(clearTimeout(R),b(new Error(`Failed to start tunnel: ${P.message}`)))}),S.on("exit",P=>{P!==0&&P!==null&&!I&&(clearTimeout(R),b(new Error(`Tunnel process exited with code ${P}`))),r===S&&(r=void 0,o=null,u?t=void 0:w())});let R=setTimeout(()=>{I||(S.kill(),b(new Error("Tunnel setup timed out")))},3e4)});return w=()=>{u||a===void 0||o!==null||d===void 0&&(d=(async()=>{for(;!u&&a!==void 0&&o===null;){console.log("[mcp-use] tunnel disconnected, restarting\u2026");let c=t??await O();try{c!==void 0&&await H(c);let i;try{i=await M(a,c)}catch(f){if(c!==void 0)console.log(`[mcp-use] subdomain "${c}" unavailable, requesting a new one\u2026`),i=await M(a,void 0);else throw f}r=i.process,o=i.url,t=i.subdomain,await $(i.subdomain),p=q;return}catch(i){console.warn(`[mcp-use] tunnel restart failed: ${i instanceof Error?i.message:String(i)}`),await T(p),p=Math.min(p*2,Be)}}})().finally(()=>{d=void 0}))},{status(){return{url:o}},async start(c){if(u=!1,a=c,o!==null)return{url:o,subdomain:t??""};let i=await O();i!==void 0&&(console.log(`[mcp-use] found existing subdomain: ${i}`),await H(i));let f;try{f=await M(c,i)}catch(b){if(i!==void 0)console.log(`[mcp-use] subdomain "${i}" unavailable, requesting a new one\u2026`),f=await M(c,void 0);else throw b}return r=f.process,o=f.url,t=f.subdomain,await $(f.subdomain),{url:f.url,subdomain:f.subdomain}},async stop(){u=!0,E(),d!==void 0&&await d,t!==void 0&&await H(t),r!==void 0&&(r.kill("SIGINT"),r=void 0),a=void 0,o=null,t=void 0,p=q}}}function en(e){let[r,o]=process.platform==="darwin"?["open",[e]]:process.platform==="win32"?["cmd",["/c","start","",e]]:["xdg-open",[e]];try{let t=We(r,o,{stdio:"ignore",detached:!0});t.on("error",()=>{}),t.unref()}catch{}}function nn(){for(let e of Object.values(ze()))for(let r of e??[])if(!r.internal&&r.family==="IPv4")return r.address}function tn(e){if(e!==void 0)try{return new URL(`http://${e}`).hostname.replace(/^\[|\]$/g,"")}catch{return}}function rn(e){let r=e.getHeader("Vary"),o=typeof r=="string"?r:Array.isArray(r)?r.join(", "):r!==void 0?String(r):"";o.split(",").map(t=>t.trim().toLowerCase()).includes("origin")||e.setHeader("Vary",o===""?"Origin":`${o}, Origin`)}function on(e,r,o){if(o.tunnelActive){r.setHeader("Access-Control-Allow-Origin","*");return}if(!o.localhostBind)return;let t=e.headers.origin;if(t==="null"){r.setHeader("Access-Control-Allow-Origin","null");return}if(typeof t!="string"||t==="")return;let a=Ze(t,Ye());!a.ok||a.origin===void 0||(r.setHeader("Access-Control-Allow-Origin",a.origin),rn(r))}function sn(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.getHandler!="function")throw new Error("The entry's default export has no getHandler() \u2014 it must be the MCPServer instance (`export default server`).");return o}async function an(e){process.env.MCP_USE_DEV_CLI="1";let r=ue(e.cwd),o=new Ke(n=>{console.error("[mcp-use] notification delivery failed:",n)});te(e.cwd,"development");let t=Q(e.host),a=["127.0.0.1","localhost","::1"].includes(t),u=t==="0.0.0.0"||t==="::",d=Ge(),{port:p,requested:T}=await we(Y(e.port),t);p!==T&&console.log(`[mcp-use] port ${T} is taken, using ${p}`),process.env.PORT=String(p);let E=process.env.MCP_URL===void 0&&(t==="127.0.0.1"||t==="localhost"||t==="::1")?`http://localhost:${p}`:void 0,H=e.mcpDir===void 0?e.cwd:Je(e.cwd,e.mcpDir),O=e.entry===void 0?W(H):W(e.cwd,e.entry);await le(e.cwd,O)&&console.log("[mcp-use] created mcp-env.d.ts");let $=e.viewsDir??(e.mcpDir===void 0?void 0:qe(e.mcpDir,"views")),w=G(e.cwd,$),M=w.length>0,c=ae(e.cwd),f=["127.0.0.1","localhost","0.0.0.0","::","::1"].includes(t)?"localhost":t,b=`http://${f.includes(":")?`[${f}]`:f}:${p}`,g=await oe({root:e.cwd,configFile:M?c:!1,envDir:!1,logLevel:"warn",cacheDir:r.cache,resolve:{tsconfigPaths:!0,alias:{tailwindcss:ce()}},plugins:M?[B(e.cwd),se(),pe({getViews:()=>w,dev:{reactRefresh:!0}}),ie()]:[B(e.cwd)],server:{middlewareMode:!0,...M&&{origin:b},cors:!1,hmr:M?{server:d}:!1},ssr:{...ne(e.cwd)}}),x=g.environments.ssr,_=re(x,{hmr:!1,sourcemapInterceptor:"node"}),S=async()=>{let n=async()=>{let l=await _.import(O),m=sn(l);if(w.length>0){let k=de(w);if(typeof m.__primeViews!="function")throw new Error("Loaded MCPServer instance does not support __primeViews.");m.__primeViews(k,{dev:!0,projectRoot:e.cwd})}return m};if(E===void 0)return n();let s=process.env.MCP_URL;try{return process.env.MCP_URL=E,await n()}finally{s===void 0?delete process.env.MCP_URL:process.env.MCP_URL=s}},I,h;try{let n=await S();I=n.getHandler({bus:o}),h=n.basePath??"/mcp"}catch(n){throw await _.close(),await g.close(),n}let A,R,P,v=n=>{if(A===void 0||P===n)return;let s=A.mountInspector({basePath:n,autoConnectUrl:`${b}${n}`,oauthProxyAllowLoopback:a||u,devMode:!0});if(typeof s!="function")throw new Error("The installed @mcp-use/inspector is incompatible: mountInspector() did not return a Fetch handler.");R=s,P=n};try{if(e.inspector!==!1){let n=await Pe(e.cwd);n.installed&&(A=n.module,v(h))}}catch(n){throw await _.close(),await g.close(),n}let C=!1,U=!1,D=()=>{if(C){U=!0;return}C=!0,(async()=>{do{U=!1;try{_.evaluatedModules.clear();let n=await S(),s=n.getHandler({bus:o}),l=n.basePath??"/mcp";v(l),I=s,h=l,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(n){console.error(`[mcp-use] reload failed \u2014 keeping the previous server:
|
|
2
|
+
`,n)}}while(U);C=!1})()},L=n=>{if(z(n,e.cwd,$))return;let s=x.moduleGraph.getModulesByFile(n);if(!(s===void 0||s.size===0)){for(let l of s)x.moduleGraph.invalidateModule(l);D()}},N=n=>{if(!z(n,e.cwd,$))return;let s=w;w=G(e.cwd,$),(s.length!==w.length||s.some((m,k)=>m.name!==w[k]?.name||m.entryPath!==w[k]?.entryPath))&&D()},F=n=>{N(n),L(n)};g.watcher.on("change",L),g.watcher.on("add",F),g.watcher.on("unlink",F);let y=ye(r.tunnel);d.prependListener("upgrade",n=>{let s=y.status().url;if(s===null)return;let l=new URL(s).hostname;n.headers.host?.split(":")[0]===l&&(n.headers.host=`localhost:${p}`)});let be=(n,s)=>{let l=y.status().url,m=l!==null?new URL(l).hostname:null,k=m!==null?[m]:[],j=Qe(n.headers.host,[...Xe(),...k]);return j.ok?!1:(s.writeHead(403,{"content-type":"application/json"}),s.end(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:j.message},id:null})),!0)},J=async()=>{g.watcher.off("change",L),g.watcher.off("add",F),g.watcher.off("unlink",F),await y.stop(),await new Promise(n=>d.close(()=>n())),await _.close(),await g.close()},Se=he({getBasePath:()=>h,port:p,tunnel:y},n=>R!==void 0&&Z(n,h)?R(n):I(n)),{toNodeHandler:Me}=await import("../node-bridge-P3XTCFXS.js"),K=Me({fetch:Se}),Ie=(n,s)=>{if(a&&be(n,s))return;let l=n.url??"/",m=new URL(l,"http://127.0.0.1").pathname,k=y.status().url,j=k===null?null:new URL(k).hostname,V=tn(n.headers.host);if((j!==null&&V===j||u&&V!==void 0&&!["localhost","127.0.0.1","::1"].includes(V))&&ee(m,h)){s.writeHead(404,{"content-type":"text/plain; charset=utf-8"}),s.end("Not Found");return}let X=M&&w.length>0,Re=n.method==="GET"&&(m.startsWith("/@")||m.startsWith("/node_modules/")||m.startsWith("/.mcp-use/")||X&&m.startsWith("/views/"));X&&Re?(on(n,s,{tunnelActive:y.status().url!==null,localhostBind:a}),g.middlewares(n,s,()=>{K(n,s)})):K(n,s)};if(d.on("request",Ie),await new Promise((n,s)=>{d.once("error",s),d.listen(p,t,()=>n())}),console.log("[mcp-use] dev server ready"),w.length>0&&console.log(` \u279C Views: ${w.map(n=>n.name).join(", ")}`),console.log(` \u279C MCP endpoint: ${b}${h}`),R!==void 0?console.log(` \u279C Inspector: ${b}${h}/inspector`):e.inspector!==!1&&console.warn("[mcp-use] Built-in Inspector is unavailable; reinstall mcp-use to restore visual testing."),t==="0.0.0.0"||t==="::"){let n=nn();n!==void 0&&console.log(` \u279C Network: http://${n}:${p}${h}`)}if(a||console.warn(`[mcp-use] --host ${t} 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:n}=await y.start(p);console.log(` \u279C Tunnel: ${n}${h}`)}catch(n){throw await J(),n}R!==void 0&&e.open!==!1&&process.stdout.isTTY===!0&&en(`${b}${h}/inspector`),await new Promise(n=>{let s=!1,l=()=>{s||(s=!0,process.off("SIGINT",l),process.off("SIGTERM",l),(async()=>(await J(),n()))())};process.on("SIGINT",l),process.on("SIGTERM",l),e.signal!==void 0&&(e.signal.aborted?l():e.signal.addEventListener("abort",l,{once:!0}))})}export{an as runDev};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as h,b as v,c as b,d as C,e as k,f as d}from"../chunk-ZELLSKD2.js";import{a as f,b as l,c as y,d as c,e as m,f as w,g as _}from"../chunk-LHNHT6HO.js";import{parseArgs as u}from"util";async function S(i,n){let o=y(n);try{return i==="login"?await P(n,o):i==="logout"?await $(n,o):await T(n,o)}catch(e){return m(e instanceof TypeError?new f(e.message):e,o)}}async function P(i,n){let{values:o}=u({args:[...i],allowPositionals:!1,strict:!0,options:{"api-key":{type:"string"},org:{type:"string"},"no-open":{type:"boolean"},json:{type:"boolean"}}}),e=o["api-key"]??process.env.MCP_USE_API_KEY;e===void 0&&(e=await I(o["no-open"]===!0||!process.stdout.isTTY));let t=await d.withApiKey(e).identity(),r=o.org!==void 0?k(t.organizations,o.org):t.organizations.find(a=>a.id===t.defaultOrganizationId);return await b({apiKey:e,...r!==void 0?{orgId:r.id,orgName:r.name,...r.slug!==null?{orgSlug:r.slug}:{}}:{}}),c({email:t.email,organization:r??null},n,`Logged in as ${t.email}${r!==void 0?` (${r.name})`:""}.`),0}async function $(i,n){let{values:o}=u({args:[...i],allowPositionals:!1,strict:!0,options:{yes:{type:"boolean"},json:{type:"boolean"}}});return await w("Delete local cloud credentials?",{yes:o.yes===!0,json:n})&&(await C(),c({loggedOut:!0},n,"Logged out.")),0}async function T(i,n){u({args:[...i],allowPositionals:!1,strict:!0,options:{json:{type:"boolean"}}});let o=await v(),e=await(await d.create()).identity(),t=e.organizations.find(a=>a.id===o.orgId)??null,r={userId:e.userId,email:e.email,organization:t};return c(r,n,`${e.email}${t!==null?` \u2014 ${t.name}`:""}`),0}async function I(i){let n=h(),o=await fetch(`${n}/api/auth/device/code`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:"mcp-use-cli",scope:"openid profile email"})});if(!o.ok)throw new l("login_failed",`Could not start device login (${o.status}).`);let e=await o.json(),t=e.verification_uri_complete??e.verification_uri;process.stderr.write(`Open ${t} and enter code ${e.user_code}.
|
|
1
|
+
import{a as h,b as v,c as b,d as C,e as k,f as d}from"../chunk-ZELLSKD2.js";import{a as f,b as l,c as y,d as c,e as m,f as w,g as _}from"../chunk-LHNHT6HO.js";import"../chunk-ZWRDP37E.js";import{parseArgs as u}from"util";async function S(i,n){let o=y(n);try{return i==="login"?await P(n,o):i==="logout"?await $(n,o):await T(n,o)}catch(e){return m(e instanceof TypeError?new f(e.message):e,o)}}async function P(i,n){let{values:o}=u({args:[...i],allowPositionals:!1,strict:!0,options:{"api-key":{type:"string"},org:{type:"string"},"no-open":{type:"boolean"},json:{type:"boolean"}}}),e=o["api-key"]??process.env.MCP_USE_API_KEY;e===void 0&&(e=await I(o["no-open"]===!0||!process.stdout.isTTY));let t=await d.withApiKey(e).identity(),r=o.org!==void 0?k(t.organizations,o.org):t.organizations.find(a=>a.id===t.defaultOrganizationId);return await b({apiKey:e,...r!==void 0?{orgId:r.id,orgName:r.name,...r.slug!==null?{orgSlug:r.slug}:{}}:{}}),c({email:t.email,organization:r??null},n,`Logged in as ${t.email}${r!==void 0?` (${r.name})`:""}.`),0}async function $(i,n){let{values:o}=u({args:[...i],allowPositionals:!1,strict:!0,options:{yes:{type:"boolean"},json:{type:"boolean"}}});return await w("Delete local cloud credentials?",{yes:o.yes===!0,json:n})&&(await C(),c({loggedOut:!0},n,"Logged out.")),0}async function T(i,n){u({args:[...i],allowPositionals:!1,strict:!0,options:{json:{type:"boolean"}}});let o=await v(),e=await(await d.create()).identity(),t=e.organizations.find(a=>a.id===o.orgId)??null,r={userId:e.userId,email:e.email,organization:t};return c(r,n,`${e.email}${t!==null?` \u2014 ${t.name}`:""}`),0}async function I(i){let n=h(),o=await fetch(`${n}/api/auth/device/code`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:"mcp-use-cli",scope:"openid profile email"})});if(!o.ok)throw new l("login_failed",`Could not start device login (${o.status}).`);let e=await o.json(),t=e.verification_uri_complete??e.verification_uri;process.stderr.write(`Open ${t} and enter code ${e.user_code}.
|
|
2
2
|
`),i||_(t);let r=Date.now()+e.expires_in*1e3,a=Math.max(e.interval,1);for(;Date.now()<r;){await O(a*1e3);let s=await(await fetch(`${n}/api/auth/device/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"urn:ietf:params:oauth:grant-type:device_code",device_code:e.device_code,client_id:"mcp-use-cli"})})).json();if(s.access_token!==void 0){let p=await fetch(`${n}/api/auth/api-key/create`,{method:"POST",headers:{Authorization:`Bearer ${s.access_token}`,"Content-Type":"application/json"},body:JSON.stringify({name:"CLI",prefix:"mcp_"})});if(!p.ok)throw new l("login_failed","Could not create a CLI API key.");let g=await p.json();if(typeof g.key!="string")throw new l("login_failed","Cloud returned an invalid API key.");return g.key}if(s.error!=="authorization_pending"){if(s.error==="slow_down"){a+=5;continue}throw new l("login_failed",s.error_description??s.error??"Device login failed.")}}throw new l("login_timeout","Device login expired.")}function O(i){return new Promise(n=>setTimeout(n,i))}export{S as runIdentity};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as m,c as p,e as w,f as y}from"../chunk-ZELLSKD2.js";import{a as s,c as g,d as l,e as f}from"../chunk-LHNHT6HO.js";import{parseArgs as $}from"util";async function I(o){let a=g(o);try{let r=o[0];if(!["list","current","use"].includes(r??""))throw new s("Usage: mcp-use org <list|current|use>");let c=await y.create(),t=await c.identity(),u=await m();if(r==="list"){z(o.slice(1));let e=t.organizations.map(n=>({...n,active:n.id===(u.orgId??t.defaultOrganizationId??void 0)}));return l(e,a,e.map(n=>`${n.active?"* ":" "}${n.name} (${n.slug??n.id}) [${n.role}]`).join(`
|
|
1
|
+
import{b as m,c as p,e as w,f as y}from"../chunk-ZELLSKD2.js";import{a as s,c as g,d as l,e as f}from"../chunk-LHNHT6HO.js";import"../chunk-ZWRDP37E.js";import{parseArgs as $}from"util";async function I(o){let a=g(o);try{let r=o[0];if(!["list","current","use"].includes(r??""))throw new s("Usage: mcp-use org <list|current|use>");let c=await y.create(),t=await c.identity(),u=await m();if(r==="list"){z(o.slice(1));let e=t.organizations.map(n=>({...n,active:n.id===(u.orgId??t.defaultOrganizationId??void 0)}));return l(e,a,e.map(n=>`${n.active?"* ":" "}${n.name} (${n.slug??n.id}) [${n.role}]`).join(`
|
|
2
2
|
`)||"No organizations."),0}if(r==="current"){z(o.slice(1));let e=t.organizations.find(n=>n.id===(u.orgId??t.defaultOrganizationId))??null;if(e===null)throw new s("No active organization. Run `mcp-use org use <id-or-slug>`.");return l(e,a,`${e.name} (${e.slug??e.id})`),0}let d=o[1];if(d===void 0||o.length!==2)throw new s("Usage: mcp-use org use <id-or-slug>");let i=w(t.organizations,d);await p({...u.apiKey!==void 0?{apiKey:u.apiKey}:{},orgId:i.id,orgName:i.name,...i.slug!==null?{orgSlug:i.slug}:{}});try{await c.setDefaultOrganization(i.id)}catch{}return l(i,a,`Using ${i.name} (${i.slug??i.id}).`),0}catch(r){return f(r instanceof TypeError?new s(r.message):r,a)}}function z(o){$({args:[...o],allowPositionals:!1,strict:!0,options:{json:{type:"boolean"}}})}export{I as runOrganizations};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as M,c as $,d as x}from"../chunk-N6R74JIF.js";import{a as c,b as s,c as _,d as k,e as R}from"../chunk-LHNHT6HO.js";import{spawn as H}from"child_process";import{access as N,mkdtemp as j,rm as A,writeFile as F}from"fs/promises";import{createServer as G}from"net";import{tmpdir as J}from"os";import{basename as V,join as q,resolve as W}from"path";import{parseArgs as z}from"util";import{fileURLToPath as K}from"url";async function Pe(r){let n=_(r),e,t,i;try{let{values:o,positionals:a}=z({args:[...r],allowPositionals:!0,strict:!0,options:{server:{type:"string"},mcp:{type:"string"},tool:{type:"string"},header:{type:"string",short:"H",multiple:!0},output:{type:"string"},width:{type:"string",default:"1280"},height:{type:"string",default:"720"},"device-scale-factor":{type:"string",default:"1"},theme:{type:"string",default:"light"},inspector:{type:"string"},"cdp-url":{type:"string"},"wait-for":{type:"string"},delay:{type:"string",default:"0"},timeout:{type:"string",default:"30000"},json:{type:"boolean"}}});if(o.server===void 0==(o.mcp===void 0))throw new c("Exactly one of --server or --mcp is required.");if(o.tool===void 0)throw new c("--tool is required.");if(o.server!==void 0&&o.header!==void 0)throw new c("--header is valid only with --mcp.");if(o.theme!=="light"&&o.theme!=="dark")throw new c("--theme must be light or dark.");let w=h(o.width,"--width"),y=h(o.height,"--height"),u=Number(o["device-scale-factor"]);if(!Number.isFinite(u)||u<=0||u>4)throw new c("--device-scale-factor must be greater than 0 and at most 4.");let l=h(o.timeout,"--timeout"),b=de(o.delay,"--delay"),U=ce(o.header??[]);e=o.server!==void 0?await M(o.server):await $(new URL(o.mcp).href,U);let P=(await e.listTools()).find(O=>O.name===o.tool);if(P===void 0)throw new s("tool_not_found",`Tool not found: ${o.tool}`);let m=Z(P),C=x(a),f=await e.callTool(o.tool,C,{timeout:l});if(f.isError===!0)throw new s("tool_failed",`Tool ${o.tool} returned an error.`,f);let I=await e.readResource(m);ee(I),i=o.inspector===void 0?await X(l):void 0;let E=(o.inspector??i.origin).replace(/\/+$/,"");await B(E,l);let S=te(m),p=new URL(`${E}/inspector/preview/${encodeURIComponent(S)}`);p.searchParams.set("protocol","1"),p.searchParams.set("theme",o.theme),p.searchParams.set("width",String(w)),t=o["cdp-url"]!==void 0?await re(o["cdp-url"]):await ne(),await t.cdp.send("Emulation.setDeviceMetricsOverride",{width:w,height:y,deviceScaleFactor:u,mobile:!1},t.sessionId),await t.cdp.send("Page.enable",{},t.sessionId),await t.cdp.send("Runtime.enable",{},t.sessionId),await t.cdp.send("Page.addScriptToEvaluateOnNewDocument",{source:`globalThis.__mcpUsePreviewBundle = ${ue({resourceUri:m,resourceContents:I,toolInput:C,toolOutput:f})};`},t.sessionId),await t.cdp.send("Page.navigate",{url:p.href},t.sessionId),await oe(t,l),await ie(t,o["wait-for"],l),b>0&&await d(b);let T=await t.cdp.send("Page.captureScreenshot",{format:"png",captureBeyondViewport:!1},t.sessionId);if(typeof T.data!="string")throw new s("capture_failed","Chrome returned no screenshot data.");let g=W(o.output??`${S}-${new Date().toISOString().replace(/[:.]/g,"-")}.png`);return await F(g,Buffer.from(T.data,"base64")),k({path:g,width:w,height:y,deviceScaleFactor:u},n,g),0}catch(o){return R(o instanceof TypeError?new c(o.message):o,n)}finally{await t?.close().catch(()=>{}),await i?.close().catch(()=>{}),await e?.disconnect().catch(()=>{})}}async function X(r){let n=await D(),e=import.meta.resolve("@mcp-use/inspector"),t=K(new URL("../cli.js",e)),i=H(process.execPath,[t,"--port",String(n),"--no-open"],{stdio:"ignore"}),o=`http://127.0.0.1:${n}`;try{await Q(o,i,Math.min(r,1e4))}catch(a){throw i.kill("SIGTERM"),a}return{origin:o,async close(){await Y(i)}}}async function Q(r,n,e){let t=Date.now()+e;for(;Date.now()<t;){if(n.exitCode!==null)throw new s("inspector_start_failed",`Packaged Inspector exited before becoming ready (code ${n.exitCode}).`);try{await B(r,Math.min(1e3,e));return}catch{await d(100)}}throw new s("inspector_start_failed","Packaged Inspector did not start in time.")}async function Y(r){r.exitCode===null&&(r.kill("SIGTERM"),await Promise.race([new Promise(n=>r.once("exit",()=>n())),d(2e3)]),r.exitCode===null&&r.kill("SIGKILL"))}async function B(r,n){let e=await fetch(`${r}/inspector/health`,{signal:AbortSignal.timeout(n)});if(!e.ok)throw new s("incompatible_inspector",`Inspector health check failed (${e.status}).`);let t=await e.json();if(t.status!=="ok"||t.protocol!=="mcp-use-inspector-preview"||t.version!==1||!t.capabilities?.includes("view-preview"))throw new s("incompatible_inspector","Inspector does not support mcp-use-inspector-preview version 1.")}function Z(r){let n=r!==null&&typeof r=="object"?r._meta:void 0,t=(n?.ui!==null&&typeof n?.ui=="object"?n.ui.resourceUri:void 0)??n?.["ui/resourceUri"];if(typeof t!="string")throw new s("missing_view","Tool does not advertise an MCP Apps UI resource.");return t}function ee(r){let n=r!==null&&typeof r=="object"?r.contents:void 0;if(!Array.isArray(n))throw new s("invalid_view","View resource has no contents.");let e=n.find(t=>t!==null&&typeof t=="object"&&typeof t.text=="string");if(e===void 0)throw new s("invalid_view","View resource has no HTML document.");return e.text}function te(r){let n=new URL(r);return V(n.pathname).replace(/\.html$/,"")||n.hostname}async function ne(){let r=await se(),n=await D(),e=await j(q(J(),"mcp-use-chrome-")),t=H(r,[`--remote-debugging-port=${n}`,`--user-data-dir=${e}`,"--headless=new","--no-first-run","--no-default-browser-check","about:blank"],{stdio:"ignore"});try{let i=await ae(`http://127.0.0.1:${n}/json/version`,1e4),o=await L(i.webSocketDebuggerUrl);return{...o,async close(){await o.close(),t.kill("SIGTERM"),await A(e,{recursive:!0,force:!0})}}}catch(i){throw t.kill("SIGTERM"),await A(e,{recursive:!0,force:!0}),i}}async function re(r){return L(r)}async function L(r){let n=await v.connect(r),e=await n.send("Target.createTarget",{url:"about:blank"}),t=await n.send("Target.attachToTarget",{targetId:e.targetId,flatten:!0});return{cdp:n,sessionId:t.sessionId,async close(){await n.send("Target.closeTarget",{targetId:e.targetId}).catch(()=>{}),n.close()}}}async function oe(r,n){let e=Date.now()+n;for(;Date.now()<e;){if((await r.cdp.send("Runtime.evaluate",{expression:"document.readyState",returnByValue:!0},r.sessionId)).result?.value==="complete")return;await d(100)}throw new s("browser_timeout","Inspector page did not load in time.")}async function ie(r,n,e){let t=Date.now()+e;for(;Date.now()<t;){let i=`(() => ({
|
|
1
|
+
import{b as M,c as $,d as x}from"../chunk-N6R74JIF.js";import{a as c,b as s,c as _,d as k,e as R}from"../chunk-LHNHT6HO.js";import"../chunk-ZWRDP37E.js";import{spawn as H}from"child_process";import{access as N,mkdtemp as j,rm as A,writeFile as F}from"fs/promises";import{createServer as G}from"net";import{tmpdir as J}from"os";import{basename as V,join as q,resolve as W}from"path";import{parseArgs as z}from"util";import{fileURLToPath as K}from"url";async function Pe(r){let n=_(r),e,t,i;try{let{values:o,positionals:a}=z({args:[...r],allowPositionals:!0,strict:!0,options:{server:{type:"string"},mcp:{type:"string"},tool:{type:"string"},header:{type:"string",short:"H",multiple:!0},output:{type:"string"},width:{type:"string",default:"1280"},height:{type:"string",default:"720"},"device-scale-factor":{type:"string",default:"1"},theme:{type:"string",default:"light"},inspector:{type:"string"},"cdp-url":{type:"string"},"wait-for":{type:"string"},delay:{type:"string",default:"0"},timeout:{type:"string",default:"30000"},json:{type:"boolean"}}});if(o.server===void 0==(o.mcp===void 0))throw new c("Exactly one of --server or --mcp is required.");if(o.tool===void 0)throw new c("--tool is required.");if(o.server!==void 0&&o.header!==void 0)throw new c("--header is valid only with --mcp.");if(o.theme!=="light"&&o.theme!=="dark")throw new c("--theme must be light or dark.");let w=h(o.width,"--width"),y=h(o.height,"--height"),u=Number(o["device-scale-factor"]);if(!Number.isFinite(u)||u<=0||u>4)throw new c("--device-scale-factor must be greater than 0 and at most 4.");let l=h(o.timeout,"--timeout"),b=de(o.delay,"--delay"),U=ce(o.header??[]);e=o.server!==void 0?await M(o.server):await $(new URL(o.mcp).href,U);let P=(await e.listTools()).find(O=>O.name===o.tool);if(P===void 0)throw new s("tool_not_found",`Tool not found: ${o.tool}`);let m=Z(P),C=x(a),f=await e.callTool(o.tool,C,{timeout:l});if(f.isError===!0)throw new s("tool_failed",`Tool ${o.tool} returned an error.`,f);let I=await e.readResource(m);ee(I),i=o.inspector===void 0?await X(l):void 0;let E=(o.inspector??i.origin).replace(/\/+$/,"");await B(E,l);let S=te(m),p=new URL(`${E}/inspector/preview/${encodeURIComponent(S)}`);p.searchParams.set("protocol","1"),p.searchParams.set("theme",o.theme),p.searchParams.set("width",String(w)),t=o["cdp-url"]!==void 0?await re(o["cdp-url"]):await ne(),await t.cdp.send("Emulation.setDeviceMetricsOverride",{width:w,height:y,deviceScaleFactor:u,mobile:!1},t.sessionId),await t.cdp.send("Page.enable",{},t.sessionId),await t.cdp.send("Runtime.enable",{},t.sessionId),await t.cdp.send("Page.addScriptToEvaluateOnNewDocument",{source:`globalThis.__mcpUsePreviewBundle = ${ue({resourceUri:m,resourceContents:I,toolInput:C,toolOutput:f})};`},t.sessionId),await t.cdp.send("Page.navigate",{url:p.href},t.sessionId),await oe(t,l),await ie(t,o["wait-for"],l),b>0&&await d(b);let T=await t.cdp.send("Page.captureScreenshot",{format:"png",captureBeyondViewport:!1},t.sessionId);if(typeof T.data!="string")throw new s("capture_failed","Chrome returned no screenshot data.");let g=W(o.output??`${S}-${new Date().toISOString().replace(/[:.]/g,"-")}.png`);return await F(g,Buffer.from(T.data,"base64")),k({path:g,width:w,height:y,deviceScaleFactor:u},n,g),0}catch(o){return R(o instanceof TypeError?new c(o.message):o,n)}finally{await t?.close().catch(()=>{}),await i?.close().catch(()=>{}),await e?.disconnect().catch(()=>{})}}async function X(r){let n=await D(),e=import.meta.resolve("@mcp-use/inspector"),t=K(new URL("../cli.js",e)),i=H(process.execPath,[t,"--port",String(n),"--no-open"],{stdio:"ignore"}),o=`http://127.0.0.1:${n}`;try{await Q(o,i,Math.min(r,1e4))}catch(a){throw i.kill("SIGTERM"),a}return{origin:o,async close(){await Y(i)}}}async function Q(r,n,e){let t=Date.now()+e;for(;Date.now()<t;){if(n.exitCode!==null)throw new s("inspector_start_failed",`Packaged Inspector exited before becoming ready (code ${n.exitCode}).`);try{await B(r,Math.min(1e3,e));return}catch{await d(100)}}throw new s("inspector_start_failed","Packaged Inspector did not start in time.")}async function Y(r){r.exitCode===null&&(r.kill("SIGTERM"),await Promise.race([new Promise(n=>r.once("exit",()=>n())),d(2e3)]),r.exitCode===null&&r.kill("SIGKILL"))}async function B(r,n){let e=await fetch(`${r}/inspector/health`,{signal:AbortSignal.timeout(n)});if(!e.ok)throw new s("incompatible_inspector",`Inspector health check failed (${e.status}).`);let t=await e.json();if(t.status!=="ok"||t.protocol!=="mcp-use-inspector-preview"||t.version!==1||!t.capabilities?.includes("view-preview"))throw new s("incompatible_inspector","Inspector does not support mcp-use-inspector-preview version 1.")}function Z(r){let n=r!==null&&typeof r=="object"?r._meta:void 0,t=(n?.ui!==null&&typeof n?.ui=="object"?n.ui.resourceUri:void 0)??n?.["ui/resourceUri"];if(typeof t!="string")throw new s("missing_view","Tool does not advertise an MCP Apps UI resource.");return t}function ee(r){let n=r!==null&&typeof r=="object"?r.contents:void 0;if(!Array.isArray(n))throw new s("invalid_view","View resource has no contents.");let e=n.find(t=>t!==null&&typeof t=="object"&&typeof t.text=="string");if(e===void 0)throw new s("invalid_view","View resource has no HTML document.");return e.text}function te(r){let n=new URL(r);return V(n.pathname).replace(/\.html$/,"")||n.hostname}async function ne(){let r=await se(),n=await D(),e=await j(q(J(),"mcp-use-chrome-")),t=H(r,[`--remote-debugging-port=${n}`,`--user-data-dir=${e}`,"--headless=new","--no-first-run","--no-default-browser-check","about:blank"],{stdio:"ignore"});try{let i=await ae(`http://127.0.0.1:${n}/json/version`,1e4),o=await L(i.webSocketDebuggerUrl);return{...o,async close(){await o.close(),t.kill("SIGTERM"),await A(e,{recursive:!0,force:!0})}}}catch(i){throw t.kill("SIGTERM"),await A(e,{recursive:!0,force:!0}),i}}async function re(r){return L(r)}async function L(r){let n=await v.connect(r),e=await n.send("Target.createTarget",{url:"about:blank"}),t=await n.send("Target.attachToTarget",{targetId:e.targetId,flatten:!0});return{cdp:n,sessionId:t.sessionId,async close(){await n.send("Target.closeTarget",{targetId:e.targetId}).catch(()=>{}),n.close()}}}async function oe(r,n){let e=Date.now()+n;for(;Date.now()<e;){if((await r.cdp.send("Runtime.evaluate",{expression:"document.readyState",returnByValue:!0},r.sessionId)).result?.value==="complete")return;await d(100)}throw new s("browser_timeout","Inspector page did not load in time.")}async function ie(r,n,e){let t=Date.now()+e;for(;Date.now()<t;){let i=`(() => ({
|
|
2
2
|
ready: document.body?.dataset.viewReady === "true",
|
|
3
3
|
error: document.body?.dataset.viewError || null,
|
|
4
4
|
selector: ${JSON.stringify(n)} === undefined || !!document.querySelector(${JSON.stringify(n??"")})
|
package/dist/commands/servers.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{g as d}from"../chunk-ZELLSKD2.js";import{a as u,c as k,d as l,e as P,f as y}from"../chunk-LHNHT6HO.js";import{parseArgs as m}from"util";async function x(n){let t=k(n);try{let e=n[0];if(e==="list")return await $(n.slice(1),t);if(e==="get")return await E(n.slice(1),t);if(e==="update")return await C(n.slice(1),t);if(e==="delete")return await A(n.slice(1),t);if(e==="env")return await I(n.slice(1),t);throw new u("Usage: mcp-use servers <list|get|update|delete|env>")}catch(e){return P(e instanceof TypeError?new u(e.message):e,t)}}async function $(n,t){let{values:e}=m({args:[...n],allowPositionals:!1,strict:!0,options:S()}),{api:s,organizationId:r}=await d(e.org),{limit:i,skip:a}=N(e.limit,e.skip),c=new URLSearchParams({organizationId:r,limit:String(i),skip:String(a)}),o=await s.request(`/servers?${c}`);return l(o,t),0}async function E(n,t){let{values:e,positionals:s}=m({args:[...n],allowPositionals:!0,strict:!0,options:p()}),r=b(s,"mcp-use servers get <id-or-slug>"),{api:i}=await d(e.org),a=await i.request(`/servers/${encodeURIComponent(r)}`);return l(a,t),0}async function C(n,t){let{values:e,positionals:s}=m({args:[...n],allowPositionals:!0,strict:!0,options:{...p(),name:{type:"string"},description:{type:"string"},branch:{type:"string"},"root-dir":{type:"string"},"build-command":{type:"string"},"start-command":{type:"string"}}}),r=b(s,"mcp-use servers update <id-or-slug>"),i={...e["root-dir"]!==void 0?{rootDir:e["root-dir"]||null}:{},...e["build-command"]!==void 0?{buildCommand:e["build-command"]||null}:{},...e["start-command"]!==void 0?{startCommand:e["start-command"]||null}:{}},a={...e.name!==void 0?{name:e.name}:{},...e.description!==void 0?{description:e.description}:{},...e.branch!==void 0?{productionBranch:e.branch}:{},...Object.keys(i).length>0?{config:i}:{}};if(Object.keys(a).length===0)throw new u("servers update requires at least one mutation option.");let{api:c}=await d(e.org),o=await c.request(`/servers/${encodeURIComponent(r)}`,{method:"PATCH",body:JSON.stringify(a)});return l(o,t,`Updated ${r}.`),0}async function A(n,t){let{values:e,positionals:s}=m({args:[...n],allowPositionals:!0,strict:!0,options:{...p(),yes:{type:"boolean"}}}),r=b(s,"mcp-use servers delete <id-or-slug>");if(!await y(`Delete server ${r}?`,{yes:e.yes===!0,json:t}))return 0;let{api:i}=await d(e.org);return await i.request(`/servers/${encodeURIComponent(r)}`,{method:"DELETE"}),l({deleted:r},t,`Deleted ${r}.`),0}async function I(n,t){let e=n[0];if(e==="list")return O(n.slice(1),t);if(e==="set")return R(n.slice(1),t);if(e==="unset")return q(n.slice(1),t);throw new u("Usage: mcp-use servers env <list|set|unset>")}async function O(n,t){let{values:e,positionals:s}=m({args:[...n],allowPositionals:!0,strict:!0,options:{...p(),branch:{type:"string"}}}),r=b(s,"mcp-use servers env list <server>"),{api:i}=await d(e.org),c=(await f(i,r,e.branch)).map(o=>({id:o.id,key:o.key,branch:o.branch??null,environments:o.environments??[],sensitive:o.sensitive===!0,createdAt:o.createdAt,updatedAt:o.updatedAt}));return l(c,t,c.map(o=>o.key).join(`
|
|
1
|
+
import{g as d}from"../chunk-ZELLSKD2.js";import{a as u,c as k,d as l,e as P,f as y}from"../chunk-LHNHT6HO.js";import"../chunk-ZWRDP37E.js";import{parseArgs as m}from"util";async function x(n){let t=k(n);try{let e=n[0];if(e==="list")return await $(n.slice(1),t);if(e==="get")return await E(n.slice(1),t);if(e==="update")return await C(n.slice(1),t);if(e==="delete")return await A(n.slice(1),t);if(e==="env")return await I(n.slice(1),t);throw new u("Usage: mcp-use servers <list|get|update|delete|env>")}catch(e){return P(e instanceof TypeError?new u(e.message):e,t)}}async function $(n,t){let{values:e}=m({args:[...n],allowPositionals:!1,strict:!0,options:S()}),{api:s,organizationId:r}=await d(e.org),{limit:i,skip:a}=N(e.limit,e.skip),c=new URLSearchParams({organizationId:r,limit:String(i),skip:String(a)}),o=await s.request(`/servers?${c}`);return l(o,t),0}async function E(n,t){let{values:e,positionals:s}=m({args:[...n],allowPositionals:!0,strict:!0,options:p()}),r=b(s,"mcp-use servers get <id-or-slug>"),{api:i}=await d(e.org),a=await i.request(`/servers/${encodeURIComponent(r)}`);return l(a,t),0}async function C(n,t){let{values:e,positionals:s}=m({args:[...n],allowPositionals:!0,strict:!0,options:{...p(),name:{type:"string"},description:{type:"string"},branch:{type:"string"},"root-dir":{type:"string"},"build-command":{type:"string"},"start-command":{type:"string"}}}),r=b(s,"mcp-use servers update <id-or-slug>"),i={...e["root-dir"]!==void 0?{rootDir:e["root-dir"]||null}:{},...e["build-command"]!==void 0?{buildCommand:e["build-command"]||null}:{},...e["start-command"]!==void 0?{startCommand:e["start-command"]||null}:{}},a={...e.name!==void 0?{name:e.name}:{},...e.description!==void 0?{description:e.description}:{},...e.branch!==void 0?{productionBranch:e.branch}:{},...Object.keys(i).length>0?{config:i}:{}};if(Object.keys(a).length===0)throw new u("servers update requires at least one mutation option.");let{api:c}=await d(e.org),o=await c.request(`/servers/${encodeURIComponent(r)}`,{method:"PATCH",body:JSON.stringify(a)});return l(o,t,`Updated ${r}.`),0}async function A(n,t){let{values:e,positionals:s}=m({args:[...n],allowPositionals:!0,strict:!0,options:{...p(),yes:{type:"boolean"}}}),r=b(s,"mcp-use servers delete <id-or-slug>");if(!await y(`Delete server ${r}?`,{yes:e.yes===!0,json:t}))return 0;let{api:i}=await d(e.org);return await i.request(`/servers/${encodeURIComponent(r)}`,{method:"DELETE"}),l({deleted:r},t,`Deleted ${r}.`),0}async function I(n,t){let e=n[0];if(e==="list")return O(n.slice(1),t);if(e==="set")return R(n.slice(1),t);if(e==="unset")return q(n.slice(1),t);throw new u("Usage: mcp-use servers env <list|set|unset>")}async function O(n,t){let{values:e,positionals:s}=m({args:[...n],allowPositionals:!0,strict:!0,options:{...p(),branch:{type:"string"}}}),r=b(s,"mcp-use servers env list <server>"),{api:i}=await d(e.org),c=(await f(i,r,e.branch)).map(o=>({id:o.id,key:o.key,branch:o.branch??null,environments:o.environments??[],sensitive:o.sensitive===!0,createdAt:o.createdAt,updatedAt:o.updatedAt}));return l(c,t,c.map(o=>o.key).join(`
|
|
2
2
|
`)||"No environment variables."),0}async function R(n,t){let{values:e,positionals:s}=m({args:[...n],allowPositionals:!0,strict:!0,options:{...p(),branch:{type:"string"},secret:{type:"boolean"}}});if(s.length!==2)throw new u("Usage: mcp-use servers env set <server> <KEY=VALUE>");let[r,i]=s,a=i.indexOf("=");if(a<=0)throw new u("Environment value must be KEY=VALUE.");let c=i.slice(0,a),o=i.slice(a+1),{api:g}=await d(e.org),v=(await f(g,r,e.branch)).find(h=>h.key===c&&(h.branch??void 0)===e.branch),w={key:c,value:o,branch:e.branch??null,environments:e.branch===void 0?["production"]:["preview"],sensitive:e.secret===!0},U=v===void 0?await g.request(`/servers/${encodeURIComponent(r)}/env-variables`,{method:"POST",body:JSON.stringify(w)}):await g.request(`/servers/${encodeURIComponent(r)}/env-variables/${encodeURIComponent(v.id)}`,{method:"PATCH",body:JSON.stringify(w)});return l(U,t,`Set ${c}.`),0}async function q(n,t){let{values:e,positionals:s}=m({args:[...n],allowPositionals:!0,strict:!0,options:{...p(),branch:{type:"string"},yes:{type:"boolean"}}});if(s.length!==2)throw new u("Usage: mcp-use servers env unset <server> <key>");let[r,i]=s;if(!await y(`Delete environment variable ${i}?`,{yes:e.yes===!0,json:t}))return 0;let{api:a}=await d(e.org),o=(await f(a,r,e.branch)).find(g=>g.key===i&&(g.branch??void 0)===e.branch);return o!==void 0&&await a.request(`/servers/${encodeURIComponent(r)}/env-variables/${encodeURIComponent(o.id)}`,{method:"DELETE"}),l({deleted:i},t,`Deleted ${i}.`),0}async function f(n,t,e){let s=e===void 0?"":`?branch=${encodeURIComponent(e)}`;return n.request(`/servers/${encodeURIComponent(t)}/env-variables${s}`)}function p(){return{org:{type:"string"},json:{type:"boolean"}}}function S(){return{...p(),limit:{type:"string",default:"30"},skip:{type:"string",default:"0"}}}function b(n,t){if(n.length!==1)throw new u(`Usage: ${t}`);return n[0]}function N(n,t){let e=Number(n??"30"),s=Number(t??"0");if(!Number.isInteger(e)||e<1||e>100)throw new u("--limit must be an integer from 1 to 100.");if(!Number.isInteger(s)||s<0)throw new u("--skip must be a non-negative integer.");return{limit:e,skip:s}}export{x as runServers};
|
package/dist/commands/skills.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
+
import{a as o,d,e as u,h as m}from"../chunk-LHNHT6HO.js";import"../chunk-ZWRDP37E.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};
|
package/dist/commands/start.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as b}from"../chunk-N7BU45K6.js";import{b as h,c as w}from"../chunk-JAFV3QGS.js";import{c as y}from"../chunk-7G4TXPP4.js";import{readFile as I}from"fs/promises";import{join as p}from"path";import{pathToFileURL as v}from"url";var k=".mcp-use",M="build",x="manifest.json";async function N(t){let e=p(t.cwd,k,M),r=p(e,x),a;try{a=await I(r,"utf8")}catch{throw new Error(`No production build found (missing ${r}).
|
|
1
|
+
import{a as b}from"../chunk-N7BU45K6.js";import{b as h,c as w}from"../chunk-JAFV3QGS.js";import{c as y}from"../chunk-7G4TXPP4.js";import"../chunk-ZWRDP37E.js";import{readFile as I}from"fs/promises";import{join as p}from"path";import{pathToFileURL as v}from"url";var k=".mcp-use",M="build",x="manifest.json";async function N(t){let e=p(t.cwd,k,M),r=p(e,x),a;try{a=await I(r,"utf8")}catch{throw new Error(`No production build found (missing ${r}).
|
|
2
2
|
Run \`mcp-use build\` first, then \`mcp-use start\`.`)}let s;try{let o=JSON.parse(a);if(typeof o.entryPoint!="string"||o.entryPoint==="")throw new Error("missing entryPoint");s=o.entryPoint}catch(o){let E=o instanceof Error?o.message:String(o);throw new Error(`Invalid build manifest at ${r} (${E}).
|
|
3
3
|
Re-run \`mcp-use build\`.`)}process.env.NODE_ENV??="production",y(t.cwd,"production");let i=p(e,s),u=await import(v(i).href);if(!("default"in u)||u.default===void 0)throw new Error(`The built entry (${i}) has no default export.
|
|
4
4
|
The server entry must \`export default\` its MCPServer instance (see the mcp-use entry contract).`);let n=u.default;if(!R(n))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 P=typeof n.port=="number"?n.port:void 0,S=typeof n.host=="string"?n.host:void 0,l=h(t.port,process.env,P),f=w(t.host,process.env,S),c=await(t.withInspector===!0?L(n,l,f):n.listen(l,{host:f})),m=typeof c?.port=="number"?c.port:l,g=typeof c?.url=="string"?c.url:`http://localhost:${m}`;return{port:m,url:g,close:async()=>{await n.close?.()}}}async function L(t,e,r){let{mountInspector:a}=await O(),s=typeof t.basePath=="string"?t.basePath:"/mcp",i=a({basePath:s,devMode:!1,oauthProxyAllowLoopback:!1});return t.listen(e,{host:r,routes:[{match:d=>b(d,s),handler:i}]})}async function O(){let t;try{t=await import("@mcp-use/inspector")}catch(e){throw _(e)?new Error("Built-in Inspector is unavailable; reinstall mcp-use to restore it."):e}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 R(t){return typeof t=="object"&&t!==null&&typeof t.listen=="function"}function _(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};
|