@mcp-use/cli 4.0.0-beta.1 → 4.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +37 -0
- package/dist/chunk-33YPDBCS.js +4 -0
- package/dist/chunk-7G4TXPP4.js +1 -0
- package/dist/chunk-JAFV3QGS.js +1 -0
- package/dist/chunk-LHNHT6HO.js +8 -0
- package/dist/chunk-N6R74JIF.js +33 -0
- package/dist/chunk-N7BU45K6.js +1 -0
- package/dist/chunk-ZELLSKD2.js +1 -0
- package/dist/commands/build.js +5 -0
- package/dist/commands/client.js +1 -0
- package/dist/commands/deploy.js +1 -0
- package/dist/commands/deployments.js +6 -0
- package/dist/commands/dev.js +2 -0
- package/dist/commands/identity.js +2 -0
- package/dist/commands/organizations.js +2 -0
- package/dist/commands/screenshot.js +5 -0
- package/dist/commands/servers.js +2 -0
- package/dist/commands/skills.js +1 -0
- package/dist/commands/start.js +4 -0
- package/dist/next-server-shims.js +1 -0
- package/dist/node-bridge-JJIA6K5P.js +1 -0
- package/package.json +30 -8
- package/types/index.d.ts +1 -0
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -10
package/dist/bin.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as i}from"./chunk-JAFV3QGS.js";import{readFileSync as l}from"fs";import{resolve as c}from"path";var r=`mcp-use \u2014 run MCP servers built with mcp-use
|
|
3
|
+
|
|
4
|
+
Usage: mcp-use <command> [options]
|
|
5
|
+
|
|
6
|
+
Commands:
|
|
7
|
+
dev Start the dev server
|
|
8
|
+
build Build the server into .mcp-use/build
|
|
9
|
+
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 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
|
+
--with-inspector Mount Inspector on the production listener (start only)
|
|
31
|
+
--tunnel Expose the dev server through a public tunnel (dev only)
|
|
32
|
+
--no-open Do not auto-open the inspector in a browser (dev only)
|
|
33
|
+
--no-inspector Start dev without loading the optional Inspector
|
|
34
|
+
-h, --help Show this help
|
|
35
|
+
-v, --version Print the version`;async function u(t){if(t.length===1&&["--version","-v"].includes(t[0]??""))return console.log(s()),0;if(t.some(e=>e==="--help"||e==="-h")){let e=t[0];if(e===void 0||e==="--help"||e==="-h")return console.log(r),0}let n=t[0];if(n==="login"||n==="logout"||n==="whoami"){let{runIdentity:e}=await import("./commands/identity.js");return e(n,t.slice(1))}if(n==="org"){let{runOrganizations:e}=await import("./commands/organizations.js");return e(t.slice(1))}if(n==="servers"){let{runServers:e}=await import("./commands/servers.js");return e(t.slice(1))}if(n==="deployments"){let{runDeployments:e}=await import("./commands/deployments.js");return e(t.slice(1))}if(n==="deploy"){let{runDeploy:e}=await import("./commands/deploy.js");return e(t.slice(1))}if(n==="client"){let{runClient:e}=await import("./commands/client.js");return e(t.slice(1))}if(n==="skills"){let{runSkills:e}=await import("./commands/skills.js");return e(t.slice(1))}if(n==="screenshot"){let{runScreenshot:e}=await import("./commands/screenshot.js");return e(t.slice(1))}let o;try{o=i(t)}catch(e){return console.error(e instanceof Error?e.message:String(e)),2}if(o.version)return console.log(s()),0;if(o.help)return console.log(r),0;switch(o.command){case"start":return a(o);case"dev":case"build":return d(o.command,o);case void 0:return console.error(r),2;default:return console.error(`Unknown command: ${o.command}
|
|
36
|
+
|
|
37
|
+
${r}`),2}}async function a(t){let n;try{let{runStart:e}=await import("./commands/start.js");n=await e({cwd:c(process.cwd(),t.path??"."),port:t.port,host:t.host,...t.withInspector&&{withInspector:!0}})}catch(e){return console.error(e instanceof Error?e.message:String(e)),1}console.log(`mcp-use server running at ${n.url}`);let o=()=>{n.close().then(()=>process.exit(0),e=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)})};return process.once("SIGINT",o),process.once("SIGTERM",o),0}async function d(t,n){let o={cwd:c(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&&{inspector:!1},...n.sourceMaps&&{sourceMaps:!0},...n.inline&&{inline:!0}};try{if(t==="dev"){let{runDev:e}=await import("./commands/dev.js");await e(o)}else{let{runBuild:e}=await import("./commands/build.js");await e(o)}return 0}catch(e){return console.error(e instanceof Error?e.message:String(e)),1}}function s(){return"2.0.0-beta.25"}u(process.argv.slice(2)).then(t=>{process.exitCode=t},t=>{console.error(t instanceof Error?t.message:String(t)),process.exitCode=1});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as p,b as f,d as l}from"./chunk-7G4TXPP4.js";import{existsSync as m}from"fs";import{isAbsolute as x,join as h,resolve as V}from"path";var d=["src/index.ts","src/index.tsx","src/server.ts","src/server.tsx","index.ts","index.tsx","server.ts","server.tsx"];function B(r,t){if(t!==void 0){let e=x(t)?t:V(r,t);if(!m(e))throw new Error(`Entry not found: ${e} (from --entry "${t}")`);return e}for(let e of d){let n=h(r,e);if(m(n))return n}throw new Error(`No server entry found in ${r}. Looked for: ${d.join(", ")}. Create one of these (default-exporting your MCPServer instance) or pass --entry <path>.`)}import{existsSync as y}from"fs";import{join as E}from"path";import{fileURLToPath as I}from"url";var D=["vite.config.ts","vite.config.js","vite.config.mts","vite.config.cjs"];function q(r){for(let t of D){let e=E(r,t);if(y(e))return e}return!1}function z(){return I(import.meta.resolve("tailwindcss/index.css"))}import{writeFile as P}from"fs/promises";import{extname as _,join as S,relative as R,sep as A}from"path";var j="mcp-env.d.ts";function M(r,t){let e=R(r,t).split(A).join("/"),n=_(e),i=n===".mts"?".mjs":n===".cts"?".cjs":n===".ts"||n===".tsx"?".js":n;return n!==i&&(e=`${e.slice(0,-n.length)}${i}`),e.startsWith(".")?e:`./${e}`}function $(r,t){let e=M(r,t);return["// mcp-use generated env declaration",'declare module "*.css";',"",'declare module "mcp-use/react" {'," interface Register {",` tools: typeof import(${JSON.stringify(e)});`," }","}","","export {};",""].join(`
|
|
2
|
+
`)}async function tt(r,t){let e=S(r,j);try{return await P(e,$(r,t),{encoding:"utf8",flag:"wx"}),!0}catch(n){if(n!==null&&typeof n=="object"&&"code"in n&&n.code==="EEXIST")return!1;throw n}}import{join as s}from"path";var T=".mcp-use",b="manifest.json";function nt(r){let t=s(r,T),e=s(t,"build");return{projectRoot:r,workspace:t,build:e,generated:s(t,"generated"),cache:s(t,"cache"),state:s(t,"state"),cloud:s(t,"cloud"),buildManifest:s(e,b),tunnel:s(t,"state","tunnel.json")}}import{existsSync as g,readdirSync as L}from"fs";import{isAbsolute as N,join as W,resolve as C}from"path";var O="views",a="virtual:mcp-use/views/",c=`\0${a}`;function v(r,t){let e=t??O;return N(e)?e:C(r,e)}function ct(r,t){let e=v(r,t);if(!g(e))return[];let n=[];for(let i of L(e,{withFileTypes:!0})){if(!i.isDirectory())continue;let o=W(e,i.name,"view.tsx");g(o)&&n.push({name:i.name,entryPath:o})}return n.sort((i,o)=>i.name.localeCompare(o.name)),n}function U(r){return`${a}${r}`}function k(r){return`/@id/__x00__${a}${r}`}function ut(r,t,e){let n=v(t,e);return r===n||r.startsWith(`${n}/`)}function pt(r){let t={};for(let e of r)t[e.name]={kind:"external",entry:k(e.name),css:[],scripts:["/@vite/client"]};return t}async function ft(r,t,e){let{createServer:n}=await import("vite");return n({root:r,configFile:e,envDir:!1,logLevel:"warn",cacheDir:t,resolve:{tsconfigPaths:!0,alias:p(r)},plugins:[l(r)],server:{middlewareMode:!0,hmr:!1},ssr:{...f(r)}})}var u="virtual:mcp-use/tailwind.css",w=`\0${u}`;function dt(r){return{name:"mcp-use-views",applyToEnvironment(t){return t.name==="client"},resolveId(t){if(t===u)return w;if(t.startsWith(a))return`\0${t}`},load(t){if(t===w)return['@import "tailwindcss";',"@custom-variant dark (&:where(.dark, .dark *, [data-theme=dark], [data-theme=dark] *));"].join(`
|
|
3
|
+
`);if(!t.startsWith(c))return;let e=t.slice(c.length),n=r.getViews().find(o=>o.name===e);if(n===void 0)return;let i=[];return r.dev?.reactRefresh===!0&&i.push('import "@vitejs/plugin-react/preamble";'),i.push(`import ${JSON.stringify(u)};`),i.push('import { bootstrapView } from "mcp-use/react";',`import * as viewModule from ${JSON.stringify(n.entryPath)};`,"bootstrapView(viewModule);"),r.dev!==void 0&&i.push("if (import.meta.hot) {"," import.meta.hot.accept();","}"),i.push(""),i.join(`
|
|
4
|
+
`)}}}export{B as a,q as b,z as c,tt as d,nt as e,ct as f,U as g,ut as h,pt as i,ft as j,dt as k};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync as p,readFileSync as d}from"fs";import{join as a}from"path";import{fileURLToPath as c}from"url";var i=new Set(["server-only","client-only","next/cache","next/headers","next/navigation","next/server"]);function x(e){let n=c(new URL("./next-server-shims.js",import.meta.url));return r(e)?[...i].map(t=>({find:t,replacement:n})):[]}function v(e){return r(e)?{noExternal:[...i]}:{external:!0}}function r(e){try{let n=JSON.parse(d(a(e,"package.json"),"utf8"));return n.dependencies?.next!==void 0||n.devDependencies?.next!==void 0}catch{return!1}}function g(e,n){let t=r(e)?[`.env.${n}.local`,".env.local",`.env.${n}`,".env"]:[".env"];for(let o of t){let s=a(e,o);p(s)&&process.loadEnvFile(s)}}function h(e){let n=r(e),t=c(new URL("./next-server-shims.js",import.meta.url));return{name:"mcp-use-next-standalone-compat",enforce:"pre",resolveId(o,s,l){return n&&l.ssr&&i.has(o)?{id:t,external:!1}:void 0}}}export{x as a,v as b,g as c,h as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f="127.0.0.1";function u(n,e,t=process.env){if(n!==void 0)return n;let r=t.HOST?.trim();return r!==void 0&&r!==""?r:e??f}function a(n,e,t=process.env){if(n!==void 0)return n;let r=c(t.PORT);return r!==void 0?r:e??3e3}function c(n){if(n===void 0||n.trim()==="")return;let e=Number(n);return Number.isInteger(e)&&e>=0&&e<=65535?e:void 0}function m(n){let e={command:void 0,port:void 0,entry:void 0,path:void 0,mcpDir:void 0,viewsDir:void 0,host:void 0,tunnel:!1,open:!0,inspector:!0,withInspector:!1,sourceMaps:!1,inline:!1,help:!1,version:!1};for(let t=0;t<n.length;t++){let r=n[t];if(r===void 0)continue;let i=r,d;if(r.startsWith("--")){let s=r.indexOf("=");s!==-1&&(i=r.slice(0,s),d=r.slice(s+1))}let o=()=>{if(d!==void 0)return d;let s=n[++t];if(s===void 0||s.startsWith("-"))throw new Error(`Missing value for ${i}`);return s};switch(i){case"-h":case"--help":e.help=!0;break;case"-v":case"--version":e.version=!0;break;case"-p":case"--port":e.port=p(o());break;case"--entry":e.entry=o();break;case"--path":e.path=o();break;case"--mcp-dir":e.mcpDir=o();break;case"--views-dir":e.viewsDir=o();break;case"--host":e.host=o();break;case"--tunnel":e.tunnel=!0;break;case"--no-open":e.open=!1;break;case"--no-inspector":e.inspector=!1;break;case"--with-inspector":e.withInspector=!0;break;case"--source-maps":e.sourceMaps=!0;break;case"--inline":e.inline=!0;break;default:if(i.startsWith("-"))throw new Error(`Unknown option: ${i}`);if(e.command!==void 0)throw new Error(`Unexpected argument: ${i}`);e.command=i}}return e}function h(n,e=process.env,t){return a(n,t,e)}function v(n,e=process.env,t){return u(n,t,e)}function p(n){let e=Number(n);if(!l(e))throw new Error(`Invalid port: ${n}`);return e}function l(n){return Number.isInteger(n)&&n>=0&&n<=65535}export{m as a,h as b,v as c};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{spawn as p}from"child_process";import{constants as u}from"fs";import{access as f,chmod as a,mkdir as m,readFile as l,rename as w,rm as g,writeFile as y}from"fs/promises";import{homedir as x}from"os";import{dirname as $,join as c}from"path";import{createInterface as E}from"readline/promises";var r=class extends Error{exitCode=2},s=class extends Error{code;details;constructor(n,e,o){super(e),this.code=n,this.details=o}};function P(t){return t.includes("--json")}function h(t,n,e){n?process.stdout.write(`${JSON.stringify(t)}
|
|
2
|
+
`):e!==void 0?process.stdout.write(`${e}
|
|
3
|
+
`):typeof t=="string"?process.stdout.write(`${t}
|
|
4
|
+
`):process.stdout.write(`${JSON.stringify(t,null,2)}
|
|
5
|
+
`)}function k(t,n){let e=t instanceof r,o=t instanceof s,d=o?t.code:e?"usage_error":"command_failed",i=t instanceof Error?t.message:String(t);return n?process.stderr.write(`${JSON.stringify({error:{code:d,message:i,...o&&t.details!==void 0?{details:t.details}:{}}})}
|
|
6
|
+
`):process.stderr.write(`${i}
|
|
7
|
+
`),e?2:1}async function _(t,n){if(n.yes)return!0;if(n.json||!process.stdin.isTTY)throw new r(`${t} Pass --yes to confirm.`);let e=E({input:process.stdin,output:process.stdout});try{return(await e.question(`${t} [y/N] `)).trim().toLowerCase()==="y"}finally{e.close()}}function v(t){let[n,e]=process.platform==="darwin"?["open",[t]]:process.platform==="win32"?["cmd",["/c","start","",t]]:["xdg-open",[t]];try{let o=p(n,e,{detached:!0,stdio:"ignore"});o.on("error",()=>{}),o.unref()}catch{}}async function j(t){try{return await f(t,u.F_OK),!0}catch{return!1}}async function F(t,n){try{return JSON.parse(await l(t,"utf8"))}catch(e){if(e.code==="ENOENT")return n;throw new s("invalid_state",`Could not read ${t}.`,{cause:e instanceof Error?e.message:String(e)})}}async function I(t,n){let e=$(t);await m(e,{recursive:!0,mode:448}),await a(e,448);let o=c(e,`.${t.slice(t.lastIndexOf("/")+1)}.${process.pid}.${Date.now()}.tmp`);await y(o,`${JSON.stringify(n,null,2)}
|
|
8
|
+
`,{mode:384}),await w(o,t),await a(t,384)}async function L(t){await g(t,{force:!0})}var A=c(x(),".mcp-use");export{r as a,s as b,P as c,h as d,k as e,_ as f,v as g,j as h,F as i,I as j,L as k,A as l};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import{a,b as E,c as L,d as p,e as N,f as S,g as U,h,i as k,j as w,l as R}from"./chunk-LHNHT6HO.js";import{createHash as ie}from"crypto";import{rm as J}from"fs/promises";import{join as P}from"path";import{parseArgs as b}from"util";import{spawn as K}from"child_process";import{readFileSync as W}from"fs";import{chmod as z,mkdir as q}from"fs/promises";import{dirname as V,join as y,resolve as Y}from"path";import{pathToFileURL as M}from"url";var g=y(R,"client-sdk"),m="@mcp-use/client",Z="^2.0.0-alpha.0",Q=[`[mcp-use] ${m} is not installed.`,"The `mcp-use client` and `mcp-use screenshot` commands require it.","Install it in your project:",""," npm install @mcp-use/client",""," pnpm add @mcp-use/client",""," bun add @mcp-use/client"].join(`
|
|
2
|
+
`);async function X(e){let n=Y(e);for(;;){if(await h(y(n,"package.json")))return n;let t=V(n);if(t===n)return;n=t}}async function D(){try{return await oe()}catch(e){if(!j(e))throw e;let n=await ee();try{return n.location==="sandbox"?await se():await re(n.projectRoot)}catch(t){throw j(t)?new a(Q):t}}}async function ee(){let e=ne(),n=`${m}@${e}`,t=await X(process.cwd());if(process.stderr.write(`[mcp-use] installing ${m}\u2026
|
|
3
|
+
`),t!==void 0){let[s,c]=te(n);if(await I(s,c,t)!==0)throw new E("client_install_failed",`Failed to install ${m}.`);return{location:"project",projectRoot:t}}await q(g,{recursive:!0,mode:448}),await z(g,448);let r=y(g,"package.json");if(await h(r)||await w(r,{private:!0,dependencies:{[m]:e}}),await I("npm",["install",n],g)!==0)throw new E("client_install_failed",`Failed to install ${m}.`);return{location:"sandbox"}}function te(e){let n=process.env.npm_config_user_agent??"";return n.startsWith("pnpm/")?["pnpm",["add",e]]:n.startsWith("bun/")?["bun",["add",e]]:["npm",["install",e]]}function ne(){for(let e of["../package.json","../../package.json"])try{let n=W(new URL(e,import.meta.url),"utf8"),t=JSON.parse(n);if(t.name!=="mcp-use")continue;let r=t.peerDependencies?.[m];if(typeof r=="string"&&r.length>0)return r}catch{}return Z}async function oe(){return import("@mcp-use/client")}async function re(e){let n=M(y(e,"package.json")).href;return import(await import.meta.resolve(m,n))}async function se(){let e=y(g,"node_modules",m,"dist","index.js");return await import(M(e).href)}function j(e){if(!(e instanceof Error))return!1;let n=e.code;return n==="ERR_MODULE_NOT_FOUND"||n==="MODULE_NOT_FOUND"?e.message.includes(m)||e.message.includes("Cannot find package"):!1}function I(e,n,t){return new Promise((r,o)=>{let s=K(e,n,{cwd:t,stdio:"inherit",shell:process.platform==="win32"});s.once("error",o),s.once("exit",(c,u)=>{r(u==="SIGINT"?130:c??1)})})}var B=P(R,"client"),_=P(B,"servers.json"),ae=`Usage: mcp-use client <command> [options]
|
|
4
|
+
|
|
5
|
+
Commands:
|
|
6
|
+
connect <name> <url> Connect and save an HTTP(S) MCP server
|
|
7
|
+
list List saved servers
|
|
8
|
+
remove <name> Remove a saved server
|
|
9
|
+
<name> Invoke tools/resources/prompts on a saved server
|
|
10
|
+
|
|
11
|
+
Connect options:
|
|
12
|
+
-H, --header <"Key: Value"> Static header (repeatable)
|
|
13
|
+
--no-oauth Skip OAuth on authorization challenges
|
|
14
|
+
--auth-timeout <ms> OAuth wait timeout (default: 300000)
|
|
15
|
+
--protocol <auto|2026-07-28|2025-11-25>
|
|
16
|
+
--open Open the OAuth URL in a browser without prompting
|
|
17
|
+
--no-open Print the OAuth URL only
|
|
18
|
+
--json Emit machine-readable output
|
|
19
|
+
|
|
20
|
+
Saved server commands:
|
|
21
|
+
mcp-use client <name> tools list|describe|call ...
|
|
22
|
+
mcp-use client <name> resources list|read ...
|
|
23
|
+
mcp-use client <name> prompts list|get ...
|
|
24
|
+
mcp-use client <name> auth status|logout
|
|
25
|
+
|
|
26
|
+
Examples:
|
|
27
|
+
mcp-use client connect linear https://mcp.linear.app/mcp
|
|
28
|
+
mcp-use client linear tools list
|
|
29
|
+
mcp-use client linear tools call search_issues query="open bugs"`;async function _e(e){if(e.includes("--help")||e.includes("-h"))return console.log(ae),0;let n=L(e);try{let t=e[0];if(t==="connect")return await ce(e.slice(1),n);if(t==="list")return await le(e.slice(1),n);if(t==="remove")return await ue(e.slice(1),n);if(t===void 0)throw new a("Usage: mcp-use client <connect|list|remove|name>");return await pe(t,e.slice(1),n)}catch(t){return N(t instanceof TypeError?new a(t.message):t,n)}}async function ce(e,n){let{values:t,positionals:r}=b({args:[...e],allowPositionals:!0,strict:!0,options:{header:{type:"string",short:"H",multiple:!0},"no-oauth":{type:"boolean"},"auth-timeout":{type:"string"},protocol:{type:"string",default:"auto"},open:{type:"boolean"},"no-open":{type:"boolean"},json:{type:"boolean"}}});if(t.open===!0&&t["no-open"]===!0)throw new a("Cannot combine --open and --no-open.");if(r.length!==2)throw new a("Usage: mcp-use client connect <name> <url>");let[o,s]=r;he(o);let c=new URL(s);if(!["http:","https:"].includes(c.protocol))throw new a("Client URLs must use http or https.");let u=we(t.protocol),l=F(t["auth-timeout"]??"300000","--auth-timeout"),i=await C();if(i.servers[o]!==void 0)throw new a(`Saved server already exists: ${o}`);let d={headers:fe(t.header??[])},f={url:c.href,oauth:t["no-oauth"]!==!0,protocol:u};return await(await $(o,f,d,l,me({open:t.open===!0,noOpen:t["no-open"]===!0,json:n}))).disconnect(),i.servers[o]=f,await w(_,i),await w(x(o),d),p({name:o,url:f.url,protocol:u},n,`Connected and saved ${o}.`),0}async function le(e,n){v(e);let t=await C(),r=Object.entries(t.servers).map(([o,s])=>({name:o,...s}));return p(r,n,r.map(o=>`${o.name} ${o.url}`).join(`
|
|
30
|
+
`)||"No saved servers."),0}async function ue(e,n){let{values:t,positionals:r}=b({args:[...e],allowPositionals:!0,strict:!0,options:{yes:{type:"boolean"},json:{type:"boolean"}}}),o=T(r,"mcp-use client remove <name>");if(!await S(`Remove saved server ${o}?`,{yes:t.yes===!0,json:n}))return 0;let s=await C();return delete s.servers[o],await w(_,s),await J(A(o),{recursive:!0,force:!0}),p({removed:o},n,`Removed ${o}.`),0}async function pe(e,n,t){let o=(await C()).servers[e];if(o===void 0)throw new a(`Unknown saved server: ${e}. Run \`mcp-use client connect ${e} <url>\`.`);let s=n[0],c=n[1];if(s==="auth"){if(c==="status"){v(n.slice(2));let i=await h(O(e));return p({name:e,oauth:o.oauth,authenticated:i},t,i?"Authenticated.":"No saved OAuth session."),0}if(c==="logout"){let{values:i,positionals:d}=b({args:[...n.slice(2)],allowPositionals:!0,strict:!0,options:{yes:{type:"boolean"},json:{type:"boolean"}}});if(d.length!==0)throw new a(`Usage: mcp-use client ${e} auth logout`);return await S(`Delete OAuth credentials for ${e}?`,{yes:i.yes===!0,json:t})&&(await J(O(e),{recursive:!0,force:!0}),p({loggedOut:e},t,`Logged out ${e}.`)),0}}let u=await k(x(e),{}),l=await $(e,o,u,3e5);try{if(s==="tools"){if(c==="list"){v(n.slice(2));let i=await l.listTools();return p(i,t,i.map(d=>`${d.name} ${d.description??""}`).join(`
|
|
31
|
+
`)),0}if(c==="describe"){let i=T(n.slice(2),`mcp-use client ${e} tools describe <tool>`),d=(await l.listTools()).find(f=>f.name===i);if(d===void 0)throw new a(`Tool not found: ${i}`);return p(d,t),0}if(c==="call")return await de(l,e,n.slice(2),t)}if(s==="resources"){if(c==="list"){v(n.slice(2));let i=await l.listResources();return p(i,t),0}if(c==="read"){let i=T(n.slice(2),`mcp-use client ${e} resources read <uri>`);return p(await l.readResource(i),t),0}}if(s==="prompts"){if(c==="list")return v(n.slice(2)),p(await l.listPrompts(),t),0;if(c==="get"){let i=n[2];if(i===void 0)throw new a(`Usage: mcp-use client ${e} prompts get <prompt> [args]`);return p(await l.getPrompt(i,H(n.slice(3))),t),0}}throw new a(`Usage: mcp-use client ${e} <tools|resources|prompts|auth> ...`)}finally{await l.disconnect()}}async function de(e,n,t,r){let o=t[0];if(o===void 0)throw new a(`Usage: mcp-use client ${n} tools call <tool> [args]`);let{values:s,positionals:c}=b({args:[...t.slice(1)],allowPositionals:!0,strict:!0,options:{timeout:{type:"string",default:"30000"},json:{type:"boolean"}}}),u=F(s.timeout,"--timeout"),l=await e.callTool(o,H(c),{timeout:u});if(l.isError===!0)throw new Error(`Tool ${o} returned an error: ${JSON.stringify(l)}`);return p(l,r),0}async function $(e,n,t,r,o=process.stdin.isTTY?"ask":"never"){let{createOAuthProvider:s,MCPClient:c}=await D(),u=O(e),l=n.oauth?await s(n.url,{baseDir:u,authTimeoutMs:r,storageKeyPrefix:`mcp-use-cli:${e}`,openBrowser:async f=>{process.stderr.write(`Open this URL to authenticate:
|
|
32
|
+
${f}
|
|
33
|
+
`),o!=="never"&&(o==="ask"&&!await S("Open in browser?",{yes:!1,json:!1})||U(f))}}):void 0,i=n.protocol==="auto"?"auto":{pin:n.protocol};return new c({mcpServers:{[e]:{url:n.url,...t.headers!==void 0?{headers:t.headers}:{},...l!==void 0?{authProvider:l}:{oauth:!1},protocolNegotiation:i}}}).connect(e)}async function Ae(e,n=3e5){let r=(await C()).servers[e];if(r===void 0)throw new a(`Unknown saved server: ${e}`);let o=await k(x(e),{});return $(e,r,o,n)}async function xe(e,n){return $("screenshot",{url:e,oauth:!1,protocol:"auto"},{headers:n},3e5)}function H(e){if(e.length===0)return{};if(e.length===1&&e[0]?.trimStart().startsWith("{")){let t=JSON.parse(e[0]);if(t===null||Array.isArray(t)||typeof t!="object")throw new a("The JSON argument must be an object.");return t}let n={};for(let t of e){let r=t.indexOf(":="),o=t.indexOf("="),s=r>=0?r:o,c=r>=0?2:1;if(s<=0)throw new a(`Expected key=value or key:=<json>, received: ${t}`);let u=t.slice(0,s).replace(/^--/,""),l=t.slice(s+c);n[u]=r>=0?JSON.parse(l):l}return n}function me(e){return e.json||e.noOpen||!process.stdin.isTTY?"never":e.open?"always":"ask"}function fe(e){let n={};for(let t of e){let r=t.indexOf(":");if(r<=0)throw new a(`Invalid header: ${t}`);n[t.slice(0,r).trim()]=t.slice(r+1).trim()}return n}function we(e){if(e!=="auto"&&e!=="2026-07-28"&&e!=="2025-11-25")throw new a(`Invalid protocol: ${e}`);return e}function F(e,n){let t=Number(e);if(!Number.isInteger(t)||t<=0)throw new a(`${n} must be a positive integer.`);return t}function he(e){if(!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(e))throw new a("Server names must be 1-64 filesystem-safe letters, numbers, dots, dashes, or underscores.")}async function C(){return k(_,{servers:{}})}function A(e){return P(B,"credentials",ie("sha256").update(e).digest("hex"))}function x(e){return P(A(e),"credentials.json")}function O(e){return P(A(e),"oauth")}function v(e){b({args:[...e],allowPositionals:!1,strict:!0,options:{json:{type:"boolean"}}})}function T(e,n){if(e.length!==1)throw new a(`Usage: ${n}`);return e[0]}export{_e as a,Ae as b,xe as c,H as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function s(t,n){return r(new URL(t.url).pathname,n)}function r(t,n){let e=`${n}/inspector`;return t===e||t.startsWith(`${e}/`)}export{s as a,r as b};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as $,b as B,c as P,d as U,e as V,f as L,g as F,j as _,k as C}from"../chunk-33YPDBCS.js";import{a as b,b as M,c as E,d as x}from"../chunk-7G4TXPP4.js";import{randomBytes as H}from"crypto";import{existsSync as X}from"fs";import{cp as Z,mkdir as v,rm as ee,writeFile as A}from"fs/promises";import{join as f,relative as y,resolve as te}from"path";import re from"@tailwindcss/vite";import ne from"@vitejs/plugin-react";import{build as D}from"vite";import{createServerModuleRunner as N}from"vite";var G="/mcp",K="http://localhost:3000";async function j(e,t){let i=N(e,{hmr:!1,sourcemapInterceptor:"node"}),n=process.env.MCP_URL;try{n===void 0&&(process.env.MCP_URL=K);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??G}finally{n===void 0?delete process.env.MCP_URL:process.env.MCP_URL=n,await i.close()}}async function O(e,t,i){let n=N(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 Q(e){return e.replace(/\/+$/,"")}function k(e){return Q(e)}import{hostHeaderValidationResponse as ge,originValidationResponse as we}from"@modelcontextprotocol/server";function T(e,t){let i=t.replace(/^\/+/,"");return e==="/"?`/${i}`:`${e}/${i}`}function q(e,t){return`${T(e,`_mcp-use/views/${t}`)}/`}var p="index.js",ie="entry-wrapper.ts",se=100*1024*1024;async function I(e,t){let i=f(e,"public");X(i)&&await Z(i,t,{recursive:!0})}async function oe(e,t,i){let n=f(e,ie);await v(e,{recursive:!0});let r=JSON.stringify(i);return await A(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 k(new URL(e).href.replace(/\/$/,""))}catch{return}}function S(e,t,i,n){let r=e.replace(/^\/+/,"");return`${i}${q(n,t)}${r}`}function ce(e,t,i,n){return e.kind!=="external"?e:{...e,entry:S(e.entry,t,i,n),css:e.css.map(r=>S(r,t,i,n)),...e.scripts!==void 0&&{scripts:e.scripts.map(r=>S(r,t,i,n))}}}async function ue(e,t){let i=f(t.viewsOutDir,e.name),n=await D({root:t.cwd,configFile:t.userViteConfig,envDir:!1,publicDir:!1,logLevel:"warn",cacheDir:t.cacheDir,resolve:{tsconfigPaths:!0,alias:{tailwindcss:P()}},plugins:[re(),ne(),C({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]:F(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();E(e.cwd,"production");let i=e.mcpDir===void 0?e.cwd:te(e.cwd,e.mcpDir),n=e.entry===void 0?$(i):$(e.cwd,e.entry);await U(e.cwd,n)&&console.log("[mcp-use] created mcp-env.d.ts");let r=V(e.cwd),o=e.viewsDir??(e.mcpDir===void 0?void 0:f(e.mcpDir,"views")),m=L(e.cwd,o),g=B(e.cwd),u=e.sourceMaps===!0,l=e.inline===!0;if(m.length===0){await D({root:e.cwd,configFile:!1,envDir:!1,publicDir:!1,logLevel:"warn",cacheDir:r.cache,resolve:{tsconfigPaths:!0,alias:b(e.cwd)},plugins:[x(e.cwd)],build:{ssr:n,outDir:r.build,emptyOutDir:!0,target:"node22",sourcemap:u,minify:!1,rollupOptions:{output:{format:"es",entryFileNames:p}}},ssr:{...M(e.cwd),target:"node"}}),await I(e.cwd,f(r.build,"views/public"));let d={buildId:H(8).toString("hex"),entryPoint:p,createdAt:new Date().toISOString(),views:{}};await v(r.build,{recursive:!0}),await A(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 ee(r.build,{recursive:!0,force:!0});let c=f(r.build,"views");await v(c,{recursive:!0});let a=await _(e.cwd,r.cache,!1),w,s={},R=ae();try{w=await j(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});R!==void 0&&!l&&(h=ce(h,d.name,R,w)),s[d.name]=h}R!==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 I(e.cwd,f(c,"public")),await O(a.environments.ssr,n,s)}finally{await a.close()}let W=await oe(r.cache,n,s);await D({root:e.cwd,configFile:!1,envDir:!1,publicDir:!1,logLevel:"warn",cacheDir:r.cache,resolve:{tsconfigPaths:!0,alias:b(e.cwd)},plugins:[x(e.cwd)],build:{ssr:W,outDir:r.build,emptyOutDir:!1,target:"node22",sourcemap:u,minify:!1,rollupOptions:{output:{format:"es",entryFileNames:p}}},ssr:{...M(e.cwd),target:"node"}});let J={buildId:H(8).toString("hex"),entryPoint:p,createdAt:new Date().toISOString(),views:s};await v(r.build,{recursive:!0}),await A(r.buildManifest,`${JSON.stringify(J,null,2)}
|
|
5
|
+
`);let z=Math.round(performance.now()-t),Y=m.map(d=>d.name).join(", ");console.log(`[mcp-use] built ${y(e.cwd,n)} + views (${Y}) \u2192 ${y(e.cwd,r.build)}/${p} (${z}ms)`)}export{le as runBuild};
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +1,6 @@
|
|
|
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(`
|
|
2
|
+
`)?r.logs:`${r.logs}
|
|
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
|
+
`):process.stdout.write(l.logs.endsWith(`
|
|
5
|
+
`)?l.logs:`${l.logs}
|
|
6
|
+
`)),s=l.offset,r=e&&!o.has(l.status),r&&await new Promise(h=>setTimeout(h,1e3))}}function p(n,t){return w({args:[...n],allowPositionals:!0,strict:!0,options:t})}function c(n,t){if(n.length!==1)throw new a(`Usage: ${t}`);return n[0]}function f(n,t,e,i=Number.MAX_SAFE_INTEGER){let s=Number(n);if(!Number.isInteger(s)||s<e||s>i)throw new a(`${t} must be an integer from ${e} to ${i}.`);return s}export{T as runDeployments};
|
|
@@ -0,0 +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=he(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 ge=(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()},ve=pe({getBasePath:()=>h,port:p,tunnel:y},n=>R!==void 0&&Z(n,h)?R(n):I(n)),{toNodeHandler:Pe}=await import("../node-bridge-JJIA6K5P.js"),K=Pe({fetch:ve}),ye=(n,s)=>{if(a&&ge(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,be=n.method==="GET"&&(m.startsWith("/@")||m.startsWith("/node_modules/")||m.startsWith("/.mcp-use/")||X&&m.startsWith("/views/"));X&&be?(on(n,s,{tunnelActive:y.status().url!==null,localhostBind:a}),g.middlewares(n,s,()=>{K(n,s)})):K(n,s)};if(d.on("request",ye),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};
|
|
@@ -0,0 +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}.
|
|
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};
|
|
@@ -0,0 +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(`
|
|
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};
|
|
@@ -0,0 +1,5 @@
|
|
|
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=`(() => ({
|
|
2
|
+
ready: document.body?.dataset.viewReady === "true",
|
|
3
|
+
error: document.body?.dataset.viewError || null,
|
|
4
|
+
selector: ${JSON.stringify(n)} === undefined || !!document.querySelector(${JSON.stringify(n??"")})
|
|
5
|
+
}))()`,a=(await r.cdp.send("Runtime.evaluate",{expression:i,returnByValue:!0},r.sessionId)).result?.value;if(a?.error)throw new s("preview_failed",`Inspector preview failed: ${a.error}`);if(a?.ready===!0&&a.selector===!0)return;await d(100)}throw new s("browser_timeout","View did not become ready in time.")}var v=class r{#t;#n=1;#e=new Map;constructor(n){this.#t=n,n.addEventListener("message",e=>{let t=JSON.parse(String(e.data));if(t.id===void 0)return;let i=this.#e.get(t.id);i!==void 0&&(this.#e.delete(t.id),t.error!==void 0?i.reject(new Error(t.error.message??"CDP command failed.")):i.resolve(t.result))}),n.addEventListener("close",()=>{for(let e of this.#e.values())e.reject(new Error("Chrome DevTools connection closed."));this.#e.clear()})}static async connect(n){let e=new WebSocket(n);return await new Promise((t,i)=>{e.addEventListener("open",()=>t(),{once:!0}),e.addEventListener("error",()=>i(new Error("Could not connect to Chrome DevTools.")),{once:!0})}),new r(e)}send(n,e={},t){let i=this.#n++;return new Promise((o,a)=>{this.#e.set(i,{resolve:o,reject:a}),this.#t.send(JSON.stringify({id:i,method:n,params:e,...t!==void 0?{sessionId:t}:{}}))})}close(){this.#t.close()}};async function se(){let n=[process.env.MCP_USE_CHROME_PATH??process.env.PUPPETEER_EXECUTABLE_PATH??process.env.CHROME_PATH,...process.platform==="darwin"?["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Chromium.app/Contents/MacOS/Chromium","/Applications/Brave Browser.app/Contents/MacOS/Brave Browser","/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"]:process.platform==="win32"?[`${process.env.PROGRAMFILES??""}\\Google\\Chrome\\Application\\chrome.exe`,`${process.env.LOCALAPPDATA??""}\\Google\\Chrome\\Application\\chrome.exe`]:["/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/usr/bin/chromium","/usr/bin/chromium-browser"]].filter(e=>e!==void 0&&e!=="");for(let e of n)try{return await N(e),e}catch{}throw new s("chrome_not_found","Chrome, Chromium, Edge, or Brave was not found. Set MCP_USE_CHROME_PATH.")}function D(){return new Promise((r,n)=>{let e=G();e.once("error",n),e.listen(0,"127.0.0.1",()=>{let t=e.address(),i=typeof t=="object"&&t!==null?t.port:0;e.close(o=>o?n(o):r(i))})})}async function ae(r,n){let e=Date.now()+n;for(;Date.now()<e;){try{let t=await fetch(r);if(t.ok)return await t.json()}catch{}await d(100)}throw new s("chrome_start_failed","Chrome DevTools did not start.")}function ce(r){let n={};for(let e of r){let t=e.indexOf(":");if(t<=0)throw new c(`Invalid header: ${e}`);n[e.slice(0,t).trim()]=e.slice(t+1).trim()}return n}function h(r,n){let e=Number(r);if(!Number.isFinite(e)||e<=0)throw new c(`${n} must be positive.`);return e}function de(r,n){let e=Number(r);if(!Number.isFinite(e)||e<0)throw new c(`${n} must be non-negative.`);return e}function ue(r){return JSON.stringify(r).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function d(r){return new Promise(n=>setTimeout(n,r))}export{Pe as runScreenshot};
|
|
@@ -0,0 +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(`
|
|
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};
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +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}).
|
|
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
|
+
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
|
+
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function a(){}function d(){}function u(){}function l(){}function p(){}function x(e){return e}async function f(){return new Headers}var i={get:()=>{},getAll:()=>[],has:()=>!1,set:()=>{},delete:()=>{}};async function g(){return i}async function R(){return{isEnabled:!1,enable(){},disable(){}}}function c(e){let n=new Error(`redirect(${String(e)}) called outside Next.js`);throw Object.assign(n,{digest:`NEXT_REDIRECT;${String(e)}`}),n}var w=c;function h(){let e=new Error("notFound() called outside Next.js");throw Object.assign(e,{digest:"NEXT_NOT_FOUND"}),e}var v={push:"push",replace:"replace"},o=class e extends Response{static json(n,t){let r=new Headers(t?.headers);return r.set("content-type","application/json"),new e(JSON.stringify(n),{...t,headers:r})}static redirect(n,t=302){return new e(null,{status:t,headers:{location:String(n)}})}static next(){return new e(null)}static rewrite(){return new e(null)}},s=class extends Request{nextUrl;cookies=i;constructor(n,t){super(n,t),this.nextUrl=new URL(typeof n=="string"?n:n instanceof URL?n.href:n.url)}};function y(){return{ua:"",browser:{},device:{},engine:{},os:{},cpu:{},isBot:!1}}export{s as NextRequest,o as NextResponse,v as RedirectType,g as cookies,R as draftMode,f as headers,h as notFound,w as permanentRedirect,c as redirect,a as revalidatePath,d as revalidateTag,x as unstable_cache,l as unstable_cacheLife,p as unstable_cacheTag,u as unstable_noStore,y as userAgent};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-use/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "4.0.0-beta.2",
|
|
5
|
+
"description": "Prebuilt CLI, development server, and build pipeline for mcp-use",
|
|
6
6
|
"author": "mcp-use, Inc.",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/mcp-use/mcp-use#readme",
|
|
@@ -20,27 +20,49 @@
|
|
|
20
20
|
"cli"
|
|
21
21
|
],
|
|
22
22
|
"bin": {
|
|
23
|
-
"mcp-use": "./dist/
|
|
23
|
+
"mcp-use": "./dist/bin.js"
|
|
24
|
+
},
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./types/index.d.ts",
|
|
28
|
+
"import": "./dist/bin.js"
|
|
29
|
+
}
|
|
24
30
|
},
|
|
25
31
|
"files": [
|
|
26
|
-
"dist"
|
|
32
|
+
"dist",
|
|
33
|
+
"types"
|
|
27
34
|
],
|
|
28
35
|
"engines": {
|
|
29
36
|
"node": ">=22.22.2"
|
|
30
37
|
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
|
|
38
|
+
"dependencies": {},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@mcp-use/client": "^2.0.0-alpha.0",
|
|
41
|
+
"@mcp-use/inspector": "^20.0.0-beta.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependenciesMeta": {
|
|
44
|
+
"@mcp-use/client": {
|
|
45
|
+
"optional": true
|
|
46
|
+
},
|
|
47
|
+
"@mcp-use/inspector": {
|
|
48
|
+
"optional": true
|
|
49
|
+
}
|
|
33
50
|
},
|
|
34
51
|
"devDependencies": {
|
|
52
|
+
"@modelcontextprotocol/server": "https://pkg.pr.new/@modelcontextprotocol/server@f60b40179b0f090f6d64248be1312245a160b5ee",
|
|
53
|
+
"@tailwindcss/vite": "^4.2.0",
|
|
54
|
+
"@vitejs/plugin-react": "^6.0.3",
|
|
35
55
|
"rimraf": "^6.1.3",
|
|
56
|
+
"tailwindcss": "^4.2.0",
|
|
36
57
|
"tsup": "^8.5.1",
|
|
37
|
-
"typescript": "^5.9.3"
|
|
58
|
+
"typescript": "^5.9.3",
|
|
59
|
+
"vite": "^8.0.16"
|
|
38
60
|
},
|
|
39
61
|
"publishConfig": {
|
|
40
62
|
"access": "public"
|
|
41
63
|
},
|
|
42
64
|
"scripts": {
|
|
43
|
-
"build": "rimraf dist && tsup
|
|
65
|
+
"build": "rimraf dist && tsup --config tsup.config.ts && node scripts/verify-package.mjs",
|
|
44
66
|
"test": "node --test tests/proxy.test.mjs"
|
|
45
67
|
}
|
|
46
68
|
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// src/index.ts
|
|
4
|
-
try {
|
|
5
|
-
const frameworkEntry = new URL(import.meta.resolve("mcp-use"));
|
|
6
|
-
await import(new URL("./bin.js", frameworkEntry).href);
|
|
7
|
-
} catch (error) {
|
|
8
|
-
console.error(error instanceof Error ? error.message : String(error));
|
|
9
|
-
process.exitCode = 1;
|
|
10
|
-
}
|