@modeltoolsprotocol/mtpcli 1.3.1 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +75 -9
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -8843,7 +8843,7 @@ var init_mcp = __esm(() => {
8843
8843
  });
8844
8844
 
8845
8845
  // src/version.ts
8846
- var VERSION2 = "1.3.1";
8846
+ var VERSION2 = "1.3.3";
8847
8847
 
8848
8848
  // src/serve.ts
8849
8849
  var exports_serve = {};
@@ -9940,7 +9940,7 @@ function parseHeaders(raw) {
9940
9940
  }
9941
9941
  return headers;
9942
9942
  }
9943
- async function run2(serverCmd, serverUrl, toolName, toolArgs = [], rawHeaders = [], clientId) {
9943
+ async function run2(serverCmd, serverUrl, toolName, toolArgs = [], rawHeaders = [], clientId, describe2) {
9944
9944
  let client;
9945
9945
  let serverName;
9946
9946
  if (serverUrl) {
@@ -9965,7 +9965,7 @@ async function run2(serverCmd, serverUrl, toolName, toolArgs = [], rawHeaders =
9965
9965
  description: `CLI wrapper for MCP server: ${serverName}`,
9966
9966
  commands
9967
9967
  };
9968
- if (!toolName) {
9968
+ if (describe2 || !toolName) {
9969
9969
  console.log(JSON.stringify(schema, null, 2));
9970
9970
  return;
9971
9971
  }
@@ -10642,6 +10642,15 @@ function describe(program2, options) {
10642
10642
  function withDescribe(program2, options) {
10643
10643
  program2.option("--mtp-describe", "Output machine-readable MTP JSON schema");
10644
10644
  program2.on("option:mtp-describe", () => {
10645
+ const subNames = new Set;
10646
+ for (const cmd of program2.commands) {
10647
+ subNames.add(cmd.name());
10648
+ for (const alias of cmd.aliases())
10649
+ subNames.add(alias);
10650
+ }
10651
+ const args = process.argv.slice(2);
10652
+ if (args.some((a) => subNames.has(a)))
10653
+ return;
10645
10654
  const schema = describe(program2, options);
10646
10655
  const clean = JSON.parse(JSON.stringify(schema));
10647
10656
  console.log(JSON.stringify(clean, null, 2));
@@ -10651,10 +10660,67 @@ function withDescribe(program2, options) {
10651
10660
  }
10652
10661
 
10653
10662
  // src/version.ts
10654
- var VERSION = "1.3.1";
10663
+ var VERSION = "1.3.3";
10655
10664
 
10656
10665
  // src/index.ts
10657
- var program2 = new Command().name("mtpcli").version(VERSION).description("Unified CLI for discovering, authenticating, and bridging --mtp-describe-compatible tools");
10666
+ var program2 = new Command().name("mtpcli").version(VERSION).description("Unified CLI for discovering, authenticating, and bridging --mtp-describe-compatible tools").addHelpText("after", `
10667
+ MTP: Using CLI Tools as an LLM Agent
10668
+
10669
+ Discovery
10670
+ Any tool supporting MTP responds to --mtp-describe with a JSON schema:
10671
+
10672
+ toolname --mtp-describe
10673
+
10674
+ This returns: tool name, commands, args (name, type, required, default),
10675
+ stdin/stdout descriptors, and examples.
10676
+
10677
+ Invoking Commands
10678
+ Schema maps directly to CLI invocation:
10679
+
10680
+ "name": "convert" -> toolname convert
10681
+ "name": "auth login" -> toolname auth login
10682
+ "name": "_root" -> toolname (no subcommand)
10683
+ Args with -- prefix are flags: --format json
10684
+ Args without prefix are positional: toolname convert myfile.csv
10685
+ "type": "boolean" flags take no value: --verbose
10686
+ "type": "array" flags repeat: --tag foo --tag bar
10687
+
10688
+ Stdin/Stdout
10689
+ When a command has stdin declared, pipe data in:
10690
+
10691
+ echo '{"name":"foo"}' | toolname process
10692
+ cat file.csv | toolname convert --format json
10693
+
10694
+ When stdout has contentType "application/json", output is parseable:
10695
+
10696
+ toolname convert data.csv --format json | jq '.results'
10697
+
10698
+ mtpcli Usage
10699
+
10700
+ Understand mtpcli by running: mtpcli --mtp-describe
10701
+
10702
+ Search for commands across tools:
10703
+
10704
+ mtpcli search "deploy to production"
10705
+ mtpcli search "convert csv" -- filetool mytool
10706
+ mtpcli search --scan-path "git commit"
10707
+
10708
+ Wrap an MCP server as a CLI:
10709
+
10710
+ mtpcli wrap --url "https://mcp.example.com/v1/mcp" --mtp-describe
10711
+ mtpcli wrap --url "https://mcp.example.com/v1/mcp" toolName -- --arg1 val1
10712
+ mtpcli wrap --server "npx @mcp/server" toolName -- --arg1 val1
10713
+
10714
+ Auth:
10715
+
10716
+ mtpcli auth login toolname # OAuth2 flow
10717
+ mtpcli auth login toolname --token sk-x # API key
10718
+ eval $(mtpcli auth env toolname) # Inject token into env
10719
+
10720
+ Composability
10721
+ Chain tools with pipes. No LLM round-trip needed for intermediate steps:
10722
+
10723
+ toolA export --format json | toolB import --stdin | jq '.summary'`);
10658
10724
  program2.command("search").description("Search across --mtp-describe-compatible tools").argument("<query>", "Search query").option("--json", "Output as JSON", false).option("--scan-path", "Scan PATH for --mtp-describe-compatible tools", false).option("--jobs <n>", "Number of parallel jobs for --scan-path", "16").argument("[tools...]", "Tool names to search (after --)").action(async (query, tools, opts) => {
10659
10725
  const { search: search2, loadSchemas: loadSchemas2, scanPath: scanPath2 } = await Promise.resolve().then(() => (init_search(), exports_search));
10660
10726
  const schemas = opts.scanPath ? await scanPath2(parseInt(opts.jobs, 10)) : await loadSchemas2(tools);
@@ -10802,7 +10868,7 @@ Multiple tools can be combined into a single MCP server:
10802
10868
  const { run: run5 } = await Promise.resolve().then(() => (init_serve(), exports_serve));
10803
10869
  await run5(opts.tool);
10804
10870
  });
10805
- program2.command("wrap").description("Wrap an MCP server as a CLI tool (mcp2cli bridge)").option("--server <cmd>", "MCP server command to run (stdio transport)").option("--url <url>", "MCP server URL (Streamable HTTP / SSE transport)").option("-H, --header <header...>", "HTTP header(s) for --url (e.g. 'Authorization: Bearer tok')").option("--client-id <id>", "Pre-registered OAuth client ID (for --url)").argument("[tool_name]", "Tool name to invoke").argument("[args...]", "Arguments for the tool (after --)").action(async (toolName, args, opts) => {
10871
+ program2.command("wrap").description("Wrap an MCP server as a CLI tool (mcp2cli bridge)").option("--server <cmd>", "MCP server command to run (stdio transport)").option("--url <url>", "MCP server URL (Streamable HTTP / SSE transport)").option("-H, --header <header...>", "HTTP header(s) for --url (e.g. 'Authorization: Bearer tok')").option("--client-id <id>", "Pre-registered OAuth client ID (for --url)").option("--mtp-describe", "Output MTP schema for the wrapped MCP server").argument("[tool_name]", "Tool name to invoke").argument("[args...]", "Arguments for the tool (after --)").action(async (toolName, args, opts) => {
10806
10872
  if (opts.server && opts.url) {
10807
10873
  process.stderr.write(`error: --server and --url are mutually exclusive
10808
10874
  `);
@@ -10824,7 +10890,7 @@ program2.command("wrap").description("Wrap an MCP server as a CLI tool (mcp2cli
10824
10890
  process.exit(1);
10825
10891
  }
10826
10892
  const { run: run5 } = await Promise.resolve().then(() => (init_wrap(), exports_wrap));
10827
- await run5(opts.server, opts.url, toolName, args, opts.header ?? [], opts.clientId);
10893
+ await run5(opts.server, opts.url, toolName, args, opts.header ?? [], opts.clientId, opts.mtpDescribe);
10828
10894
  });
10829
10895
  program2.command("validate").description("Validate a tool's --mtp-describe output against the MTP spec").argument("[tool]", "Tool name to validate").option("--json", "Output as JSON", false).option("--stdin", "Read JSON from stdin", false).option("--skip-help", "Skip --help cross-reference", false).action(async (tool, opts) => {
10830
10896
  const { run: run5 } = await Promise.resolve().then(() => (init_validate(), exports_validate));
@@ -10892,9 +10958,9 @@ var describeOptions = {
10892
10958
  },
10893
10959
  wrap: {
10894
10960
  examples: [
10895
- { description: "Describe a stdio MCP server", command: 'mtpcli wrap --server "npx @mcp/server-github"' },
10961
+ { description: "Describe a stdio MCP server", command: 'mtpcli wrap --server "npx @mcp/server-github" --mtp-describe' },
10896
10962
  { description: "Call a tool on a stdio server", command: 'mtpcli wrap --server "npx @mcp/server-github" search_repos -- --query mtpcli' },
10897
- { description: "Describe an HTTP MCP server", command: "mtpcli wrap --url http://localhost:3000/mcp" },
10963
+ { description: "Describe an HTTP MCP server", command: "mtpcli wrap --url http://localhost:3000/mcp --mtp-describe" },
10898
10964
  { description: "Call a tool on an HTTP server", command: "mtpcli wrap --url http://localhost:3000/mcp search_repos -- --query mtpcli" }
10899
10965
  ]
10900
10966
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modeltoolsprotocol/mtpcli",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,7 +17,7 @@
17
17
  "typecheck": "tsc --noEmit"
18
18
  },
19
19
  "dependencies": {
20
- "@modeltoolsprotocol/sdk": "^0.4.0",
20
+ "@modeltoolsprotocol/sdk": "^0.4.1",
21
21
  "commander": "^14.0.0",
22
22
  "jaro-winkler": "^0.2.8",
23
23
  "open": "^11.0.0",