@mcp-use/cli 4.1.10 → 4.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +1 -1
- package/dist/{chunk-YTNIFIL2.js → chunk-K5AVW4TV.js} +6 -6
- package/dist/commands/client.js +1 -1
- package/dist/commands/screenshot.js +1 -1
- package/dist/commands/servers.js +7 -7
- package/dist/index.js +1 -1
- package/package.json +4 -4
- /package/dist/{chunk-JBGCRKRU.js → chunk-JPZVQE3D.js} +0 -0
package/dist/bin.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as o}from"./chunk-
|
|
2
|
+
import{a as o}from"./chunk-JPZVQE3D.js";import"./chunk-RXKUVCL7.js";import"./chunk-WOT6VMZA.js";import{readFileSync as i}from"fs";import{createRequire as a}from"module";import{dirname as t,join as c,parse as m}from"path";function p(){try{let e=a(import.meta.url).resolve("mcp-use"),n=t(e),s=m(n).root;for(;n!==s;){try{let r=JSON.parse(i(c(n,"package.json"),"utf8"));if(r.name==="mcp-use"&&typeof r.version=="string")return r.version}catch{}n=t(n)}}catch{}}o(process.argv.slice(2),{frameworkVersion:p()??"4.1.11"}).then(e=>{process.exitCode=e},e=>{console.error(e instanceof Error?e.message:String(e)),process.exitCode=1});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import{a,b as h,d as G,e as f,f as K,g as W,h as V,i as O,j as U,k as C,m as
|
|
1
|
+
import{a,b as h,d as G,e as f,f as K,g as W,h as V,i as O,j as U,k as C,m as j}from"./chunk-Q6AC7LJS.js";import{createHash as ke}from"crypto";import{rm as ne}from"fs/promises";import{join as T}from"path";import{createInterface as Oe}from"readline/promises";import{parseArgs as x}from"util";var l=["-h, --help","Show this help"],g=["--json","Emit machine-readable JSON (accepted anywhere after client)"],b=new Map;function d(e,t){b.set(e,t)}d("",{usage:"mcp-use client <command>",summary:"Connect to and invoke saved HTTP(S) MCP servers.",commands:[["connect <name> <url>","Connect and save a server"],["list","List saved servers"],["remove <name>","Remove a saved server"],["<name>","Invoke a saved server"]],options:[l]});d("connect",{usage:"mcp-use client connect <name> <url> [options]",summary:"Connect to and save an HTTP(S) MCP server.",options:[['-H, --header <"Key: Value">',"Static header (repeatable)"],["--no-oauth","Skip OAuth on authorization challenges"],["--auth-timeout <ms>","OAuth wait timeout (default: 300000)"],["--protocol <auto|legacy|modern>","Protocol mode (default: auto; modern is stateless/sessionless)"],["--no-open","Print the OAuth URL without opening a browser"],g,l],notes:["JSON mode never opens a browser or prints an OAuth URL/state. If new consent is required, it returns oauth_interaction_required with an interactive retry command."]});d("list",{usage:"mcp-use client list [options]",summary:"List saved MCP servers.",options:[g,l]});d("remove",{usage:"mcp-use client remove <name> [options]",summary:"Immediately remove a saved server and its credentials.",options:[g,l]});d("<name>",{usage:"mcp-use client <name> <command>",summary:"Invoke a saved MCP server.",commands:[["tools","List, describe, or call tools"],["resources","List or read resources"],["prompts","List or get prompts"],["auth","Authenticate or inspect saved OAuth state"]],options:[l]});d("<name> tools",{usage:"mcp-use client <name> tools <command>",summary:"Use tools on a saved MCP server.",commands:[["list","List tools"],["describe <tool>","Show a tool definition"],["call <tool> [args...]","Call a tool"]],options:[l]});d("<name> tools list",{usage:"mcp-use client <name> tools list [options]",summary:"List tools on a saved MCP server.",options:[g,l]});d("<name> tools describe",{usage:"mcp-use client <name> tools describe <tool> [options]",summary:"Show one tool definition.",options:[g,l]});d("<name> tools call",{usage:"mcp-use client <name> tools call <tool> [args...] [options]",summary:"Call a tool on a saved MCP server.",options:[["--timeout <ms>","Call timeout (default: 30000)"],g,l],notes:["Arguments are one JSON object or key=value/key:=<json> pairs; do not mix forms."]});d("<name> resources",{usage:"mcp-use client <name> resources <command>",summary:"Use resources on a saved MCP server.",commands:[["list","List resources"],["read <uri>","Read a resource"]],options:[l]});d("<name> resources list",{usage:"mcp-use client <name> resources list [options]",summary:"List resources on a saved MCP server.",options:[g,l]});d("<name> resources read",{usage:"mcp-use client <name> resources read <uri> [options]",summary:"Read one resource.",options:[g,l]});d("<name> prompts",{usage:"mcp-use client <name> prompts <command>",summary:"Use prompts on a saved MCP server.",commands:[["list","List prompts"],["get <prompt> [args...]","Get a prompt"]],options:[l]});d("<name> prompts list",{usage:"mcp-use client <name> prompts list [options]",summary:"List prompts on a saved MCP server.",options:[g,l]});d("<name> prompts get",{usage:"mcp-use client <name> prompts get <prompt> [args...] [options]",summary:"Get a prompt from a saved MCP server.",options:[g,l],notes:["Arguments are one JSON object or key=value/key:=<json> pairs; do not mix forms."]});d("<name> auth",{usage:"mcp-use client <name> auth <command>",summary:"Manage saved OAuth state.",commands:[["login","Authenticate this server"],["status","Show OAuth status"],["logout","Delete saved OAuth credentials"]],options:[l]});d("<name> auth login",{usage:"mcp-use client <name> auth login [options]",summary:"Authenticate a saved MCP server with OAuth.",options:[g,l]});d("<name> auth status",{usage:"mcp-use client <name> auth status [options]",summary:"Show saved OAuth status.",options:[g,l]});d("<name> auth logout",{usage:"mcp-use client <name> auth logout [options]",summary:"Delete saved OAuth credentials but keep the server.",options:[["--yes","Skip the confirmation prompt"],g,l]});function Z(e){let t=e.filter(u=>u!=="--help"&&u!=="-h"&&u!=="--json"),n=t[0];if(n===void 0)return{text:$(b.get(""))};if(n==="connect"||n==="list"||n==="remove")return{text:$(b.get(n))};let o=t[1];if(o===void 0)return{text:$(b.get("<name>"))};if(!["tools","resources","prompts","auth"].includes(o))return{error:`Unknown client command family: ${o}`};let r=t[2],s=`<name> ${o}`;if(r===void 0)return{text:$(b.get(s))};let i=`${s} ${r}`,m=b.get(i);return m===void 0?{error:`Unknown client ${o} command: ${r}`}:{text:$(m)}}function $(e){let t=[`Usage: ${e.usage}`,e.summary];return e.commands!==void 0&&t.push(Y("Commands",e.commands)),e.options!==void 0&&t.push(Y("Options",e.options)),e.notes!==void 0&&t.push(e.notes.join(`
|
|
2
2
|
`)),t.join(`
|
|
3
3
|
|
|
4
4
|
`)}function Y(e,t){let n=Math.max(...t.map(([o])=>o.length));return`${e}:
|
|
5
5
|
${t.map(([o,r])=>` ${o.padEnd(n)} ${r}`).join(`
|
|
6
|
-
`)}`}import{spawn as ue}from"child_process";import{readFileSync as le}from"fs";import{chmod as de,mkdir as me}from"fs/promises";import{dirname as pe,join as R,resolve as fe}from"path";import{pathToFileURL as ee}from"url";var A=R(
|
|
6
|
+
`)}`}import{spawn as ue}from"child_process";import{readFileSync as le}from"fs";import{chmod as de,mkdir as me}from"fs/promises";import{dirname as pe,join as R,resolve as fe}from"path";import{pathToFileURL as ee}from"url";var A=R(j,"client-sdk"),w="@mcp-use/client",ge="^2.0.0-alpha.0",he=[`[mcp-use] ${w} 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(`
|
|
7
7
|
`);async function we(e){let t=fe(e);for(;;){if(await O(R(t,"package.json")))return t;let n=pe(t);if(n===t)return;t=n}}async function te(e={}){try{return await Se()}catch(t){if(!Q(t))throw t;if(e.allowInstall===!1)throw new h("client_install_required",`${w} is required for this command.`,{nextSteps:[{description:"Install the optional client SDK",command:`npm install ${w}`}]});let n=await ve();try{return n.location==="sandbox"?await be():await Ce(n.projectRoot)}catch(o){throw Q(o)?new a(he):o}}}async function ve(){let e=Pe(),t=`${w}@${e}`,n=await we(process.cwd());if(process.stderr.write(`[mcp-use] installing ${w}\u2026
|
|
8
|
-
`),n!==void 0){let[s,i]=ye(t);if(await X(s,i,n)!==0)throw new h("client_install_failed",`Failed to install ${w}.`);return{location:"project",projectRoot:n}}await me(A,{recursive:!0,mode:448}),await de(A,448);let o=R(A,"package.json");if(await O(o)||await C(o,{private:!0,dependencies:{[w]:e}}),await X("npm",["install",t],A)!==0)throw new h("client_install_failed",`Failed to install ${w}.`);return{location:"sandbox"}}function ye(e){let t=process.env.npm_config_user_agent??"";return t.startsWith("pnpm/")?["pnpm",["add",e]]:t.startsWith("bun/")?["bun",["add",e]]:["npm",["install",e]]}function Pe(){for(let e of["../package.json","../../package.json"])try{let t=le(new URL(e,import.meta.url),"utf8"),n=JSON.parse(t);if(n.name!=="mcp-use")continue;let o=n.peerDependencies?.[w];if(typeof o=="string"&&o.length>0)return o}catch{}return ge}async function Se(){return D(),import("@mcp-use/client")}async function Ce(e){D();let t=ee(R(e,"package.json")).href;return import(await import.meta.resolve(w,t))}async function be(){D();let e=R(A,"node_modules",w,"dist","index.js");return await import(ee(e).href)}function D(){let e=Object.getOwnPropertyDescriptor(globalThis,"localStorage");e?.get===void 0||e.configurable!==!0||Object.defineProperty(globalThis,"localStorage",{configurable:!0,enumerable:e.enumerable??!1,value:void 0,writable:!0})}function Q(e){if(!(e instanceof Error))return!1;let t=e.code;return t==="ERR_MODULE_NOT_FOUND"||t==="MODULE_NOT_FOUND"?e.message.includes(w)||e.message.includes("Cannot find package"):!1}function X(e,t,n){return new Promise((o,r)=>{let s=ue(e,t,{cwd:n,stdio:"inherit",shell:process.platform==="win32"});s.once("error",r),s.once("exit",(i,m)=>{o(m==="SIGINT"?130:i??1)})})}var oe=T(
|
|
8
|
+
`),n!==void 0){let[s,i]=ye(t);if(await X(s,i,n)!==0)throw new h("client_install_failed",`Failed to install ${w}.`);return{location:"project",projectRoot:n}}await me(A,{recursive:!0,mode:448}),await de(A,448);let o=R(A,"package.json");if(await O(o)||await C(o,{private:!0,dependencies:{[w]:e}}),await X("npm",["install",t],A)!==0)throw new h("client_install_failed",`Failed to install ${w}.`);return{location:"sandbox"}}function ye(e){let t=process.env.npm_config_user_agent??"";return t.startsWith("pnpm/")?["pnpm",["add",e]]:t.startsWith("bun/")?["bun",["add",e]]:["npm",["install",e]]}function Pe(){for(let e of["../package.json","../../package.json"])try{let t=le(new URL(e,import.meta.url),"utf8"),n=JSON.parse(t);if(n.name!=="mcp-use")continue;let o=n.peerDependencies?.[w];if(typeof o=="string"&&o.length>0)return o}catch{}return ge}async function Se(){return D(),import("@mcp-use/client")}async function Ce(e){D();let t=ee(R(e,"package.json")).href;return import(await import.meta.resolve(w,t))}async function be(){D();let e=R(A,"node_modules",w,"dist","index.js");return await import(ee(e).href)}function D(){let e=Object.getOwnPropertyDescriptor(globalThis,"localStorage");e?.get===void 0||e.configurable!==!0||Object.defineProperty(globalThis,"localStorage",{configurable:!0,enumerable:e.enumerable??!1,value:void 0,writable:!0})}function Q(e){if(!(e instanceof Error))return!1;let t=e.code;return t==="ERR_MODULE_NOT_FOUND"||t==="MODULE_NOT_FOUND"?e.message.includes(w)||e.message.includes("Cannot find package"):!1}function X(e,t,n){return new Promise((o,r)=>{let s=ue(e,t,{cwd:n,stdio:"inherit",shell:process.platform==="win32"});s.once("error",r),s.once("exit",(i,m)=>{o(m==="SIGINT"?130:i??1)})})}var oe=T(j,"client"),M=T(oe,"servers.json");async function nt(e){if(e.includes("--help")||e.includes("-h")){let r=Z(e);return r.text!==void 0?(process.stdout.write(`${r.text}
|
|
9
9
|
`),0):(process.stderr.write(`${r.error}
|
|
10
|
-
`),2)}let t=G(e),n=e.filter(r=>r!=="--json"),o=n[0];try{if(o==="connect")return await $e(n.slice(1),t);if(o==="list")return await Ae(n.slice(1),t);if(o==="remove")return await Re(n.slice(1),t);if(o===void 0)throw new a("Usage: mcp-use client <connect|list|remove|name>");return await Ee(o,n.slice(1),t)}catch(r){return K(r instanceof TypeError?new a(r.message):r,t)}}async function $e(e,t){let{values:n,positionals:o}=x({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"},"no-open":{type:"boolean"}}});if(o.length!==2)throw new a("Usage: mcp-use client connect <name> <url>");let[r,s]=o;
|
|
10
|
+
`),2)}let t=G(e),n=e.filter(r=>r!=="--json"),o=n[0];try{if(o==="connect")return await $e(n.slice(1),t);if(o==="list")return await Ae(n.slice(1),t);if(o==="remove")return await Re(n.slice(1),t);if(o===void 0)throw new a("Usage: mcp-use client <connect|list|remove|name>");return await Ee(o,n.slice(1),t)}catch(r){return K(r instanceof TypeError?new a(r.message):r,t)}}async function $e(e,t){let{values:n,positionals:o}=x({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"},"no-open":{type:"boolean"}}});if(o.length!==2)throw new a("Usage: mcp-use client connect <name> <url>");let[r,s]=o;je(r);let i=new URL(s);if(!["http:","https:"].includes(i.protocol))throw new a("Client URLs must use http or https.");let m=Ue(n.protocol),u=ie(n["auth-timeout"]??"300000","--auth-timeout"),c=await _();if(c.servers[r]!==void 0)throw new a(`Saved server already exists: ${r}`);let p={headers:Le(n.header??[])},P={url:i.href,oauth:n["no-oauth"]!==!0,protocol:m},k=await N(r,P,p,u,se({noOpen:n["no-open"]===!0,json:t}),t,`mcp-use client connect ${r} <url> --no-open`);await k.discoverAuthorization();let y=k.authorization;return await k.disconnect(),c.servers[r]=P,await C(M,c),await C(q(r),p),f({name:r,url:H(P.url),protocol:m,...y?{authorization:{...y,...y.resource?{resource:H(y.resource)}:{}}}:{}},t,y?.mode==="mixed"&&!y.authenticated?`Connected and saved ${r}.
|
|
11
11
|
This server is using mixed auth. Public tools are available now; run \`mcp-use client ${r} auth login\` to authenticate.`:`Connected and saved ${r}.`),0}async function Ae(e,t){S(e);let n=await _(),o=Object.entries(n.servers).map(([r,s])=>({name:r,...s,url:H(s.url)}));return f(o,t,o.map(r=>`${r.name} ${r.url}`).join(`
|
|
12
|
-
`)||"No saved servers."),0}async function Re(e,t){let{positionals:n}=x({args:[...e],allowPositionals:!0,strict:!0,options:{}}),o=E(n,"mcp-use client remove <name>"),r=await _();return delete r.servers[o],await C(
|
|
12
|
+
`)||"No saved servers."),0}async function Re(e,t){let{positionals:n}=x({args:[...e],allowPositionals:!0,strict:!0,options:{}}),o=E(n,"mcp-use client remove <name>"),r=await _();if(!Object.hasOwn(r.servers,o))throw new a(`Unknown saved server: ${o}. Run \`mcp-use client list\` to see saved servers.`);return delete r.servers[o],await C(M,r),await ne(B(o),{recursive:!0,force:!0}),f({removed:o},t,`Removed ${o}.`),0}async function Ee(e,t,n){let r=(await _()).servers[e];if(r===void 0)throw new a(`Unknown saved server: ${e}. Run \`mcp-use client connect ${e} <url>\`.`);let s=t[0],i=t[1];if(s==="auth"){if(i==="status"){S(t.slice(2));let c=await O(z(e));return f({name:e,oauth:r.oauth,authenticated:c},n,c?"Authenticated.":"No saved OAuth session."),0}if(i==="logout"){let{values:c,positionals:p}=x({args:[...t.slice(2)],allowPositionals:!0,strict:!0,options:{yes:{type:"boolean"}}});if(p.length!==0)throw new a(`Usage: mcp-use client ${e} auth logout`);return await W(`Delete OAuth credentials for ${e}?`,{yes:c.yes===!0,json:n})&&(await ne(z(e),{recursive:!0,force:!0}),f({loggedOut:e},n,`Logged out ${e}.`)),0}}Te(e,s,i,t.slice(2));let m=await U(q(e),{}),u=await N(e,r,m,3e5,se({noOpen:!1,json:n}),n,s==="auth"&&i==="login"?`mcp-use client ${e} auth login`:void 0);try{if(s==="auth"&&i==="login")return S(t.slice(2)),await u.authenticate(),f({name:e,authenticated:!0},n,`Authenticated ${e}.`),0;if(s==="tools"){if(i==="list"){S(t.slice(2));let c=await u.listTools();return f(c,n,c.map(p=>p.description?`${p.name} - ${p.description}`:p.name).join(`
|
|
13
13
|
`)),0}if(i==="describe"){let c=E(t.slice(2),`mcp-use client ${e} tools describe <tool>`),p=(await u.listTools()).find(P=>P.name===c);if(p===void 0)throw new a(`Tool not found: ${c}`);return f(p,n),0}if(i==="call")return await xe(u,e,t.slice(2),n)}if(s==="resources"){if(i==="list"){S(t.slice(2));let c=await u.listResources();return f(c,n),0}if(i==="read"){let c=E(t.slice(2),`mcp-use client ${e} resources read <uri>`);return f(await u.readResource(c),n),0}}if(s==="prompts"){if(i==="list")return S(t.slice(2)),f(await u.listPrompts(),n),0;if(i==="get"){let c=t[2];if(c===void 0)throw new a(`Usage: mcp-use client ${e} prompts get <prompt> [args]`);return f(await u.getPrompt(c,I(t.slice(3))),n),0}}throw new a(`Usage: mcp-use client ${e} <tools|resources|prompts|auth> ...`)}finally{await u.disconnect()}}function Te(e,t,n,o){if(t==="tools"&&n==="list"||t==="resources"&&n==="list"||t==="prompts"&&n==="list"){S(o);return}if(t==="auth"&&n==="login"){S(o);return}if(t==="tools"&&n==="describe"){E(o,`mcp-use client ${e} tools describe <tool>`);return}if(t==="tools"&&n==="call"){re(e,o);return}if(t==="resources"&&n==="read"){E(o,`mcp-use client ${e} resources read <uri>`);return}if(t==="prompts"&&n==="get"){if(o[0]===void 0)throw new a(`Usage: mcp-use client ${e} prompts get <prompt> [args]`);I(o.slice(1));return}throw new a(`Usage: mcp-use client ${e} <tools|resources|prompts|auth> ...`)}async function xe(e,t,n,o){let{tool:r,timeout:s,positionals:i}=re(t,n),m=await e.callTool(r,I(i),{timeout:s});if(m.isError===!0)throw new h("tool_error",`Tool ${r} returned an error.`,m);return f(m,o),0}function re(e,t){let n=t[0];if(n===void 0)throw new a(`Usage: mcp-use client ${e} tools call <tool> [args]`);let{values:o,positionals:r}=x({args:[...t.slice(1)],allowPositionals:!0,strict:!0,options:{timeout:{type:"string",default:"30000"}}}),s=ie(o.timeout,"--timeout");return I(r),{tool:n,timeout:s,positionals:r}}async function N(e,t,n,o,r=process.stdin.isTTY?"ask":"never",s=!1,i=`mcp-use client ${e} tools list`){let{createOAuthProvider:m,MCPClient:u,logger:c}=await te({allowInstall:!s});s&&(c.level="silent");let p,P=s&&t.oauth?new Promise((v,L)=>{p=L}):void 0,k=z(e),y=t.oauth?await m(t.url,{baseDir:k,authTimeoutMs:o,storageKeyPrefix:`mcp-use-cli:${e}`,openBrowser:async v=>{if(s){let L=new h("oauth_interaction_required","OAuth interaction is required; retry this command without --json in a terminal.",{server:e,nextSteps:[{description:"Authenticate interactively in a terminal",command:i}]});throw p?.(L),L}if(r==="never"){process.stderr.write(`Open this URL to authenticate:
|
|
14
14
|
${v}
|
|
15
|
-
`);return}await _e(),V(v)}}):void 0,ce=t.protocol==="auto"?{protocolNegotiation:"auto"}:t.protocol==="modern"?{protocolNegotiation:{pin:"2026-07-28"}}:{protocolNegotiation:"legacy",clientOptions:{supportedProtocolVersions:["2025-11-25"]}},F=new u({mcpServers:{[e]:{url:t.url,...n.headers!==void 0?{headers:n.headers}:{},...y!==void 0?{authProvider:y}:{oauth:!1},...ce}}});try{let v=F.connect(e);return await(P===void 0?v:Promise.race([v,P]))}catch(v){throw v instanceof h&&v.code==="oauth_interaction_required"?(y?.dispose?.(),await F.closeSession?.(e),v):Ie(Ne(v,t.protocol),t,n)}}async function ot(e,t=3e5,n=!1){let r=(await _()).servers[e];if(r===void 0)throw new a(`Unknown saved server: ${e}`);let s=await U(q(e),{});return N(e,r,s,t,process.stdin.isTTY?"ask":"never",n)}async function rt(e,t,n=!1){return N("screenshot",{url:e,oauth:!1,protocol:"auto"},{headers:t},3e5,"never",n)}function I(e){if(e.length===0)return{};if(e.length===1&&e[0]?.trimStart().startsWith("{")){let n=JSON.parse(e[0]);if(n===null||Array.isArray(n)||typeof n!="object")throw new a("The JSON argument must be an object.");return n}let t={};for(let n of e){let o=n.indexOf(":="),r=n.indexOf("="),s=o>=0?o:r,i=o>=0?2:1;if(s<=0)throw new a(`Expected key=value or key:=<json>, received: ${n}`);let m=n.slice(0,s).replace(/^--/,""),u=n.slice(s+i);t[m]=o>=0?JSON.parse(u):u}return t}function se(e){return e.json||e.noOpen||!process.stdin.isTTY?"never":"ask"}async function _e(){let e=Oe({input:process.stdin,output:process.stderr});try{await e.question("This server requires OAuth. Press Enter to open your browser.")}finally{e.close()}}function Le(e){let t={};for(let n of e){let o=n.indexOf(":");if(o<=0)throw new a(`Invalid header: ${n}`);t[n.slice(0,o).trim()]=n.slice(o+1).trim()}return t}function Ue(e){if(e!=="auto"&&e!=="legacy"&&e!=="modern")throw new a("Invalid protocol. Expected auto, legacy, or modern.");return e}function ie(e,t){let n=Number(e);if(!Number.isInteger(n)||n<=0)throw new a(`${t} must be a positive integer.`);return n}function
|
|
15
|
+
`);return}await _e(),V(v)}}):void 0,ce=t.protocol==="auto"?{protocolNegotiation:"auto"}:t.protocol==="modern"?{protocolNegotiation:{pin:"2026-07-28"}}:{protocolNegotiation:"legacy",clientOptions:{supportedProtocolVersions:["2025-11-25"]}},F=new u({mcpServers:{[e]:{url:t.url,...n.headers!==void 0?{headers:n.headers}:{},...y!==void 0?{authProvider:y}:{oauth:!1},...ce}}});try{let v=F.connect(e);return await(P===void 0?v:Promise.race([v,P]))}catch(v){throw v instanceof h&&v.code==="oauth_interaction_required"?(y?.dispose?.(),await F.closeSession?.(e),v):Ie(Ne(v,t.protocol),t,n)}}async function ot(e,t=3e5,n=!1){let r=(await _()).servers[e];if(r===void 0)throw new a(`Unknown saved server: ${e}`);let s=await U(q(e),{});return N(e,r,s,t,process.stdin.isTTY?"ask":"never",n)}async function rt(e,t,n=!1){return N("screenshot",{url:e,oauth:!1,protocol:"auto"},{headers:t},3e5,"never",n)}function I(e){if(e.length===0)return{};if(e.length===1&&e[0]?.trimStart().startsWith("{")){let n=JSON.parse(e[0]);if(n===null||Array.isArray(n)||typeof n!="object")throw new a("The JSON argument must be an object.");return n}let t={};for(let n of e){let o=n.indexOf(":="),r=n.indexOf("="),s=o>=0?o:r,i=o>=0?2:1;if(s<=0)throw new a(`Expected key=value or key:=<json>, received: ${n}`);let m=n.slice(0,s).replace(/^--/,""),u=n.slice(s+i);t[m]=o>=0?JSON.parse(u):u}return t}function se(e){return e.json||e.noOpen||!process.stdin.isTTY?"never":"ask"}async function _e(){let e=Oe({input:process.stdin,output:process.stderr});try{await e.question("This server requires OAuth. Press Enter to open your browser.")}finally{e.close()}}function Le(e){let t={};for(let n of e){let o=n.indexOf(":");if(o<=0)throw new a(`Invalid header: ${n}`);t[n.slice(0,o).trim()]=n.slice(o+1).trim()}return t}function Ue(e){if(e!=="auto"&&e!=="legacy"&&e!=="modern")throw new a("Invalid protocol. Expected auto, legacy, or modern.");return e}function ie(e,t){let n=Number(e);if(!Number.isInteger(n)||n<=0)throw new a(`${t} must be a positive integer.`);return n}function je(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.")}function H(e){let t=new URL(e);(t.username!==""||t.password!=="")&&(t.username="[REDACTED]",t.password="");for(let n of[...t.searchParams.keys()])t.searchParams.set(n,"[REDACTED]");return t.hash!==""&&(t.hash="[REDACTED]"),t.href}async function _(){let e=await U(M,{servers:{}}),t={servers:{}},n=!1;for(let[o,r]of Object.entries(e.servers)){let s=Me(r.protocol);t.servers[o]={...r,protocol:s},n||=s!==r.protocol}return n&&await C(M,t),t}function Me(e){if(e==="auto"||e==="legacy"||e==="modern")return e;if(e===void 0)return"auto";if(e==="2025-11-25")return"legacy";if(e==="2026-07-28")return"modern";throw new a("Saved server has an invalid protocol setting. Remove and reconnect it.")}function Ne(e,t){return t==="auto"||!(e instanceof Error)||!e.message.includes("Unsupported protocol version")&&!e.message.includes("pinned protocol version")?e:t==="legacy"?new h("protocol_mismatch","Server does not support the requested legacy protocol."):new h("protocol_mismatch","Server does not support the requested modern protocol (stateless/sessionless, no fallback).")}function Ie(e,t,n){let o=De(t.url,n.headers);if(!(e instanceof Error)||o.size===0)return e;let r=ae(e.message,o);if(e instanceof h)return new h(e.code,r,J(e.details,o));let s=new Error(r);return s.name=e.name,s}function De(e,t){let n=new Set,o=new URL(e);for(let r of[o.username,o.password,...o.searchParams.values(),o.hash.slice(1)])r!==""&&n.add(r);for(let r of Object.values(t??{}))if(r!==""){n.add(r);let s=r.match(/^Bearer\s+(.+)$/i)?.[1];s!==void 0&&n.add(s)}return n}function J(e,t){return typeof e=="string"?ae(e,t):Array.isArray(e)?e.map(n=>J(n,t)):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([n,o])=>[n,J(o,t)]))}function ae(e,t){let n=e;for(let o of t)n=n.replaceAll(o,"[REDACTED]");return n}function B(e){return T(oe,"credentials",ke("sha256").update(e).digest("hex"))}function q(e){return T(B(e),"credentials.json")}function z(e){return T(B(e),"oauth")}function S(e){x({args:[...e],allowPositionals:!1,strict:!0,options:{}})}function E(e,t){if(e.length!==1)throw new a(`Usage: ${t}`);return e[0]}export{nt as a,ot as b,rt as c,I as d};
|
package/dist/commands/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d}from"../chunk-
|
|
1
|
+
import{a,b,c,d}from"../chunk-K5AVW4TV.js";import"../chunk-Q6AC7LJS.js";import"../chunk-S3WHXP7I.js";import"../chunk-WOT6VMZA.js";export{c as openDirectConnection,b as openSavedConnection,d as parseMcpArguments,a as runClient};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{b as R,c as B,d as H}from"../chunk-
|
|
1
|
+
import{b as R,c as B,d as H}from"../chunk-K5AVW4TV.js";import{a,b as s,d as x,e as M,f as T}from"../chunk-Q6AC7LJS.js";import"../chunk-S3WHXP7I.js";import"../chunk-WOT6VMZA.js";import{spawn as $}from"child_process";import{access as j,mkdtemp as F,rm as A,writeFile as G}from"fs/promises";import{createServer as V}from"net";import{tmpdir as J}from"os";import{basename as q,join as z,resolve as W}from"path";import{parseArgs as K}from"util";import{fileURLToPath as X}from"url";var Q=`Usage: mcp-use screenshot (--server <name> | --mcp <url>) --tool <name> [args...] [options]
|
|
2
2
|
|
|
3
3
|
Call a view-backed MCP tool and capture its rendered MCP App as PNG.
|
|
4
4
|
|
package/dist/commands/servers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{h as
|
|
1
|
+
import{h as m}from"../chunk-2E4ZVDXN.js";import{a as u,b as E,d as $,e as p,f as A,g as w}from"../chunk-Q6AC7LJS.js";import"../chunk-S3WHXP7I.js";import"../chunk-WOT6VMZA.js";import{parseArgs as h}from"util";var I=`Usage: mcp-use servers <command> [options]
|
|
2
2
|
|
|
3
3
|
Manage cloud servers and environment variables.
|
|
4
4
|
|
|
@@ -21,7 +21,7 @@ Global options:
|
|
|
21
21
|
Exit codes:
|
|
22
22
|
0 Success or help
|
|
23
23
|
2 Invalid arguments or confirmation required
|
|
24
|
-
1 API or operational failure`,
|
|
24
|
+
1 API or operational failure`,D={list:`Usage: mcp-use servers list [options]
|
|
25
25
|
|
|
26
26
|
Options:
|
|
27
27
|
--org <id-or-slug> Override the active organization
|
|
@@ -83,8 +83,8 @@ Options:
|
|
|
83
83
|
--branch <name> Delete a preview value for a branch
|
|
84
84
|
--yes Confirm deletion without prompting
|
|
85
85
|
--json Emit the deletion result; never prompt
|
|
86
|
-
-h, --help Show this help`};async function W(n){if(n.some(e=>e==="--help"||e==="-h")){let e=n[0]==="env"&&n[1]!==void 0?`env ${n[1]}`:n[0]??"";return process.stdout.write(`${
|
|
87
|
-
`),0}let t
|
|
88
|
-
`)||"No environment variables."),0}async function
|
|
89
|
-
`)}function
|
|
90
|
-
`)}function
|
|
86
|
+
-h, --help Show this help`};async function W(n){if(n.some(e=>e==="--help"||e==="-h")){let e=n[0]==="env"&&n[1]!==void 0?`env ${n[1]}`:n[0]??"";return process.stdout.write(`${D[e]??I}
|
|
87
|
+
`),0}let t=$(n);try{let e=n[0];if(e==="list")return await j(n.slice(1),t);if(e==="get")return await L(n.slice(1),t);if(e==="update")return await N(n.slice(1),t);if(e==="delete")return await q(n.slice(1),t);if(e==="env")return await x(n.slice(1),t);throw new u("Usage: mcp-use servers <list|get|update|delete|env>")}catch(e){return A(e instanceof TypeError?new u(e.message):e,t)}}async function j(n,t){let{values:e}=h({args:[...n],allowPositionals:!1,strict:!0,options:G()}),{api:r,organizationId:s}=await m(e.org),{limit:o,skip:c}=J(e.limit,e.skip),l=new URLSearchParams({organizationId:s,limit:String(o),skip:String(c)}),i=await r.request(`/servers?${l}`);return p(i,t,V(i)),0}async function L(n,t){let{values:e,positionals:r}=h({args:[...n],allowPositionals:!0,strict:!0,options:f()}),s=v(r,"mcp-use servers get <id-or-slug>"),{api:o}=await m(e.org),c=await o.request(`/servers/${encodeURIComponent(s)}`);return p(c,t,M(c)),0}async function N(n,t){let{values:e,positionals:r}=h({args:[...n],allowPositionals:!0,strict:!0,options:{...f(),name:{type:"string"},description:{type:"string"},branch:{type:"string"},"root-dir":{type:"string"},"build-command":{type:"string"},"start-command":{type:"string"},"watch-paths":{type:"string",multiple:!0},"deploy-branches":{type:"string",multiple:!0},"wait-for-ci":{type:"boolean"},"no-wait-for-ci":{type:"boolean"}}}),s=v(r,"mcp-use servers update <id-or-slug>"),o={...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}:{}};if(e["wait-for-ci"]===!0&&e["no-wait-for-ci"]===!0)throw new u("--wait-for-ci and --no-wait-for-ci cannot be used together.");let c={...e.name!==void 0?{name:e.name}:{},...e.description!==void 0?{description:e.description}:{},...e.branch!==void 0?{productionBranch:e.branch}:{},...e["watch-paths"]!==void 0?{watchPaths:O(e["watch-paths"],"--watch-paths",512)}:{},...e["deploy-branches"]!==void 0?{deployBranchPatterns:O(e["deploy-branches"],"--deploy-branches",255)}:{},...e["wait-for-ci"]===!0?{waitForCi:!0}:{},...e["no-wait-for-ci"]===!0?{waitForCi:!1}:{},...Object.keys(o).length>0?{config:o}:{}};if(Object.keys(c).length===0)throw new u("servers update requires at least one mutation option.");let{api:l}=await m(e.org),i=await l.request(`/servers/${encodeURIComponent(s)}`,{method:"PATCH",body:JSON.stringify(c)});return p(i,t,`Updated ${s}.`),0}async function q(n,t){let{values:e,positionals:r}=h({args:[...n],allowPositionals:!0,strict:!0,options:{...f(),yes:{type:"boolean"}}}),s=v(r,"mcp-use servers delete <id-or-slug>");if(!await w(`Delete server ${s}?`,{yes:e.yes===!0,json:t}))return 0;let{api:o}=await m(e.org);return await o.request(`/servers/${encodeURIComponent(s)}`,{method:"DELETE"}),p({deleted:s},t,`Deleted ${s}.`),0}async function x(n,t){let e=n[0];if(e==="list")return z(n.slice(1),t);if(e==="set")return T(n.slice(1),t);if(e==="unset")return F(n.slice(1),t);throw new u("Usage: mcp-use servers env <list|set|unset>")}async function z(n,t){let{values:e,positionals:r}=h({args:[...n],allowPositionals:!0,strict:!0,options:{...f(),branch:{type:"string"}}}),s=v(r,"mcp-use servers env list <server>"),{api:o}=await m(e.org),l=(await U(o,s,e.branch)).map(i=>({id:i.id,key:i.key,branch:i.branch??null,environments:i.environments??[],sensitive:i.sensitive===!0,createdAt:i.createdAt,updatedAt:i.updatedAt}));return p(l,t,l.map(i=>i.key).join(`
|
|
88
|
+
`)||"No environment variables."),0}async function T(n,t){let{values:e,positionals:r}=h({args:[...n],allowPositionals:!0,strict:!0,options:{...f(),branch:{type:"string"},secret:{type:"boolean"}}});if(r.length!==2)throw new u("Usage: mcp-use servers env set <server> <KEY=VALUE>");let[s,o]=r,c=o.indexOf("=");if(c<=0)throw new u("Environment value must be KEY=VALUE.");let l=o.slice(0,c),i=o.slice(c+1),{api:d}=await m(e.org),b=(await U(d,s,e.branch)).find(S=>S.key===l&&(S.branch??void 0)===e.branch),k={key:l,value:i,branch:e.branch??null,environments:e.branch===void 0?["production"]:["preview"],sensitive:e.secret===!0};b===void 0?await d.request(`/servers/${encodeURIComponent(s)}/env-variables`,{method:"POST",body:JSON.stringify(k)}):await d.request(`/servers/${encodeURIComponent(s)}/env-variables/${encodeURIComponent(b.id)}`,{method:"PATCH",body:JSON.stringify(k)});let R={serverId:s,key:l,scope:e.branch===void 0?"production":"preview",branch:e.branch??null,secret:e.secret===!0,updated:b!==void 0};return p(R,t,`Set ${l}.`),0}async function F(n,t){let{values:e,positionals:r}=h({args:[...n],allowPositionals:!0,strict:!0,options:{...f(),branch:{type:"string"},yes:{type:"boolean"}}});if(r.length!==2)throw new u("Usage: mcp-use servers env unset <server> <key>");let[s,o]=r;if(!await w(`Delete environment variable ${o}?`,{yes:e.yes===!0,json:t}))return 0;let{api:c}=await m(e.org),i=(await U(c,s,e.branch)).find(d=>d.key===o&&(d.branch??void 0)===e.branch);if(i===void 0){let d=e.branch===void 0?"production":`branch ${e.branch}`;throw new E("env_variable_not_found",`Environment variable not found on ${s} (${d}): ${o}`)}return await c.request(`/servers/${encodeURIComponent(s)}/env-variables/${encodeURIComponent(i.id)}`,{method:"DELETE"}),p({deleted:o},t,`Deleted ${o}.`),0}async function U(n,t,e){let r=e===void 0?"":`?branch=${encodeURIComponent(e)}`;return n.request(`/servers/${encodeURIComponent(t)}/env-variables${r}`)}function f(){return{org:{type:"string"},json:{type:"boolean"}}}function V(n){let t=H(n,"items");return t.length===0?"No servers.":["NAME STATUS SOURCE REGION UPDATED",...t.map(r=>{let s=C(r,"connectedRepository"),o=y(s,"isManaged")===!0?"managed":s!==void 0?"github":a(r,"externalUrl")!==void 0?"external":"-";return[a(r,"name")??a(r,"slug")??"-",a(r,"status")??a(r,"latestDeploymentStatus")??"-",o,a(r,"region")??"AUTO",a(r,"updatedAt")??"-"].join(" ")})].join(`
|
|
89
|
+
`)}function M(n){if(!g(n))return String(n);let t=C(n,"connectedRepository"),e=y(t,"isManaged")===!0?"managed":t!==void 0?"github":a(n,"externalUrl")!==void 0?"external":"-",r=P(t,"watchPaths"),s=P(t,"deployBranchPatterns"),o=y(t,"waitForCi");return[`Name: ${a(n,"name")??"-"}`,`ID: ${a(n,"id")??"-"}`,`Slug: ${a(n,"slug")??"-"}`,`Status: ${a(n,"status")??a(n,"latestDeploymentStatus")??"-"}`,`Source: ${e}`,`Region: ${a(n,"region")??"AUTO"}`,`MCP URL: ${a(n,"mcpUrl")??"-"}`,...t!==void 0?[`Watch paths: ${r.length>0?r.join(", "):"all changes"}`,`Deploy branches: ${s.length>0?s.join(", "):"all branches"}`,`Wait for CI: ${o===!0?"yes":"no"}`]:[],`Updated: ${a(n,"updatedAt")??"-"}`].join(`
|
|
90
|
+
`)}function H(n,t){if(!g(n))return[];let e=n[t];return Array.isArray(e)?e.filter(g):[]}function C(n,t){if(!g(n))return;let e=n[t];return g(e)?e:void 0}function a(n,t){if(!g(n))return;let e=n[t];return typeof e=="string"&&e!==""?e:void 0}function y(n,t){if(!g(n))return;let e=n[t];return typeof e=="boolean"?e:void 0}function P(n,t){if(!g(n))return[];let e=n[t];return Array.isArray(e)?e.filter(r=>typeof r=="string"):[]}function O(n,t,e){if(n.length===1&&n[0]==="")return[];if(n.length>32)throw new u(`${t} accepts at most 32 patterns.`);if(n.some(r=>r===""))throw new u(`${t} accepts an empty value only by itself to clear all patterns.`);if(n.some(r=>r.length>e))throw new u(`${t} patterns may not exceed ${e} characters.`);return n}function g(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function G(){return{...f(),limit:{type:"string",default:"30"},skip:{type:"string",default:"0"}}}function v(n,t){if(n.length!==1)throw new u(`Usage: ${t}`);return n[0]}function J(n,t){let e=Number(n??"30"),r=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(r)||r<0)throw new u("--skip must be a non-negative integer.");return{limit:e,skip:r}}export{W as runServers};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-JPZVQE3D.js";import"./chunk-RXKUVCL7.js";import"./chunk-WOT6VMZA.js";export{a as main};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-use/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.11",
|
|
5
5
|
"description": "Prebuilt CLI, development server, and build pipeline for mcp-use",
|
|
6
6
|
"author": "mcp-use, Inc.",
|
|
7
7
|
"license": "MIT",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"vite": "8.0.16"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@mcp-use/client": "^2.0.1 || ^2.1.0 || ^2.1.1 || ^2.1.2 || ^2.1.3 || ^2.1.4 || ^2.1.5 || ^2.2.0 || ^2.2.1 || ^2.2.2 || ^2.2.3 || ^2.2.4",
|
|
54
|
-
"@mcp-use/inspector": "^20.3.
|
|
53
|
+
"@mcp-use/client": "^2.0.1 || ^2.1.0 || ^2.1.1 || ^2.1.2 || ^2.1.3 || ^2.1.4 || ^2.1.5 || ^2.2.0 || ^2.2.1 || ^2.2.2 || ^2.2.3 || ^2.2.4 || ^2.2.5 || ^2.3.0",
|
|
54
|
+
"@mcp-use/inspector": "^20.3.7"
|
|
55
55
|
},
|
|
56
56
|
"peerDependenciesMeta": {
|
|
57
57
|
"@mcp-use/client": {
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"typescript": "^5.9.3",
|
|
75
75
|
"vitest": "^4.1.9",
|
|
76
76
|
"zod": "^4.4.3",
|
|
77
|
-
"@mcp-use/client": "2.
|
|
77
|
+
"@mcp-use/client": "2.3.0",
|
|
78
78
|
"@mcp-use/tunnel": "0.2.0"
|
|
79
79
|
},
|
|
80
80
|
"publishConfig": {
|
|
File without changes
|