@modeltoolsprotocol/mtpcli 1.1.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +8 -8
  2. package/dist/index.js +459 -698
  3. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -27,7 +27,6 @@ var __export = (target, all) => {
27
27
  });
28
28
  };
29
29
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
30
- var __promiseAll = (args) => Promise.all(args);
31
30
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
32
31
 
33
32
  // node_modules/commander/lib/error.js
@@ -2123,25 +2122,6 @@ var require_commander = __commonJS((exports) => {
2123
2122
  exports.InvalidOptionArgumentError = InvalidArgumentError;
2124
2123
  });
2125
2124
 
2126
- // node_modules/commander/esm.mjs
2127
- var import__, program, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help;
2128
- var init_esm = __esm(() => {
2129
- import__ = __toESM(require_commander(), 1);
2130
- ({
2131
- program,
2132
- createCommand,
2133
- createArgument,
2134
- createOption,
2135
- CommanderError,
2136
- InvalidArgumentError,
2137
- InvalidOptionArgumentError,
2138
- Command,
2139
- Argument,
2140
- Option,
2141
- Help
2142
- } = import__.default);
2143
- });
2144
-
2145
2125
  // node_modules/zod/v3/helpers/util.js
2146
2126
  var util, objectUtil, ZodParsedType, getParsedType = (data) => {
2147
2127
  const t = typeof data;
@@ -6108,38 +6088,21 @@ var init_zod = __esm(() => {
6108
6088
  init_external();
6109
6089
  });
6110
6090
 
6111
- // src/models.ts
6112
- function cleanJson(obj) {
6113
- if (obj === null || obj === undefined)
6114
- return;
6115
- if (Array.isArray(obj)) {
6116
- return obj.map(cleanJson);
6117
- }
6118
- if (typeof obj === "object") {
6119
- const out = {};
6120
- for (const [k, v] of Object.entries(obj)) {
6121
- if (v === undefined)
6122
- continue;
6123
- if (Array.isArray(v) && v.length === 0)
6124
- continue;
6125
- const cleaned = cleanJson(v);
6126
- if (cleaned !== undefined) {
6127
- out[k] = cleaned;
6128
- }
6129
- }
6130
- return out;
6131
- }
6132
- return obj;
6133
- }
6134
- var ExampleSchema, ArgSchema, IoDescriptorSchema, CommandAuthSchema, CommandSchema, AuthProviderSchema, AuthConfigSchema, ToolSchemaSchema, StoredTokenSchema, JsonRpcErrorSchema, JsonRpcRequestSchema, JsonRpcResponseSchema, McpToolDefSchema;
6135
- var init_models = __esm(() => {
6091
+ // node_modules/@modeltoolsprotocol/sdk/src/schemas.ts
6092
+ var MTP_SPEC_VERSION = "2026-02-07", ExampleSchema, IODescriptorSchema, ArgDescriptorSchema, CommandAuthSchema, CommandDescriptorSchema, AuthProviderSchema, AuthConfigSchema, ToolSchemaSchema;
6093
+ var init_schemas = __esm(() => {
6136
6094
  init_zod();
6137
6095
  ExampleSchema = exports_external.object({
6138
6096
  description: exports_external.string().optional(),
6139
6097
  command: exports_external.string(),
6140
6098
  output: exports_external.string().optional()
6141
6099
  });
6142
- ArgSchema = exports_external.object({
6100
+ IODescriptorSchema = exports_external.object({
6101
+ contentType: exports_external.string().optional(),
6102
+ description: exports_external.string().optional(),
6103
+ schema: exports_external.any().optional()
6104
+ });
6105
+ ArgDescriptorSchema = exports_external.object({
6143
6106
  name: exports_external.string(),
6144
6107
  type: exports_external.string(),
6145
6108
  description: exports_external.string().optional(),
@@ -6147,21 +6110,16 @@ var init_models = __esm(() => {
6147
6110
  default: exports_external.any().optional(),
6148
6111
  values: exports_external.array(exports_external.string()).optional()
6149
6112
  });
6150
- IoDescriptorSchema = exports_external.object({
6151
- contentType: exports_external.string().optional(),
6152
- description: exports_external.string().optional(),
6153
- schema: exports_external.any().optional()
6154
- });
6155
6113
  CommandAuthSchema = exports_external.object({
6156
6114
  required: exports_external.boolean().default(false),
6157
6115
  scopes: exports_external.array(exports_external.string()).optional()
6158
6116
  });
6159
- CommandSchema = exports_external.object({
6117
+ CommandDescriptorSchema = exports_external.object({
6160
6118
  name: exports_external.string(),
6161
6119
  description: exports_external.string(),
6162
- args: exports_external.array(ArgSchema).default([]),
6163
- stdin: IoDescriptorSchema.optional(),
6164
- stdout: IoDescriptorSchema.optional(),
6120
+ args: exports_external.array(ArgDescriptorSchema).default([]),
6121
+ stdin: IODescriptorSchema.optional(),
6122
+ stdout: IODescriptorSchema.optional(),
6165
6123
  examples: exports_external.array(ExampleSchema).default([]),
6166
6124
  auth: CommandAuthSchema.optional()
6167
6125
  });
@@ -6182,45 +6140,148 @@ var init_models = __esm(() => {
6182
6140
  providers: exports_external.array(AuthProviderSchema)
6183
6141
  });
6184
6142
  ToolSchemaSchema = exports_external.object({
6143
+ specVersion: exports_external.string(),
6185
6144
  name: exports_external.string(),
6186
6145
  version: exports_external.string(),
6187
6146
  description: exports_external.string(),
6188
6147
  auth: AuthConfigSchema.optional(),
6189
- commands: exports_external.array(CommandSchema)
6190
- });
6191
- StoredTokenSchema = exports_external.object({
6192
- access_token: exports_external.string(),
6193
- token_type: exports_external.string().optional(),
6194
- refresh_token: exports_external.string().optional(),
6195
- expires_at: exports_external.string().optional(),
6196
- scopes: exports_external.array(exports_external.string()).optional(),
6197
- provider_id: exports_external.string(),
6198
- created_at: exports_external.string()
6199
- });
6200
- JsonRpcErrorSchema = exports_external.object({
6201
- code: exports_external.number(),
6202
- message: exports_external.string(),
6203
- data: exports_external.any().optional()
6204
- });
6205
- JsonRpcRequestSchema = exports_external.object({
6206
- jsonrpc: exports_external.string(),
6207
- id: exports_external.any().optional(),
6208
- method: exports_external.string(),
6209
- params: exports_external.any().default({})
6210
- });
6211
- JsonRpcResponseSchema = exports_external.object({
6212
- jsonrpc: exports_external.string(),
6213
- id: exports_external.any().optional(),
6214
- result: exports_external.any().optional(),
6215
- error: JsonRpcErrorSchema.optional()
6216
- });
6217
- McpToolDefSchema = exports_external.object({
6218
- name: exports_external.string(),
6219
- description: exports_external.string(),
6220
- inputSchema: exports_external.any()
6148
+ commands: exports_external.array(CommandDescriptorSchema)
6221
6149
  });
6222
6150
  });
6223
6151
 
6152
+ // node_modules/@modeltoolsprotocol/sdk/src/introspect.ts
6153
+ function extractArgFromOption(option, typeOverrides) {
6154
+ const name = option.long ?? option.short;
6155
+ const overrideType = typeOverrides?.[option.attributeName()];
6156
+ let type;
6157
+ let values;
6158
+ if (overrideType) {
6159
+ type = overrideType;
6160
+ } else if (option.argChoices) {
6161
+ type = "enum";
6162
+ values = [...option.argChoices];
6163
+ } else if (option.variadic) {
6164
+ type = "array";
6165
+ } else if (option.isBoolean()) {
6166
+ type = "boolean";
6167
+ } else {
6168
+ type = "string";
6169
+ }
6170
+ const arg = { name, type };
6171
+ if (option.description)
6172
+ arg.description = option.description;
6173
+ if (values)
6174
+ arg.values = values;
6175
+ arg.required = option.mandatory;
6176
+ if (option.defaultValue !== undefined) {
6177
+ let def = option.defaultValue;
6178
+ if ((type === "integer" || type === "number") && typeof def === "string" && !isNaN(Number(def))) {
6179
+ def = Number(def);
6180
+ }
6181
+ arg.default = def;
6182
+ }
6183
+ return arg;
6184
+ }
6185
+ function extractArgFromArgument(argument, typeOverrides) {
6186
+ const name = argument.name();
6187
+ const overrideType = typeOverrides?.[name];
6188
+ let type;
6189
+ let values;
6190
+ if (overrideType) {
6191
+ type = overrideType;
6192
+ } else if (argument.argChoices) {
6193
+ type = "enum";
6194
+ values = [...argument.argChoices];
6195
+ } else if (argument.variadic) {
6196
+ type = "array";
6197
+ } else {
6198
+ type = "string";
6199
+ }
6200
+ const arg = { name, type };
6201
+ if (argument.description)
6202
+ arg.description = argument.description;
6203
+ if (values)
6204
+ arg.values = values;
6205
+ arg.required = argument.required;
6206
+ if (argument.defaultValue !== undefined) {
6207
+ let def = argument.defaultValue;
6208
+ if ((type === "integer" || type === "number") && typeof def === "string" && !isNaN(Number(def))) {
6209
+ def = Number(def);
6210
+ }
6211
+ arg.default = def;
6212
+ }
6213
+ return arg;
6214
+ }
6215
+ function isFilteredOption(option, cmd, describeOptionName) {
6216
+ if (option.hidden)
6217
+ return true;
6218
+ const internals = cmd;
6219
+ if (internals._helpOption && option === internals._helpOption)
6220
+ return true;
6221
+ if (internals._versionOptionName && option.attributeName() === internals._versionOptionName)
6222
+ return true;
6223
+ if (describeOptionName && option.attributeName() === describeOptionName)
6224
+ return true;
6225
+ return false;
6226
+ }
6227
+ function walkCommands(cmd, annotations, parentPath, describeOptionName) {
6228
+ const internals = cmd;
6229
+ const visibleSubcommands = cmd.commands.filter((sub) => !sub._hidden);
6230
+ if (visibleSubcommands.length === 0) {
6231
+ const name = parentPath || "_root";
6232
+ return [buildCommand(cmd, name, annotations?.[name], describeOptionName)];
6233
+ }
6234
+ const results = [];
6235
+ for (const sub of visibleSubcommands) {
6236
+ const subName = parentPath ? `${parentPath} ${sub.name()}` : sub.name();
6237
+ results.push(...walkCommands(sub, annotations, subName, describeOptionName));
6238
+ }
6239
+ return results;
6240
+ }
6241
+ function buildCommand(cmd, name, annotation, describeOptionName) {
6242
+ const descriptor = {
6243
+ name,
6244
+ description: cmd.description() || ""
6245
+ };
6246
+ const args = [];
6247
+ const typeOverrides = annotation?.argTypes;
6248
+ for (const arg of cmd.registeredArguments) {
6249
+ args.push(extractArgFromArgument(arg, typeOverrides));
6250
+ }
6251
+ for (const opt of cmd.options) {
6252
+ if (isFilteredOption(opt, cmd, describeOptionName))
6253
+ continue;
6254
+ args.push(extractArgFromOption(opt, typeOverrides));
6255
+ }
6256
+ if (args.length > 0)
6257
+ descriptor.args = args;
6258
+ if (annotation?.stdin)
6259
+ descriptor.stdin = annotation.stdin;
6260
+ if (annotation?.stdout)
6261
+ descriptor.stdout = annotation.stdout;
6262
+ if (annotation?.examples && annotation.examples.length > 0)
6263
+ descriptor.examples = annotation.examples;
6264
+ if (annotation?.auth)
6265
+ descriptor.auth = annotation.auth;
6266
+ return descriptor;
6267
+ }
6268
+ function generateSchema(program2, options) {
6269
+ const internals = program2;
6270
+ const schema = {
6271
+ specVersion: MTP_SPEC_VERSION,
6272
+ name: program2.name(),
6273
+ version: internals._version || "",
6274
+ description: program2.description() || "",
6275
+ commands: walkCommands(program2, options?.commands, undefined, "mtpDescribe")
6276
+ };
6277
+ if (options?.auth)
6278
+ schema.auth = options.auth;
6279
+ return schema;
6280
+ }
6281
+ var init_introspect = __esm(() => {
6282
+ init_schemas();
6283
+ });
6284
+
6224
6285
  // node_modules/jaro-winkler/index.js
6225
6286
  var require_jaro_winkler = __commonJS((exports, module) => {
6226
6287
  (function(root) {
@@ -6554,6 +6615,12 @@ var require_lib = __commonJS((exports, module) => {
6554
6615
  which.sync = whichSync;
6555
6616
  });
6556
6617
 
6618
+ // node_modules/@modeltoolsprotocol/sdk/src/index.ts
6619
+ var init_src = __esm(() => {
6620
+ init_introspect();
6621
+ init_schemas();
6622
+ });
6623
+
6557
6624
  // src/models.ts
6558
6625
  function jsonRpcSuccess(id, result) {
6559
6626
  return { jsonrpc: "2.0", id, result };
@@ -6561,64 +6628,11 @@ function jsonRpcSuccess(id, result) {
6561
6628
  function jsonRpcError(id, code, message) {
6562
6629
  return { jsonrpc: "2.0", id, error: { code, message } };
6563
6630
  }
6564
- var ExampleSchema2, ArgSchema2, IoDescriptorSchema2, CommandAuthSchema2, CommandSchema2, AuthProviderSchema2, AuthConfigSchema2, ToolSchemaSchema2, StoredTokenSchema2, JsonRpcErrorSchema2, JsonRpcRequestSchema2, JsonRpcResponseSchema2, McpToolDefSchema2;
6565
- var init_models2 = __esm(() => {
6631
+ var StoredTokenSchema, JsonRpcErrorSchema, JsonRpcRequestSchema, JsonRpcResponseSchema, McpToolDefSchema;
6632
+ var init_models = __esm(() => {
6566
6633
  init_zod();
6567
- ExampleSchema2 = exports_external.object({
6568
- description: exports_external.string().optional(),
6569
- command: exports_external.string(),
6570
- output: exports_external.string().optional()
6571
- });
6572
- ArgSchema2 = exports_external.object({
6573
- name: exports_external.string(),
6574
- type: exports_external.string(),
6575
- description: exports_external.string().optional(),
6576
- required: exports_external.boolean().default(false),
6577
- default: exports_external.any().optional(),
6578
- values: exports_external.array(exports_external.string()).optional()
6579
- });
6580
- IoDescriptorSchema2 = exports_external.object({
6581
- contentType: exports_external.string().optional(),
6582
- description: exports_external.string().optional(),
6583
- schema: exports_external.any().optional()
6584
- });
6585
- CommandAuthSchema2 = exports_external.object({
6586
- required: exports_external.boolean().default(false),
6587
- scopes: exports_external.array(exports_external.string()).optional()
6588
- });
6589
- CommandSchema2 = exports_external.object({
6590
- name: exports_external.string(),
6591
- description: exports_external.string(),
6592
- args: exports_external.array(ArgSchema2).default([]),
6593
- stdin: IoDescriptorSchema2.optional(),
6594
- stdout: IoDescriptorSchema2.optional(),
6595
- examples: exports_external.array(ExampleSchema2).default([]),
6596
- auth: CommandAuthSchema2.optional()
6597
- });
6598
- AuthProviderSchema2 = exports_external.object({
6599
- id: exports_external.string(),
6600
- type: exports_external.string(),
6601
- displayName: exports_external.string().optional(),
6602
- authorizationUrl: exports_external.string().optional(),
6603
- tokenUrl: exports_external.string().optional(),
6604
- scopes: exports_external.array(exports_external.string()).optional(),
6605
- clientId: exports_external.string().optional(),
6606
- registrationUrl: exports_external.string().optional(),
6607
- instructions: exports_external.string().optional()
6608
- });
6609
- AuthConfigSchema2 = exports_external.object({
6610
- required: exports_external.boolean().default(false),
6611
- envVar: exports_external.string(),
6612
- providers: exports_external.array(AuthProviderSchema2)
6613
- });
6614
- ToolSchemaSchema2 = exports_external.object({
6615
- name: exports_external.string(),
6616
- version: exports_external.string(),
6617
- description: exports_external.string(),
6618
- auth: AuthConfigSchema2.optional(),
6619
- commands: exports_external.array(CommandSchema2)
6620
- });
6621
- StoredTokenSchema2 = exports_external.object({
6634
+ init_src();
6635
+ StoredTokenSchema = exports_external.object({
6622
6636
  access_token: exports_external.string(),
6623
6637
  token_type: exports_external.string().optional(),
6624
6638
  refresh_token: exports_external.string().optional(),
@@ -6627,24 +6641,24 @@ var init_models2 = __esm(() => {
6627
6641
  provider_id: exports_external.string(),
6628
6642
  created_at: exports_external.string()
6629
6643
  });
6630
- JsonRpcErrorSchema2 = exports_external.object({
6644
+ JsonRpcErrorSchema = exports_external.object({
6631
6645
  code: exports_external.number(),
6632
6646
  message: exports_external.string(),
6633
6647
  data: exports_external.any().optional()
6634
6648
  });
6635
- JsonRpcRequestSchema2 = exports_external.object({
6649
+ JsonRpcRequestSchema = exports_external.object({
6636
6650
  jsonrpc: exports_external.string(),
6637
6651
  id: exports_external.any().optional(),
6638
6652
  method: exports_external.string(),
6639
6653
  params: exports_external.any().default({})
6640
6654
  });
6641
- JsonRpcResponseSchema2 = exports_external.object({
6655
+ JsonRpcResponseSchema = exports_external.object({
6642
6656
  jsonrpc: exports_external.string(),
6643
6657
  id: exports_external.any().optional(),
6644
6658
  result: exports_external.any().optional(),
6645
- error: JsonRpcErrorSchema2.optional()
6659
+ error: JsonRpcErrorSchema.optional()
6646
6660
  });
6647
- McpToolDefSchema2 = exports_external.object({
6661
+ McpToolDefSchema = exports_external.object({
6648
6662
  name: exports_external.string(),
6649
6663
  description: exports_external.string(),
6650
6664
  inputSchema: exports_external.any()
@@ -6705,10 +6719,10 @@ async function getToolSchema(toolName) {
6705
6719
  return null;
6706
6720
  }
6707
6721
  try {
6708
- const { stdout } = await execFileAsync(toolPath, ["--describe"], {
6722
+ const { stdout } = await execFileAsync(toolPath, ["--mtp-describe"], {
6709
6723
  timeout: 5000
6710
6724
  });
6711
- return ToolSchemaSchema2.parse(JSON.parse(stdout.trim()));
6725
+ return ToolSchemaSchema.parse(JSON.parse(stdout.trim()));
6712
6726
  } catch {
6713
6727
  return null;
6714
6728
  }
@@ -6731,7 +6745,7 @@ function readAllCached() {
6731
6745
  continue;
6732
6746
  try {
6733
6747
  const data = readFileSync(join(dir, entry), "utf-8");
6734
- schemas.push(ToolSchemaSchema2.parse(JSON.parse(data)));
6748
+ schemas.push(ToolSchemaSchema.parse(JSON.parse(data)));
6735
6749
  } catch {}
6736
6750
  }
6737
6751
  return schemas;
@@ -6803,7 +6817,7 @@ async function loadSchemas(toolNames) {
6803
6817
  writeCache(schema.name, schema);
6804
6818
  schemas.push(schema);
6805
6819
  } else {
6806
- process.stderr.write(`warning: could not get --describe from '${name}'
6820
+ process.stderr.write(`warning: could not get --mtp-describe from '${name}'
6807
6821
  `);
6808
6822
  }
6809
6823
  }
@@ -6811,7 +6825,7 @@ async function loadSchemas(toolNames) {
6811
6825
  }
6812
6826
  var import_jaro_winkler, import_which, execFileAsync;
6813
6827
  var init_search = __esm(() => {
6814
- init_models2();
6828
+ init_models();
6815
6829
  import_jaro_winkler = __toESM(require_jaro_winkler(), 1);
6816
6830
  import_which = __toESM(require_lib(), 1);
6817
6831
  execFileAsync = promisify(execFile);
@@ -7457,17 +7471,17 @@ async function getToolSchema2(toolName) {
7457
7471
  return null;
7458
7472
  }
7459
7473
  try {
7460
- const { stdout } = await execFileAsync6(toolPath, ["--describe"], {
7474
+ const { stdout } = await execFileAsync6(toolPath, ["--mtp-describe"], {
7461
7475
  timeout: 5000
7462
7476
  });
7463
- return ToolSchemaSchema2.parse(JSON.parse(stdout.trim()));
7477
+ return ToolSchemaSchema.parse(JSON.parse(stdout.trim()));
7464
7478
  } catch {
7465
7479
  return null;
7466
7480
  }
7467
7481
  }
7468
7482
  var import_jaro_winkler2, import_which2, execFileAsync6;
7469
7483
  var init_search2 = __esm(() => {
7470
- init_models2();
7484
+ init_models();
7471
7485
  import_jaro_winkler2 = __toESM(require_jaro_winkler(), 1);
7472
7486
  import_which2 = __toESM(require_lib(), 1);
7473
7487
  execFileAsync6 = promisify8(execFile8);
@@ -8810,7 +8824,7 @@ function readResponse(rl) {
8810
8824
  rl.off("line", onLine);
8811
8825
  rl.off("close", onClose);
8812
8826
  try {
8813
- resolve(JsonRpcResponseSchema2.parse(msg));
8827
+ resolve(JsonRpcResponseSchema.parse(msg));
8814
8828
  } catch (e) {
8815
8829
  reject(e);
8816
8830
  }
@@ -8825,9 +8839,12 @@ function readResponse(rl) {
8825
8839
  });
8826
8840
  }
8827
8841
  var init_mcp = __esm(() => {
8828
- init_models2();
8842
+ init_models();
8829
8843
  });
8830
8844
 
8845
+ // src/version.ts
8846
+ var VERSION2 = "1.3.0";
8847
+
8831
8848
  // src/serve.ts
8832
8849
  var exports_serve = {};
8833
8850
  __export(exports_serve, {
@@ -8886,12 +8903,12 @@ function commandToMcpTool(toolName, cmd) {
8886
8903
  if (cmd.stdin.description && typeof prop === "object" && prop !== null) {
8887
8904
  prop.description = cmd.stdin.description;
8888
8905
  }
8889
- properties._stdin = prop;
8906
+ properties["mtp:stdin"] = prop;
8890
8907
  } else {
8891
8908
  const prop = { type: "string" };
8892
8909
  if (cmd.stdin.description)
8893
8910
  prop.description = cmd.stdin.description;
8894
- properties._stdin = prop;
8911
+ properties["mtp:stdin"] = prop;
8895
8912
  }
8896
8913
  }
8897
8914
  const inputSchema = {
@@ -8950,8 +8967,8 @@ function buildCliCommand(toolName, commandName, arguments_, commandSchema) {
8950
8967
  }
8951
8968
  function invokeCliTool(toolName, commandName, arguments_, commandSchema, authEnv) {
8952
8969
  const argsForCli = { ...arguments_ };
8953
- const stdinData = argsForCli._stdin;
8954
- delete argsForCli._stdin;
8970
+ const stdinData = argsForCli["mtp:stdin"];
8971
+ delete argsForCli["mtp:stdin"];
8955
8972
  const stdinStr = stdinData !== undefined ? typeof stdinData === "string" ? stdinData : JSON.stringify(stdinData) : undefined;
8956
8973
  const cmd = buildCliCommand(toolName, commandName, argsForCli, commandSchema);
8957
8974
  return new Promise((resolve) => {
@@ -9020,7 +9037,7 @@ async function handleRequest(state, req) {
9020
9037
  return jsonRpcSuccess(id, {
9021
9038
  protocolVersion: "2024-11-05",
9022
9039
  capabilities: { tools: {} },
9023
- serverInfo: { name: "mtpcli-serve", version: VERSION }
9040
+ serverInfo: { name: "mtpcli-serve", version: VERSION2 }
9024
9041
  });
9025
9042
  case "notifications/initialized":
9026
9043
  return null;
@@ -9062,7 +9079,7 @@ async function run(toolNames) {
9062
9079
  for (const name of toolNames) {
9063
9080
  const schema = await getToolSchema2(name);
9064
9081
  if (!schema)
9065
- throw new Error(`could not get --describe from '${name}'`);
9082
+ throw new Error(`could not get --mtp-describe from '${name}'`);
9066
9083
  if (schema.auth)
9067
9084
  allAuth.set(name, schema.auth);
9068
9085
  for (const cmd of schema.commands) {
@@ -9095,7 +9112,7 @@ async function run(toolNames) {
9095
9112
  continue;
9096
9113
  let req;
9097
9114
  try {
9098
- req = JsonRpcRequestSchema2.parse(JSON.parse(trimmed));
9115
+ req = JsonRpcRequestSchema.parse(JSON.parse(trimmed));
9099
9116
  } catch (e) {
9100
9117
  const msg = e instanceof Error ? e.message : String(e);
9101
9118
  process.stderr.write(`error reading request: ${msg}
@@ -9110,12 +9127,11 @@ async function run(toolNames) {
9110
9127
  }
9111
9128
  }
9112
9129
  var execFileAsync7, TOOL_TIMEOUT_MS = 60000, MAX_OUTPUT_BYTES;
9113
- var init_serve = __esm(async () => {
9130
+ var init_serve = __esm(() => {
9114
9131
  init_auth();
9115
9132
  init_mcp();
9116
- init_models2();
9133
+ init_models();
9117
9134
  init_search2();
9118
- await init_src();
9119
9135
  execFileAsync7 = promisify9(execFile9);
9120
9136
  MAX_OUTPUT_BYTES = 1024 * 1024 * 1024;
9121
9137
  });
@@ -9567,8 +9583,8 @@ function mcpToolToCommand(tool) {
9567
9583
  ...inputSchema.properties ?? {}
9568
9584
  };
9569
9585
  const requiredFields = (inputSchema.required ?? []).filter((v) => typeof v === "string");
9570
- const stdinProp = allProperties._stdin;
9571
- delete allProperties._stdin;
9586
+ const stdinProp = allProperties["mtp:stdin"];
9587
+ delete allProperties["mtp:stdin"];
9572
9588
  let stdin;
9573
9589
  if (stdinProp) {
9574
9590
  const propType = stdinProp.type;
@@ -9684,7 +9700,7 @@ class McpClient {
9684
9700
  client.sendRequest("initialize", {
9685
9701
  protocolVersion: "2024-11-05",
9686
9702
  capabilities: {},
9687
- clientInfo: { name: "mtpcli-wrap", version: VERSION }
9703
+ clientInfo: { name: "mtpcli-wrap", version: VERSION2 }
9688
9704
  });
9689
9705
  await client.readResponse();
9690
9706
  client.sendNotification("notifications/initialized", {});
@@ -9745,7 +9761,7 @@ class HttpMcpClient {
9745
9761
  const initResult = await client.sendRequest("initialize", {
9746
9762
  protocolVersion: "2025-11-25",
9747
9763
  capabilities: {},
9748
- clientInfo: { name: "mtpcli-wrap", version: VERSION }
9764
+ clientInfo: { name: "mtpcli-wrap", version: VERSION2 }
9749
9765
  });
9750
9766
  client.protocolVersion = initResult.protocolVersion ?? "2025-11-25";
9751
9767
  await client.sendNotification("notifications/initialized", {});
@@ -9943,6 +9959,7 @@ async function run2(serverCmd, serverUrl, describeMode, toolName, toolArgs = [],
9943
9959
  const mcpTools = await client.listTools();
9944
9960
  const commands = mcpTools.map(mcpToolToCommand);
9945
9961
  const schema = {
9962
+ specVersion: MTP_SPEC_VERSION,
9946
9963
  name: serverName,
9947
9964
  version: "0.1.0",
9948
9965
  description: `CLI wrapper for MCP server: ${serverName}`,
@@ -9966,9 +9983,9 @@ async function run2(serverCmd, serverUrl, describeMode, toolName, toolArgs = [],
9966
9983
  const stdinData = Buffer.concat(chunks).toString("utf-8");
9967
9984
  if (stdinData) {
9968
9985
  try {
9969
- parsed._stdin = JSON.parse(stdinData);
9986
+ parsed["mtp:stdin"] = JSON.parse(stdinData);
9970
9987
  } catch {
9971
- parsed._stdin = stdinData;
9988
+ parsed["mtp:stdin"] = stdinData;
9972
9989
  }
9973
9990
  }
9974
9991
  }
@@ -9987,9 +10004,9 @@ async function run2(serverCmd, serverUrl, describeMode, toolName, toolArgs = [],
9987
10004
  client.stop();
9988
10005
  }
9989
10006
  }
9990
- var init_wrap = __esm(async () => {
10007
+ var init_wrap = __esm(() => {
9991
10008
  init_mcp();
9992
- await init_src();
10009
+ init_models();
9993
10010
  });
9994
10011
 
9995
10012
  // src/validate.ts
@@ -10015,7 +10032,7 @@ function validateJson(raw) {
10015
10032
  });
10016
10033
  return diags;
10017
10034
  }
10018
- const result = ToolSchemaSchema2.safeParse(parsed);
10035
+ const result = ToolSchemaSchema.safeParse(parsed);
10019
10036
  if (!result.success) {
10020
10037
  for (const issue of result.error.issues) {
10021
10038
  diags.push({
@@ -10080,7 +10097,7 @@ function crossReferenceHelp(schema, helpText) {
10080
10097
  }
10081
10098
  helpFlags.delete("--help");
10082
10099
  helpFlags.delete("--version");
10083
- helpFlags.delete("--describe");
10100
+ helpFlags.delete("--mtp-describe");
10084
10101
  const declaredFlags = new Set;
10085
10102
  for (const cmd of schema.commands) {
10086
10103
  for (const arg of cmd.args) {
@@ -10094,7 +10111,7 @@ function crossReferenceHelp(schema, helpText) {
10094
10111
  diags.push({
10095
10112
  level: "info",
10096
10113
  code: "HELP_ARG_MISMATCH",
10097
- message: `Flag "${flag}" in --describe but not found in --help`
10114
+ message: `Flag "${flag}" in --mtp-describe but not found in --help`
10098
10115
  });
10099
10116
  }
10100
10117
  }
@@ -10103,7 +10120,7 @@ function crossReferenceHelp(schema, helpText) {
10103
10120
  diags.push({
10104
10121
  level: "info",
10105
10122
  code: "HELP_ARG_MISMATCH",
10106
- message: `Flag "${flag}" in --help but not found in --describe`
10123
+ message: `Flag "${flag}" in --help but not found in --mtp-describe`
10107
10124
  });
10108
10125
  }
10109
10126
  }
@@ -10124,7 +10141,7 @@ async function validateTool(toolName, opts) {
10124
10141
  }
10125
10142
  let describeOutput;
10126
10143
  try {
10127
- const { stdout } = await execFileAsync8(toolPath, ["--describe"], {
10144
+ const { stdout } = await execFileAsync8(toolPath, ["--mtp-describe"], {
10128
10145
  timeout: 1e4
10129
10146
  });
10130
10147
  describeOutput = stdout.trim();
@@ -10132,7 +10149,7 @@ async function validateTool(toolName, opts) {
10132
10149
  diags.push({
10133
10150
  level: "error",
10134
10151
  code: "DESCRIBE_FAILED",
10135
- message: `"${toolName} --describe" produced empty output`
10152
+ message: `"${toolName} --mtp-describe" produced empty output`
10136
10153
  });
10137
10154
  return buildResult(toolName, diags);
10138
10155
  }
@@ -10140,7 +10157,7 @@ async function validateTool(toolName, opts) {
10140
10157
  diags.push({
10141
10158
  level: "error",
10142
10159
  code: "DESCRIBE_FAILED",
10143
- message: `"${toolName} --describe" failed: ${e instanceof Error ? e.message : e}`
10160
+ message: `"${toolName} --mtp-describe" failed: ${e instanceof Error ? e.message : e}`
10144
10161
  });
10145
10162
  return buildResult(toolName, diags);
10146
10163
  }
@@ -10151,7 +10168,7 @@ async function validateTool(toolName, opts) {
10151
10168
  const { stdout: helpText } = await execFileAsync8(toolPath, ["--help"], {
10152
10169
  timeout: 5000
10153
10170
  });
10154
- const schema = ToolSchemaSchema2.parse(JSON.parse(describeOutput));
10171
+ const schema = ToolSchemaSchema.parse(JSON.parse(describeOutput));
10155
10172
  diags.push(...crossReferenceHelp(schema, helpText));
10156
10173
  } catch {}
10157
10174
  }
@@ -10213,7 +10230,7 @@ function printHuman(result) {
10213
10230
  }
10214
10231
  var import_which3, execFileAsync8, VALID_ARG_TYPES;
10215
10232
  var init_validate = __esm(() => {
10216
- init_models2();
10233
+ init_models();
10217
10234
  import_which3 = __toESM(require_lib(), 1);
10218
10235
  execFileAsync8 = promisify10(execFile10);
10219
10236
  VALID_ARG_TYPES = new Set([
@@ -10590,7 +10607,7 @@ async function run4(shell, toolName) {
10590
10607
  }
10591
10608
  const schema = await getToolSchema2(toolName);
10592
10609
  if (!schema) {
10593
- process.stderr.write(`error: could not get --describe from "${toolName}"
10610
+ process.stderr.write(`error: could not get --mtp-describe from "${toolName}"
10594
10611
  `);
10595
10612
  process.exit(1);
10596
10613
  }
@@ -10600,480 +10617,153 @@ var init_completions = __esm(() => {
10600
10617
  init_search2();
10601
10618
  });
10602
10619
 
10603
- // src/index.ts
10604
- function selfDescribe() {
10605
- const schema = {
10606
- name: "mtpcli",
10607
- version: VERSION,
10608
- description: "Unified CLI for discovering, authenticating, and bridging --describe-compatible tools",
10609
- commands: [
10610
- {
10611
- name: "search",
10612
- description: "Search across --describe-compatible tools for commands matching a query",
10613
- args: [
10614
- {
10615
- name: "query",
10616
- type: "string",
10617
- required: true,
10618
- description: "Search query"
10619
- },
10620
- {
10621
- name: "--json",
10622
- type: "boolean",
10623
- default: false,
10624
- description: "Output as JSON"
10625
- },
10626
- {
10627
- name: "--scan-path",
10628
- type: "boolean",
10629
- default: false,
10630
- description: "Scan PATH for tools"
10631
- },
10632
- {
10633
- name: "--jobs",
10634
- type: "integer",
10635
- default: 16,
10636
- description: "Parallel jobs for scan-path"
10637
- }
10638
- ],
10639
- examples: [
10640
- {
10641
- description: "Search specific tools",
10642
- command: 'mtpcli search "convert files" -- filetool mytool'
10643
- },
10644
- {
10645
- description: "Search cached tools",
10646
- command: 'mtpcli search "deploy"'
10647
- },
10648
- {
10649
- description: "Scan PATH and search",
10650
- command: 'mtpcli search --scan-path "git commit"'
10651
- }
10652
- ]
10653
- },
10654
- {
10655
- name: "auth login",
10656
- description: "Authenticate with a tool (OAuth2, API key, or bearer token)",
10657
- args: [
10658
- {
10659
- name: "tool",
10660
- type: "string",
10661
- description: "Tool name (required unless --url is used)"
10662
- },
10663
- {
10664
- name: "--provider",
10665
- type: "string",
10666
- description: "Specific auth provider ID"
10667
- },
10668
- {
10669
- name: "--token",
10670
- type: "string",
10671
- description: "API key or bearer token"
10672
- },
10673
- {
10674
- name: "--url",
10675
- type: "string",
10676
- description: "HTTP MCP server URL (triggers OAuth discovery and login)"
10677
- },
10678
- {
10679
- name: "--client-id",
10680
- type: "string",
10681
- description: "Pre-registered OAuth client ID (for --url)"
10682
- }
10683
- ],
10684
- examples: [
10685
- { description: "OAuth2 login", command: "mtpcli auth login gh-tool" },
10686
- {
10687
- description: "API key login",
10688
- command: "mtpcli auth login my-tool --token sk-xxx"
10689
- },
10690
- {
10691
- description: "Login to HTTP MCP server",
10692
- command: "mtpcli auth login --url https://mcp.example.com/v1/mcp"
10693
- }
10694
- ]
10695
- },
10696
- {
10697
- name: "auth logout",
10698
- description: "Remove stored tokens for a tool",
10699
- args: [
10700
- {
10701
- name: "tool",
10702
- type: "string",
10703
- description: "Tool name (required unless --url is used)"
10704
- },
10705
- {
10706
- name: "--url",
10707
- type: "string",
10708
- description: "HTTP MCP server URL"
10709
- }
10710
- ],
10711
- examples: [
10712
- { command: "mtpcli auth logout gh-tool" },
10713
- {
10714
- description: "Logout from HTTP MCP server",
10715
- command: "mtpcli auth logout --url https://mcp.example.com/v1/mcp"
10716
- }
10717
- ]
10718
- },
10719
- {
10720
- name: "auth status",
10721
- description: "Show authentication status for a tool",
10722
- args: [
10723
- {
10724
- name: "tool",
10725
- type: "string",
10726
- description: "Tool name (required unless --url is used)"
10727
- },
10728
- {
10729
- name: "--url",
10730
- type: "string",
10731
- description: "HTTP MCP server URL"
10732
- }
10733
- ],
10734
- examples: [
10735
- { command: "mtpcli auth status gh-tool" },
10736
- {
10737
- description: "Status for HTTP MCP server",
10738
- command: "mtpcli auth status --url https://mcp.example.com/v1/mcp"
10739
- }
10740
- ]
10741
- },
10742
- {
10743
- name: "auth token",
10744
- description: "Print the access token for a tool",
10745
- args: [
10746
- {
10747
- name: "tool",
10748
- type: "string",
10749
- description: "Tool name (required unless --url is used)"
10750
- },
10751
- {
10752
- name: "--url",
10753
- type: "string",
10754
- description: "HTTP MCP server URL"
10755
- }
10756
- ],
10757
- examples: [
10758
- { command: "mtpcli auth token gh-tool" },
10759
- {
10760
- description: "Token for HTTP MCP server",
10761
- command: "mtpcli auth token --url https://mcp.example.com/v1/mcp"
10762
- }
10763
- ]
10764
- },
10765
- {
10766
- name: "auth env",
10767
- description: "Print shell export statement for eval $(mtpcli auth env <tool>)",
10768
- args: [
10769
- {
10770
- name: "tool",
10771
- type: "string",
10772
- required: true,
10773
- description: "Tool name"
10774
- }
10775
- ],
10776
- examples: [{ command: "eval $(mtpcli auth env gh-tool)" }]
10777
- },
10778
- {
10779
- name: "auth refresh",
10780
- description: "Force-refresh the stored OAuth token for a tool",
10781
- args: [
10782
- {
10783
- name: "tool",
10784
- type: "string",
10785
- description: "Tool name (required unless --url is used)"
10786
- },
10787
- {
10788
- name: "--url",
10789
- type: "string",
10790
- description: "HTTP MCP server URL"
10791
- }
10792
- ],
10793
- examples: [
10794
- { command: "mtpcli auth refresh gh-tool" },
10795
- {
10796
- description: "Refresh token for HTTP MCP server",
10797
- command: "mtpcli auth refresh --url https://mcp.example.com/v1/mcp"
10798
- }
10799
- ]
10800
- },
10801
- {
10802
- name: "serve",
10803
- description: "Serve CLI tools as an MCP server over stdio. Not meant to be run directly; add to your MCP client config instead.",
10804
- args: [
10805
- {
10806
- name: "--tool",
10807
- type: "array",
10808
- required: true,
10809
- description: "Tool name(s) to serve (must support --describe)"
10810
- }
10811
- ],
10812
- examples: [
10813
- {
10814
- description: "Add to ~/.claude.json as an MCP server",
10815
- command: '{ "mcpServers": { "my-tools": { "type": "stdio", "command": "mtpcli", "args": ["serve", "--tool", "my-cli-tool"] } } }'
10816
- },
10817
- {
10818
- description: "Serve multiple tools in one MCP server",
10819
- command: '{ "mcpServers": { "my-tools": { "type": "stdio", "command": "mtpcli", "args": ["serve", "--tool", "tool1", "--tool", "tool2"] } } }'
10820
- }
10821
- ]
10822
- },
10823
- {
10824
- name: "wrap",
10825
- description: "Wrap an MCP server as a --describe-compatible CLI",
10826
- args: [
10827
- {
10828
- name: "--server",
10829
- type: "string",
10830
- description: "MCP server command (stdio transport)"
10831
- },
10832
- {
10833
- name: "--url",
10834
- type: "string",
10835
- description: "MCP server URL (Streamable HTTP transport). Mutually exclusive with --server."
10836
- },
10837
- {
10838
- name: "--header",
10839
- type: "array",
10840
- description: "HTTP header(s) for --url, e.g. 'Authorization: Bearer tok'. Repeatable."
10841
- },
10842
- {
10843
- name: "--client-id",
10844
- type: "string",
10845
- description: "Pre-registered OAuth client ID (for servers without dynamic registration)"
10846
- },
10847
- {
10848
- name: "--describe",
10849
- type: "boolean",
10850
- description: "Output --describe JSON"
10851
- },
10852
- {
10853
- name: "tool_name",
10854
- type: "string",
10855
- description: "Tool to invoke"
10856
- }
10857
- ],
10858
- examples: [
10859
- {
10860
- description: "Describe a stdio MCP server",
10861
- command: 'mtpcli wrap --server "npx @mcp/server-github" --describe'
10862
- },
10863
- {
10864
- description: "Call a tool on a stdio server",
10865
- command: 'mtpcli wrap --server "npx @mcp/server-github" search_repos -- --query mtpcli'
10866
- },
10867
- {
10868
- description: "Describe an HTTP MCP server",
10869
- command: "mtpcli wrap --url http://localhost:3000/mcp --describe"
10870
- },
10871
- {
10872
- description: "Call a tool on an HTTP server",
10873
- command: "mtpcli wrap --url http://localhost:3000/mcp search_repos -- --query mtpcli"
10874
- }
10875
- ]
10876
- },
10877
- {
10878
- name: "validate",
10879
- description: "Validate a tool's --describe output against the MTP spec",
10880
- args: [
10881
- {
10882
- name: "tool",
10883
- type: "string",
10884
- description: "Tool name to validate"
10885
- },
10886
- {
10887
- name: "--json",
10888
- type: "boolean",
10889
- default: false,
10890
- description: "Output as JSON"
10891
- },
10892
- {
10893
- name: "--stdin",
10894
- type: "boolean",
10895
- default: false,
10896
- description: "Read JSON from stdin instead of running tool"
10897
- },
10898
- {
10899
- name: "--skip-help",
10900
- type: "boolean",
10901
- default: false,
10902
- description: "Skip --help cross-reference check"
10903
- }
10904
- ],
10905
- examples: [
10906
- {
10907
- description: "Validate a tool",
10908
- command: "mtpcli validate mytool"
10909
- },
10910
- {
10911
- description: "Validate from stdin",
10912
- command: "cat describe.json | mtpcli validate --stdin"
10913
- },
10914
- {
10915
- description: "JSON output for CI",
10916
- command: "mtpcli validate mytool --json"
10917
- }
10918
- ]
10919
- },
10920
- {
10921
- name: "completions",
10922
- description: "Generate shell completions for a --describe-compatible tool",
10923
- args: [
10924
- {
10925
- name: "shell",
10926
- type: "enum",
10927
- required: true,
10928
- values: ["bash", "zsh", "fish"],
10929
- description: "Target shell"
10930
- },
10931
- {
10932
- name: "tool",
10933
- type: "string",
10934
- required: true,
10935
- description: "Tool name"
10936
- }
10937
- ],
10938
- examples: [
10939
- {
10940
- description: "Install bash completions",
10941
- command: "eval $(mtpcli completions bash mytool)"
10942
- },
10943
- {
10944
- description: "Install zsh completions",
10945
- command: "eval $(mtpcli completions zsh mytool)"
10946
- },
10947
- {
10948
- description: "Install fish completions",
10949
- command: "mtpcli completions fish mytool | source"
10950
- }
10951
- ]
10952
- }
10953
- ]
10954
- };
10955
- console.log(JSON.stringify(cleanJson(schema), null, 2));
10956
- }
10957
- var VERSION = "1.1.1", program2, authCmd;
10958
- var init_src = __esm(async () => {
10959
- init_esm();
10960
- init_models();
10961
- program2 = new Command().name("mtpcli").version(VERSION).description("Unified CLI for discovering, authenticating, and bridging --describe-compatible tools").option("--describe", "Print self-describing JSON (mtpcli spec)").action(async (opts) => {
10962
- if (opts.describe) {
10963
- selfDescribe();
10964
- return;
10965
- }
10966
- program2.help();
10620
+ // node_modules/commander/esm.mjs
10621
+ var import__ = __toESM(require_commander(), 1);
10622
+ var {
10623
+ program,
10624
+ createCommand,
10625
+ createArgument,
10626
+ createOption,
10627
+ CommanderError,
10628
+ InvalidArgumentError,
10629
+ InvalidOptionArgumentError,
10630
+ Command,
10631
+ Argument,
10632
+ Option,
10633
+ Help
10634
+ } = import__.default;
10635
+
10636
+ // node_modules/@modeltoolsprotocol/sdk/src/index.ts
10637
+ init_introspect();
10638
+ init_schemas();
10639
+ function describe(program2, options) {
10640
+ return generateSchema(program2, options);
10641
+ }
10642
+ function withDescribe(program2, options) {
10643
+ program2.option("--mtp-describe", "Output machine-readable MTP JSON schema");
10644
+ program2.on("option:mtp-describe", () => {
10645
+ const schema = describe(program2, options);
10646
+ const clean = JSON.parse(JSON.stringify(schema));
10647
+ console.log(JSON.stringify(clean, null, 2));
10648
+ process.exit(0);
10967
10649
  });
10968
- program2.command("search").description("Search across --describe-compatible tools").argument("<query>", "Search query").option("--json", "Output as JSON", false).option("--scan-path", "Scan PATH for --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) => {
10969
- const { search: search2, loadSchemas: loadSchemas2, scanPath: scanPath2 } = await Promise.resolve().then(() => (init_search(), exports_search));
10970
- const schemas = opts.scanPath ? await scanPath2(parseInt(opts.jobs, 10)) : await loadSchemas2(tools);
10971
- if (schemas.length === 0) {
10972
- process.stderr.write(`no tools found. Try: mtpcli search --scan-path "query"
10650
+ return program2;
10651
+ }
10652
+
10653
+ // src/version.ts
10654
+ var VERSION = "1.3.0";
10655
+
10656
+ // src/index.ts
10657
+ var program2 = new Command().name("mtpcli").version(VERSION).description("Unified CLI for discovering, authenticating, and bridging --mtp-describe-compatible tools");
10658
+ 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
+ const { search: search2, loadSchemas: loadSchemas2, scanPath: scanPath2 } = await Promise.resolve().then(() => (init_search(), exports_search));
10660
+ const schemas = opts.scanPath ? await scanPath2(parseInt(opts.jobs, 10)) : await loadSchemas2(tools);
10661
+ if (schemas.length === 0) {
10662
+ process.stderr.write(`no tools found. Try: mtpcli search --scan-path "query"
10973
10663
  `);
10974
- return;
10975
- }
10976
- const results = search2(query, schemas);
10977
- if (results.length === 0) {
10978
- process.stderr.write(`no results for "${query}"
10664
+ return;
10665
+ }
10666
+ const results = search2(query, schemas);
10667
+ if (results.length === 0) {
10668
+ process.stderr.write(`no results for "${query}"
10979
10669
  `);
10980
- return;
10981
- }
10982
- if (opts.json) {
10983
- console.log(JSON.stringify(results, null, 2));
10984
- } else {
10985
- for (const r of results) {
10986
- console.log(`${r.score.toFixed(1).padStart(6)} ${r.tool} ${r.command} ${r.description}`);
10987
- }
10988
- }
10989
- });
10990
- authCmd = program2.command("auth").description("Manage authentication for tools");
10991
- authCmd.command("login").description("Log in to a tool").argument("[tool]", "Tool name").option("--provider <id>", "Specific provider ID").option("--token <value>", "API key / bearer token (skip OAuth flow)").option("--url <url>", "HTTP MCP server URL (triggers OAuth discovery)").option("--client-id <id>", "Pre-registered OAuth client ID (for --url)").action(async (tool, opts) => {
10992
- if (opts.url) {
10993
- const { mcpOAuthFlow: mcpOAuthFlow3 } = await Promise.resolve().then(() => (init_mcp_oauth(), exports_mcp_oauth));
10994
- await mcpOAuthFlow3(opts.url, "", opts.clientId);
10995
- return;
10670
+ return;
10671
+ }
10672
+ if (opts.json) {
10673
+ console.log(JSON.stringify(results, null, 2));
10674
+ } else {
10675
+ for (const r of results) {
10676
+ console.log(`${r.score.toFixed(1).padStart(6)} ${r.tool} ${r.command} ${r.description}`);
10996
10677
  }
10997
- if (!tool) {
10998
- process.stderr.write(`error: tool name is required (or use --url)
10678
+ }
10679
+ });
10680
+ var authCmd = program2.command("auth").description("Manage authentication for tools");
10681
+ authCmd.command("login").description("Log in to a tool").argument("[tool]", "Tool name").option("--provider <id>", "Specific provider ID").option("--token <value>", "API key / bearer token (skip OAuth flow)").option("--url <url>", "HTTP MCP server URL (triggers OAuth discovery)").option("--client-id <id>", "Pre-registered OAuth client ID (for --url)").action(async (tool, opts) => {
10682
+ if (opts.url) {
10683
+ const { mcpOAuthFlow: mcpOAuthFlow3 } = await Promise.resolve().then(() => (init_mcp_oauth(), exports_mcp_oauth));
10684
+ await mcpOAuthFlow3(opts.url, "", opts.clientId);
10685
+ return;
10686
+ }
10687
+ if (!tool) {
10688
+ process.stderr.write(`error: tool name is required (or use --url)
10999
10689
  `);
11000
- process.exit(1);
11001
- }
11002
- const { runLogin: runLogin3 } = await Promise.resolve().then(() => (init_auth2(), exports_auth2));
11003
- await runLogin3(tool, opts.provider, opts.token);
11004
- });
11005
- authCmd.command("logout").description("Log out from a tool").argument("[tool]", "Tool name").option("--url <url>", "HTTP MCP server URL").action(async (tool, opts) => {
11006
- if (opts.url) {
11007
- const { mcpAuthLogout: mcpAuthLogout3 } = await Promise.resolve().then(() => (init_mcp_oauth(), exports_mcp_oauth));
11008
- const deleted = mcpAuthLogout3(opts.url);
11009
- if (deleted) {
11010
- process.stderr.write(`Logged out from ${opts.url}
10690
+ process.exit(1);
10691
+ }
10692
+ const { runLogin: runLogin3 } = await Promise.resolve().then(() => (init_auth2(), exports_auth2));
10693
+ await runLogin3(tool, opts.provider, opts.token);
10694
+ });
10695
+ authCmd.command("logout").description("Log out from a tool").argument("[tool]", "Tool name").option("--url <url>", "HTTP MCP server URL").action(async (tool, opts) => {
10696
+ if (opts.url) {
10697
+ const { mcpAuthLogout: mcpAuthLogout3 } = await Promise.resolve().then(() => (init_mcp_oauth(), exports_mcp_oauth));
10698
+ const deleted = mcpAuthLogout3(opts.url);
10699
+ if (deleted) {
10700
+ process.stderr.write(`Logged out from ${opts.url}
11011
10701
  `);
11012
- } else {
11013
- process.stderr.write(`No tokens found for ${opts.url}
10702
+ } else {
10703
+ process.stderr.write(`No tokens found for ${opts.url}
11014
10704
  `);
11015
- }
11016
- return;
11017
10705
  }
11018
- if (!tool) {
11019
- process.stderr.write(`error: tool name is required (or use --url)
10706
+ return;
10707
+ }
10708
+ if (!tool) {
10709
+ process.stderr.write(`error: tool name is required (or use --url)
11020
10710
  `);
11021
- process.exit(1);
11022
- }
11023
- const { runLogout: runLogout3 } = await Promise.resolve().then(() => (init_auth2(), exports_auth2));
11024
- await runLogout3(tool);
11025
- });
11026
- authCmd.command("status").description("Show auth status for a tool").argument("[tool]", "Tool name").option("--url <url>", "HTTP MCP server URL").action(async (tool, opts) => {
11027
- if (opts.url) {
11028
- const { mcpAuthStatus: mcpAuthStatus3 } = await Promise.resolve().then(() => (init_mcp_oauth(), exports_mcp_oauth));
11029
- console.log(JSON.stringify(mcpAuthStatus3(opts.url), null, 2));
11030
- return;
11031
- }
11032
- if (!tool) {
11033
- process.stderr.write(`error: tool name is required (or use --url)
10711
+ process.exit(1);
10712
+ }
10713
+ const { runLogout: runLogout3 } = await Promise.resolve().then(() => (init_auth2(), exports_auth2));
10714
+ await runLogout3(tool);
10715
+ });
10716
+ authCmd.command("status").description("Show auth status for a tool").argument("[tool]", "Tool name").option("--url <url>", "HTTP MCP server URL").action(async (tool, opts) => {
10717
+ if (opts.url) {
10718
+ const { mcpAuthStatus: mcpAuthStatus3 } = await Promise.resolve().then(() => (init_mcp_oauth(), exports_mcp_oauth));
10719
+ console.log(JSON.stringify(mcpAuthStatus3(opts.url), null, 2));
10720
+ return;
10721
+ }
10722
+ if (!tool) {
10723
+ process.stderr.write(`error: tool name is required (or use --url)
11034
10724
  `);
11035
- process.exit(1);
11036
- }
11037
- const { runStatus: runStatus3 } = await Promise.resolve().then(() => (init_auth2(), exports_auth2));
11038
- await runStatus3(tool);
11039
- });
11040
- authCmd.command("token").description("Print the access token for a tool").argument("[tool]", "Tool name").option("--url <url>", "HTTP MCP server URL").action(async (tool, opts) => {
11041
- if (opts.url) {
11042
- const { mcpAuthToken: mcpAuthToken3 } = await Promise.resolve().then(() => (init_mcp_oauth(), exports_mcp_oauth));
11043
- const t = await mcpAuthToken3(opts.url);
11044
- if (!t) {
11045
- throw new Error(`no valid token for '${opts.url}'. Run: mtpcli auth login --url ${opts.url}`);
11046
- }
11047
- console.log(t);
11048
- return;
11049
- }
11050
- if (!tool) {
11051
- process.stderr.write(`error: tool name is required (or use --url)
10725
+ process.exit(1);
10726
+ }
10727
+ const { runStatus: runStatus3 } = await Promise.resolve().then(() => (init_auth2(), exports_auth2));
10728
+ await runStatus3(tool);
10729
+ });
10730
+ authCmd.command("token").description("Print the access token for a tool").argument("[tool]", "Tool name").option("--url <url>", "HTTP MCP server URL").action(async (tool, opts) => {
10731
+ if (opts.url) {
10732
+ const { mcpAuthToken: mcpAuthToken3 } = await Promise.resolve().then(() => (init_mcp_oauth(), exports_mcp_oauth));
10733
+ const t = await mcpAuthToken3(opts.url);
10734
+ if (!t) {
10735
+ throw new Error(`no valid token for '${opts.url}'. Run: mtpcli auth login --url ${opts.url}`);
10736
+ }
10737
+ console.log(t);
10738
+ return;
10739
+ }
10740
+ if (!tool) {
10741
+ process.stderr.write(`error: tool name is required (or use --url)
11052
10742
  `);
11053
- process.exit(1);
11054
- }
11055
- const { runToken: runToken3 } = await Promise.resolve().then(() => (init_auth2(), exports_auth2));
11056
- await runToken3(tool);
11057
- });
11058
- authCmd.command("env").description("Print shell export statement for eval").argument("<tool>", "Tool name").action(async (tool) => {
11059
- const { runEnv: runEnv3 } = await Promise.resolve().then(() => (init_auth2(), exports_auth2));
11060
- await runEnv3(tool);
11061
- });
11062
- authCmd.command("refresh").description("Force-refresh the stored OAuth token for a tool").argument("[tool]", "Tool name").option("--url <url>", "HTTP MCP server URL").action(async (tool, opts) => {
11063
- if (opts.url) {
11064
- const { mcpAuthRefresh: mcpAuthRefresh3 } = await Promise.resolve().then(() => (init_mcp_oauth(), exports_mcp_oauth));
11065
- await mcpAuthRefresh3(opts.url);
11066
- return;
11067
- }
11068
- if (!tool) {
11069
- process.stderr.write(`error: tool name is required (or use --url)
10743
+ process.exit(1);
10744
+ }
10745
+ const { runToken: runToken3 } = await Promise.resolve().then(() => (init_auth2(), exports_auth2));
10746
+ await runToken3(tool);
10747
+ });
10748
+ authCmd.command("env").description("Print shell export statement for eval").argument("<tool>", "Tool name").action(async (tool) => {
10749
+ const { runEnv: runEnv3 } = await Promise.resolve().then(() => (init_auth2(), exports_auth2));
10750
+ await runEnv3(tool);
10751
+ });
10752
+ authCmd.command("refresh").description("Force-refresh the stored OAuth token for a tool").argument("[tool]", "Tool name").option("--url <url>", "HTTP MCP server URL").action(async (tool, opts) => {
10753
+ if (opts.url) {
10754
+ const { mcpAuthRefresh: mcpAuthRefresh3 } = await Promise.resolve().then(() => (init_mcp_oauth(), exports_mcp_oauth));
10755
+ await mcpAuthRefresh3(opts.url);
10756
+ return;
10757
+ }
10758
+ if (!tool) {
10759
+ process.stderr.write(`error: tool name is required (or use --url)
11070
10760
  `);
11071
- process.exit(1);
11072
- }
11073
- const { runRefresh: runRefresh3 } = await Promise.resolve().then(() => (init_auth2(), exports_auth2));
11074
- await runRefresh3(tool);
11075
- });
11076
- program2.command("serve").description("Serve CLI tools as an MCP server (cli2mcp bridge)").requiredOption("--tool <names...>", "Tool(s) to serve").addHelpText("after", `
10761
+ process.exit(1);
10762
+ }
10763
+ const { runRefresh: runRefresh3 } = await Promise.resolve().then(() => (init_auth2(), exports_auth2));
10764
+ await runRefresh3(tool);
10765
+ });
10766
+ program2.command("serve").description("Serve CLI tools as an MCP server (cli2mcp bridge)").requiredOption("--tool <names...>", "Tool(s) to serve").addHelpText("after", `
11077
10767
  This command is meant to be used as an MCP server, not run directly.
11078
10768
  Add it to your MCP client config (e.g. ~/.claude.json):
11079
10769
 
@@ -11087,12 +10777,12 @@ Add it to your MCP client config (e.g. ~/.claude.json):
11087
10777
  }
11088
10778
  }
11089
10779
 
11090
- Any CLI tool on your PATH that supports --describe can be served.
10780
+ Any CLI tool on your PATH that supports --mtp-describe can be served.
11091
10781
  Multiple tools can be combined into a single MCP server:
11092
10782
 
11093
10783
  mtpcli serve --tool tool1 --tool tool2`).action(async (opts) => {
11094
- if (process.stdin.isTTY) {
11095
- process.stderr.write(`Error: 'mtpcli serve' is an MCP server and should not be run directly.
10784
+ if (process.stdin.isTTY) {
10785
+ process.stderr.write(`Error: 'mtpcli serve' is an MCP server and should not be run directly.
11096
10786
  ` + `Add it to your MCP client config instead. For example, in ~/.claude.json:
11097
10787
 
11098
10788
  ` + ` {
@@ -11107,57 +10797,128 @@ Multiple tools can be combined into a single MCP server:
11107
10797
 
11108
10798
  ` + `Run 'mtpcli serve --help' for more details.
11109
10799
  `);
11110
- process.exit(1);
11111
- }
11112
- const { run: run5 } = await init_serve().then(() => exports_serve);
11113
- await run5(opts.tool);
11114
- });
11115
- 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("--describe", "Output --describe JSON instead of invoking", false).argument("[tool_name]", "Tool name to invoke").argument("[args...]", "Arguments for the tool (after --)").action(async (toolName, args, opts) => {
11116
- if (opts.server && opts.url) {
11117
- process.stderr.write(`error: --server and --url are mutually exclusive
11118
- `);
11119
- process.exit(1);
11120
- }
11121
- if (!opts.server && !opts.url) {
11122
- process.stderr.write(`error: one of --server or --url is required
10800
+ process.exit(1);
10801
+ }
10802
+ const { run: run5 } = await Promise.resolve().then(() => (init_serve(), exports_serve));
10803
+ await run5(opts.tool);
10804
+ });
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)").option("--mtp-describe", "Output --mtp-describe JSON instead of invoking", false).argument("[tool_name]", "Tool name to invoke").argument("[args...]", "Arguments for the tool (after --)").action(async (toolName, args, opts) => {
10806
+ if (opts.server && opts.url) {
10807
+ process.stderr.write(`error: --server and --url are mutually exclusive
11123
10808
  `);
11124
- process.exit(1);
11125
- }
11126
- if (opts.header && !opts.url) {
11127
- process.stderr.write(`error: --header requires --url
10809
+ process.exit(1);
10810
+ }
10811
+ if (!opts.server && !opts.url) {
10812
+ process.stderr.write(`error: one of --server or --url is required
11128
10813
  `);
11129
- process.exit(1);
11130
- }
11131
- if (opts.clientId && !opts.url) {
11132
- process.stderr.write(`error: --client-id requires --url
10814
+ process.exit(1);
10815
+ }
10816
+ if (opts.header && !opts.url) {
10817
+ process.stderr.write(`error: --header requires --url
11133
10818
  `);
11134
- process.exit(1);
11135
- }
11136
- const { run: run5 } = await init_wrap().then(() => exports_wrap);
11137
- await run5(opts.server, opts.url, opts.describe, toolName, args, opts.header ?? [], opts.clientId);
11138
- });
11139
- program2.command("validate").description("Validate a tool's --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) => {
11140
- const { run: run5 } = await Promise.resolve().then(() => (init_validate(), exports_validate));
11141
- await run5(tool, {
11142
- json: opts.json,
11143
- stdin: opts.stdin,
11144
- skipHelp: opts.skipHelp
11145
- });
11146
- });
11147
- program2.command("completions").description("Generate shell completions from --describe output").argument("<shell>", "Shell type (bash, zsh, fish)").argument("<tool>", "Tool name").action(async (shell, tool) => {
11148
- const { run: run5 } = await Promise.resolve().then(() => (init_completions(), exports_completions));
11149
- await run5(shell, tool);
11150
- });
11151
- try {
11152
- await program2.parseAsync(process.argv);
11153
- } catch (e) {
11154
- process.stderr.write(`error: ${e instanceof Error ? e.message : e}
10819
+ process.exit(1);
10820
+ }
10821
+ if (opts.clientId && !opts.url) {
10822
+ process.stderr.write(`error: --client-id requires --url
11155
10823
  `);
11156
10824
  process.exit(1);
11157
10825
  }
10826
+ const { run: run5 } = await Promise.resolve().then(() => (init_wrap(), exports_wrap));
10827
+ await run5(opts.server, opts.url, opts.mtpDescribe, toolName, args, opts.header ?? [], opts.clientId);
11158
10828
  });
11159
- await init_src();
11160
-
11161
- export {
11162
- VERSION
10829
+ 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
+ const { run: run5 } = await Promise.resolve().then(() => (init_validate(), exports_validate));
10831
+ await run5(tool, {
10832
+ json: opts.json,
10833
+ stdin: opts.stdin,
10834
+ skipHelp: opts.skipHelp
10835
+ });
10836
+ });
10837
+ program2.command("completions").description("Generate shell completions from --mtp-describe output").argument("<shell>", "Shell type (bash, zsh, fish)").argument("<tool>", "Tool name").action(async (shell, tool) => {
10838
+ const { run: run5 } = await Promise.resolve().then(() => (init_completions(), exports_completions));
10839
+ await run5(shell, tool);
10840
+ });
10841
+ var describeOptions = {
10842
+ commands: {
10843
+ search: {
10844
+ examples: [
10845
+ { description: "Search specific tools", command: 'mtpcli search "convert files" -- filetool mytool' },
10846
+ { description: "Search cached tools", command: 'mtpcli search "deploy"' },
10847
+ { description: "Scan PATH and search", command: 'mtpcli search --scan-path "git commit"' }
10848
+ ],
10849
+ argTypes: { jobs: "integer" }
10850
+ },
10851
+ "auth login": {
10852
+ examples: [
10853
+ { description: "OAuth2 login", command: "mtpcli auth login gh-tool" },
10854
+ { description: "API key login", command: "mtpcli auth login my-tool --token sk-xxx" },
10855
+ { description: "Login to HTTP MCP server", command: "mtpcli auth login --url https://mcp.example.com/v1/mcp" }
10856
+ ]
10857
+ },
10858
+ "auth logout": {
10859
+ examples: [
10860
+ { command: "mtpcli auth logout gh-tool" },
10861
+ { description: "Logout from HTTP MCP server", command: "mtpcli auth logout --url https://mcp.example.com/v1/mcp" }
10862
+ ]
10863
+ },
10864
+ "auth status": {
10865
+ examples: [
10866
+ { command: "mtpcli auth status gh-tool" },
10867
+ { description: "Status for HTTP MCP server", command: "mtpcli auth status --url https://mcp.example.com/v1/mcp" }
10868
+ ]
10869
+ },
10870
+ "auth token": {
10871
+ examples: [
10872
+ { command: "mtpcli auth token gh-tool" },
10873
+ { description: "Token for HTTP MCP server", command: "mtpcli auth token --url https://mcp.example.com/v1/mcp" }
10874
+ ]
10875
+ },
10876
+ "auth env": {
10877
+ examples: [
10878
+ { command: "eval $(mtpcli auth env gh-tool)" }
10879
+ ]
10880
+ },
10881
+ "auth refresh": {
10882
+ examples: [
10883
+ { command: "mtpcli auth refresh gh-tool" },
10884
+ { description: "Refresh token for HTTP MCP server", command: "mtpcli auth refresh --url https://mcp.example.com/v1/mcp" }
10885
+ ]
10886
+ },
10887
+ serve: {
10888
+ examples: [
10889
+ { description: "Add to ~/.claude.json as an MCP server", command: '{ "mcpServers": { "my-tools": { "type": "stdio", "command": "mtpcli", "args": ["serve", "--tool", "my-cli-tool"] } } }' },
10890
+ { description: "Serve multiple tools in one MCP server", command: '{ "mcpServers": { "my-tools": { "type": "stdio", "command": "mtpcli", "args": ["serve", "--tool", "tool1", "--tool", "tool2"] } } }' }
10891
+ ]
10892
+ },
10893
+ wrap: {
10894
+ examples: [
10895
+ { description: "Describe a stdio MCP server", command: 'mtpcli wrap --server "npx @mcp/server-github" --mtp-describe' },
10896
+ { 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 --mtp-describe" },
10898
+ { description: "Call a tool on an HTTP server", command: "mtpcli wrap --url http://localhost:3000/mcp search_repos -- --query mtpcli" }
10899
+ ]
10900
+ },
10901
+ validate: {
10902
+ examples: [
10903
+ { description: "Validate a tool", command: "mtpcli validate mytool" },
10904
+ { description: "Validate from stdin", command: "cat describe.json | mtpcli validate --stdin" },
10905
+ { description: "JSON output for CI", command: "mtpcli validate mytool --json" }
10906
+ ]
10907
+ },
10908
+ completions: {
10909
+ examples: [
10910
+ { description: "Install bash completions", command: "eval $(mtpcli completions bash mytool)" },
10911
+ { description: "Install zsh completions", command: "eval $(mtpcli completions zsh mytool)" },
10912
+ { description: "Install fish completions", command: "mtpcli completions fish mytool | source" }
10913
+ ]
10914
+ }
10915
+ }
11163
10916
  };
10917
+ withDescribe(program2, describeOptions);
10918
+ try {
10919
+ await program2.parseAsync(process.argv);
10920
+ } catch (e) {
10921
+ process.stderr.write(`error: ${e instanceof Error ? e.message : e}
10922
+ `);
10923
+ process.exit(1);
10924
+ }