@modeltoolsprotocol/mtpcli 1.2.0 → 1.3.1
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/index.js +315 -547
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -6088,6 +6088,200 @@ var init_zod = __esm(() => {
|
|
|
6088
6088
|
init_external();
|
|
6089
6089
|
});
|
|
6090
6090
|
|
|
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(() => {
|
|
6094
|
+
init_zod();
|
|
6095
|
+
ExampleSchema = exports_external.object({
|
|
6096
|
+
description: exports_external.string().optional(),
|
|
6097
|
+
command: exports_external.string(),
|
|
6098
|
+
output: exports_external.string().optional()
|
|
6099
|
+
});
|
|
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({
|
|
6106
|
+
name: exports_external.string(),
|
|
6107
|
+
type: exports_external.string(),
|
|
6108
|
+
description: exports_external.string().optional(),
|
|
6109
|
+
required: exports_external.boolean().default(false),
|
|
6110
|
+
default: exports_external.any().optional(),
|
|
6111
|
+
values: exports_external.array(exports_external.string()).optional()
|
|
6112
|
+
});
|
|
6113
|
+
CommandAuthSchema = exports_external.object({
|
|
6114
|
+
required: exports_external.boolean().default(false),
|
|
6115
|
+
scopes: exports_external.array(exports_external.string()).optional()
|
|
6116
|
+
});
|
|
6117
|
+
CommandDescriptorSchema = exports_external.object({
|
|
6118
|
+
name: exports_external.string(),
|
|
6119
|
+
description: exports_external.string(),
|
|
6120
|
+
args: exports_external.array(ArgDescriptorSchema).default([]),
|
|
6121
|
+
stdin: IODescriptorSchema.optional(),
|
|
6122
|
+
stdout: IODescriptorSchema.optional(),
|
|
6123
|
+
examples: exports_external.array(ExampleSchema).default([]),
|
|
6124
|
+
auth: CommandAuthSchema.optional()
|
|
6125
|
+
});
|
|
6126
|
+
AuthProviderSchema = exports_external.object({
|
|
6127
|
+
id: exports_external.string(),
|
|
6128
|
+
type: exports_external.string(),
|
|
6129
|
+
displayName: exports_external.string().optional(),
|
|
6130
|
+
authorizationUrl: exports_external.string().optional(),
|
|
6131
|
+
tokenUrl: exports_external.string().optional(),
|
|
6132
|
+
scopes: exports_external.array(exports_external.string()).optional(),
|
|
6133
|
+
clientId: exports_external.string().optional(),
|
|
6134
|
+
registrationUrl: exports_external.string().optional(),
|
|
6135
|
+
instructions: exports_external.string().optional()
|
|
6136
|
+
});
|
|
6137
|
+
AuthConfigSchema = exports_external.object({
|
|
6138
|
+
required: exports_external.boolean().default(false),
|
|
6139
|
+
envVar: exports_external.string(),
|
|
6140
|
+
providers: exports_external.array(AuthProviderSchema)
|
|
6141
|
+
});
|
|
6142
|
+
ToolSchemaSchema = exports_external.object({
|
|
6143
|
+
specVersion: exports_external.string(),
|
|
6144
|
+
name: exports_external.string(),
|
|
6145
|
+
version: exports_external.string(),
|
|
6146
|
+
description: exports_external.string(),
|
|
6147
|
+
auth: AuthConfigSchema.optional(),
|
|
6148
|
+
commands: exports_external.array(CommandDescriptorSchema)
|
|
6149
|
+
});
|
|
6150
|
+
});
|
|
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
|
+
|
|
6091
6285
|
// node_modules/jaro-winkler/index.js
|
|
6092
6286
|
var require_jaro_winkler = __commonJS((exports, module) => {
|
|
6093
6287
|
(function(root) {
|
|
@@ -6421,6 +6615,12 @@ var require_lib = __commonJS((exports, module) => {
|
|
|
6421
6615
|
which.sync = whichSync;
|
|
6422
6616
|
});
|
|
6423
6617
|
|
|
6618
|
+
// node_modules/@modeltoolsprotocol/sdk/src/index.ts
|
|
6619
|
+
var init_src = __esm(() => {
|
|
6620
|
+
init_introspect();
|
|
6621
|
+
init_schemas();
|
|
6622
|
+
});
|
|
6623
|
+
|
|
6424
6624
|
// src/models.ts
|
|
6425
6625
|
function jsonRpcSuccess(id, result) {
|
|
6426
6626
|
return { jsonrpc: "2.0", id, result };
|
|
@@ -6428,65 +6628,11 @@ function jsonRpcSuccess(id, result) {
|
|
|
6428
6628
|
function jsonRpcError(id, code, message) {
|
|
6429
6629
|
return { jsonrpc: "2.0", id, error: { code, message } };
|
|
6430
6630
|
}
|
|
6431
|
-
var
|
|
6631
|
+
var StoredTokenSchema, JsonRpcErrorSchema, JsonRpcRequestSchema, JsonRpcResponseSchema, McpToolDefSchema;
|
|
6432
6632
|
var init_models = __esm(() => {
|
|
6433
6633
|
init_zod();
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
command: exports_external.string(),
|
|
6437
|
-
output: exports_external.string().optional()
|
|
6438
|
-
});
|
|
6439
|
-
ArgSchema2 = exports_external.object({
|
|
6440
|
-
name: exports_external.string(),
|
|
6441
|
-
type: exports_external.string(),
|
|
6442
|
-
description: exports_external.string().optional(),
|
|
6443
|
-
required: exports_external.boolean().default(false),
|
|
6444
|
-
default: exports_external.any().optional(),
|
|
6445
|
-
values: exports_external.array(exports_external.string()).optional()
|
|
6446
|
-
});
|
|
6447
|
-
IoDescriptorSchema2 = exports_external.object({
|
|
6448
|
-
contentType: exports_external.string().optional(),
|
|
6449
|
-
description: exports_external.string().optional(),
|
|
6450
|
-
schema: exports_external.any().optional()
|
|
6451
|
-
});
|
|
6452
|
-
CommandAuthSchema2 = exports_external.object({
|
|
6453
|
-
required: exports_external.boolean().default(false),
|
|
6454
|
-
scopes: exports_external.array(exports_external.string()).optional()
|
|
6455
|
-
});
|
|
6456
|
-
CommandSchema2 = exports_external.object({
|
|
6457
|
-
name: exports_external.string(),
|
|
6458
|
-
description: exports_external.string(),
|
|
6459
|
-
args: exports_external.array(ArgSchema2).default([]),
|
|
6460
|
-
stdin: IoDescriptorSchema2.optional(),
|
|
6461
|
-
stdout: IoDescriptorSchema2.optional(),
|
|
6462
|
-
examples: exports_external.array(ExampleSchema2).default([]),
|
|
6463
|
-
auth: CommandAuthSchema2.optional()
|
|
6464
|
-
});
|
|
6465
|
-
AuthProviderSchema2 = exports_external.object({
|
|
6466
|
-
id: exports_external.string(),
|
|
6467
|
-
type: exports_external.string(),
|
|
6468
|
-
displayName: exports_external.string().optional(),
|
|
6469
|
-
authorizationUrl: exports_external.string().optional(),
|
|
6470
|
-
tokenUrl: exports_external.string().optional(),
|
|
6471
|
-
scopes: exports_external.array(exports_external.string()).optional(),
|
|
6472
|
-
clientId: exports_external.string().optional(),
|
|
6473
|
-
registrationUrl: exports_external.string().optional(),
|
|
6474
|
-
instructions: exports_external.string().optional()
|
|
6475
|
-
});
|
|
6476
|
-
AuthConfigSchema2 = exports_external.object({
|
|
6477
|
-
required: exports_external.boolean().default(false),
|
|
6478
|
-
envVar: exports_external.string(),
|
|
6479
|
-
providers: exports_external.array(AuthProviderSchema2)
|
|
6480
|
-
});
|
|
6481
|
-
ToolSchemaSchema2 = exports_external.object({
|
|
6482
|
-
specVersion: exports_external.string(),
|
|
6483
|
-
name: exports_external.string(),
|
|
6484
|
-
version: exports_external.string(),
|
|
6485
|
-
description: exports_external.string(),
|
|
6486
|
-
auth: AuthConfigSchema2.optional(),
|
|
6487
|
-
commands: exports_external.array(CommandSchema2)
|
|
6488
|
-
});
|
|
6489
|
-
StoredTokenSchema2 = exports_external.object({
|
|
6634
|
+
init_src();
|
|
6635
|
+
StoredTokenSchema = exports_external.object({
|
|
6490
6636
|
access_token: exports_external.string(),
|
|
6491
6637
|
token_type: exports_external.string().optional(),
|
|
6492
6638
|
refresh_token: exports_external.string().optional(),
|
|
@@ -6495,24 +6641,24 @@ var init_models = __esm(() => {
|
|
|
6495
6641
|
provider_id: exports_external.string(),
|
|
6496
6642
|
created_at: exports_external.string()
|
|
6497
6643
|
});
|
|
6498
|
-
|
|
6644
|
+
JsonRpcErrorSchema = exports_external.object({
|
|
6499
6645
|
code: exports_external.number(),
|
|
6500
6646
|
message: exports_external.string(),
|
|
6501
6647
|
data: exports_external.any().optional()
|
|
6502
6648
|
});
|
|
6503
|
-
|
|
6649
|
+
JsonRpcRequestSchema = exports_external.object({
|
|
6504
6650
|
jsonrpc: exports_external.string(),
|
|
6505
6651
|
id: exports_external.any().optional(),
|
|
6506
6652
|
method: exports_external.string(),
|
|
6507
6653
|
params: exports_external.any().default({})
|
|
6508
6654
|
});
|
|
6509
|
-
|
|
6655
|
+
JsonRpcResponseSchema = exports_external.object({
|
|
6510
6656
|
jsonrpc: exports_external.string(),
|
|
6511
6657
|
id: exports_external.any().optional(),
|
|
6512
6658
|
result: exports_external.any().optional(),
|
|
6513
|
-
error:
|
|
6659
|
+
error: JsonRpcErrorSchema.optional()
|
|
6514
6660
|
});
|
|
6515
|
-
|
|
6661
|
+
McpToolDefSchema = exports_external.object({
|
|
6516
6662
|
name: exports_external.string(),
|
|
6517
6663
|
description: exports_external.string(),
|
|
6518
6664
|
inputSchema: exports_external.any()
|
|
@@ -6576,7 +6722,7 @@ async function getToolSchema(toolName) {
|
|
|
6576
6722
|
const { stdout } = await execFileAsync(toolPath, ["--mtp-describe"], {
|
|
6577
6723
|
timeout: 5000
|
|
6578
6724
|
});
|
|
6579
|
-
return
|
|
6725
|
+
return ToolSchemaSchema.parse(JSON.parse(stdout.trim()));
|
|
6580
6726
|
} catch {
|
|
6581
6727
|
return null;
|
|
6582
6728
|
}
|
|
@@ -6599,7 +6745,7 @@ function readAllCached() {
|
|
|
6599
6745
|
continue;
|
|
6600
6746
|
try {
|
|
6601
6747
|
const data = readFileSync(join(dir, entry), "utf-8");
|
|
6602
|
-
schemas.push(
|
|
6748
|
+
schemas.push(ToolSchemaSchema.parse(JSON.parse(data)));
|
|
6603
6749
|
} catch {}
|
|
6604
6750
|
}
|
|
6605
6751
|
return schemas;
|
|
@@ -7328,7 +7474,7 @@ async function getToolSchema2(toolName) {
|
|
|
7328
7474
|
const { stdout } = await execFileAsync6(toolPath, ["--mtp-describe"], {
|
|
7329
7475
|
timeout: 5000
|
|
7330
7476
|
});
|
|
7331
|
-
return
|
|
7477
|
+
return ToolSchemaSchema.parse(JSON.parse(stdout.trim()));
|
|
7332
7478
|
} catch {
|
|
7333
7479
|
return null;
|
|
7334
7480
|
}
|
|
@@ -8678,7 +8824,7 @@ function readResponse(rl) {
|
|
|
8678
8824
|
rl.off("line", onLine);
|
|
8679
8825
|
rl.off("close", onClose);
|
|
8680
8826
|
try {
|
|
8681
|
-
resolve(
|
|
8827
|
+
resolve(JsonRpcResponseSchema.parse(msg));
|
|
8682
8828
|
} catch (e) {
|
|
8683
8829
|
reject(e);
|
|
8684
8830
|
}
|
|
@@ -8697,7 +8843,7 @@ var init_mcp = __esm(() => {
|
|
|
8697
8843
|
});
|
|
8698
8844
|
|
|
8699
8845
|
// src/version.ts
|
|
8700
|
-
var VERSION2 = "1.
|
|
8846
|
+
var VERSION2 = "1.3.1";
|
|
8701
8847
|
|
|
8702
8848
|
// src/serve.ts
|
|
8703
8849
|
var exports_serve = {};
|
|
@@ -8966,7 +9112,7 @@ async function run(toolNames) {
|
|
|
8966
9112
|
continue;
|
|
8967
9113
|
let req;
|
|
8968
9114
|
try {
|
|
8969
|
-
req =
|
|
9115
|
+
req = JsonRpcRequestSchema.parse(JSON.parse(trimmed));
|
|
8970
9116
|
} catch (e) {
|
|
8971
9117
|
const msg = e instanceof Error ? e.message : String(e);
|
|
8972
9118
|
process.stderr.write(`error reading request: ${msg}
|
|
@@ -9794,7 +9940,7 @@ function parseHeaders(raw) {
|
|
|
9794
9940
|
}
|
|
9795
9941
|
return headers;
|
|
9796
9942
|
}
|
|
9797
|
-
async function run2(serverCmd, serverUrl,
|
|
9943
|
+
async function run2(serverCmd, serverUrl, toolName, toolArgs = [], rawHeaders = [], clientId) {
|
|
9798
9944
|
let client;
|
|
9799
9945
|
let serverName;
|
|
9800
9946
|
if (serverUrl) {
|
|
@@ -9813,13 +9959,13 @@ async function run2(serverCmd, serverUrl, describeMode, toolName, toolArgs = [],
|
|
|
9813
9959
|
const mcpTools = await client.listTools();
|
|
9814
9960
|
const commands = mcpTools.map(mcpToolToCommand);
|
|
9815
9961
|
const schema = {
|
|
9816
|
-
specVersion:
|
|
9962
|
+
specVersion: MTP_SPEC_VERSION,
|
|
9817
9963
|
name: serverName,
|
|
9818
9964
|
version: "0.1.0",
|
|
9819
9965
|
description: `CLI wrapper for MCP server: ${serverName}`,
|
|
9820
9966
|
commands
|
|
9821
9967
|
};
|
|
9822
|
-
if (
|
|
9968
|
+
if (!toolName) {
|
|
9823
9969
|
console.log(JSON.stringify(schema, null, 2));
|
|
9824
9970
|
return;
|
|
9825
9971
|
}
|
|
@@ -9886,7 +10032,7 @@ function validateJson(raw) {
|
|
|
9886
10032
|
});
|
|
9887
10033
|
return diags;
|
|
9888
10034
|
}
|
|
9889
|
-
const result =
|
|
10035
|
+
const result = ToolSchemaSchema.safeParse(parsed);
|
|
9890
10036
|
if (!result.success) {
|
|
9891
10037
|
for (const issue of result.error.issues) {
|
|
9892
10038
|
diags.push({
|
|
@@ -10022,7 +10168,7 @@ async function validateTool(toolName, opts) {
|
|
|
10022
10168
|
const { stdout: helpText } = await execFileAsync8(toolPath, ["--help"], {
|
|
10023
10169
|
timeout: 5000
|
|
10024
10170
|
});
|
|
10025
|
-
const schema =
|
|
10171
|
+
const schema = ToolSchemaSchema.parse(JSON.parse(describeOutput));
|
|
10026
10172
|
diags.push(...crossReferenceHelp(schema, helpText));
|
|
10027
10173
|
} catch {}
|
|
10028
10174
|
}
|
|
@@ -10487,483 +10633,28 @@ var {
|
|
|
10487
10633
|
Help
|
|
10488
10634
|
} = import__.default;
|
|
10489
10635
|
|
|
10490
|
-
// src/
|
|
10491
|
-
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
|
|
10495
|
-
|
|
10496
|
-
|
|
10497
|
-
|
|
10498
|
-
|
|
10499
|
-
|
|
10500
|
-
|
|
10501
|
-
|
|
10502
|
-
|
|
10503
|
-
|
|
10504
|
-
|
|
10505
|
-
var IoDescriptorSchema = exports_external.object({
|
|
10506
|
-
contentType: exports_external.string().optional(),
|
|
10507
|
-
description: exports_external.string().optional(),
|
|
10508
|
-
schema: exports_external.any().optional()
|
|
10509
|
-
});
|
|
10510
|
-
var CommandAuthSchema = exports_external.object({
|
|
10511
|
-
required: exports_external.boolean().default(false),
|
|
10512
|
-
scopes: exports_external.array(exports_external.string()).optional()
|
|
10513
|
-
});
|
|
10514
|
-
var CommandSchema = exports_external.object({
|
|
10515
|
-
name: exports_external.string(),
|
|
10516
|
-
description: exports_external.string(),
|
|
10517
|
-
args: exports_external.array(ArgSchema).default([]),
|
|
10518
|
-
stdin: IoDescriptorSchema.optional(),
|
|
10519
|
-
stdout: IoDescriptorSchema.optional(),
|
|
10520
|
-
examples: exports_external.array(ExampleSchema).default([]),
|
|
10521
|
-
auth: CommandAuthSchema.optional()
|
|
10522
|
-
});
|
|
10523
|
-
var AuthProviderSchema = exports_external.object({
|
|
10524
|
-
id: exports_external.string(),
|
|
10525
|
-
type: exports_external.string(),
|
|
10526
|
-
displayName: exports_external.string().optional(),
|
|
10527
|
-
authorizationUrl: exports_external.string().optional(),
|
|
10528
|
-
tokenUrl: exports_external.string().optional(),
|
|
10529
|
-
scopes: exports_external.array(exports_external.string()).optional(),
|
|
10530
|
-
clientId: exports_external.string().optional(),
|
|
10531
|
-
registrationUrl: exports_external.string().optional(),
|
|
10532
|
-
instructions: exports_external.string().optional()
|
|
10533
|
-
});
|
|
10534
|
-
var AuthConfigSchema = exports_external.object({
|
|
10535
|
-
required: exports_external.boolean().default(false),
|
|
10536
|
-
envVar: exports_external.string(),
|
|
10537
|
-
providers: exports_external.array(AuthProviderSchema)
|
|
10538
|
-
});
|
|
10539
|
-
var MTP_SPEC_VERSION = "2026-02-07";
|
|
10540
|
-
var ToolSchemaSchema = exports_external.object({
|
|
10541
|
-
specVersion: exports_external.string(),
|
|
10542
|
-
name: exports_external.string(),
|
|
10543
|
-
version: exports_external.string(),
|
|
10544
|
-
description: exports_external.string(),
|
|
10545
|
-
auth: AuthConfigSchema.optional(),
|
|
10546
|
-
commands: exports_external.array(CommandSchema)
|
|
10547
|
-
});
|
|
10548
|
-
var StoredTokenSchema = exports_external.object({
|
|
10549
|
-
access_token: exports_external.string(),
|
|
10550
|
-
token_type: exports_external.string().optional(),
|
|
10551
|
-
refresh_token: exports_external.string().optional(),
|
|
10552
|
-
expires_at: exports_external.string().optional(),
|
|
10553
|
-
scopes: exports_external.array(exports_external.string()).optional(),
|
|
10554
|
-
provider_id: exports_external.string(),
|
|
10555
|
-
created_at: exports_external.string()
|
|
10556
|
-
});
|
|
10557
|
-
var JsonRpcErrorSchema = exports_external.object({
|
|
10558
|
-
code: exports_external.number(),
|
|
10559
|
-
message: exports_external.string(),
|
|
10560
|
-
data: exports_external.any().optional()
|
|
10561
|
-
});
|
|
10562
|
-
var JsonRpcRequestSchema = exports_external.object({
|
|
10563
|
-
jsonrpc: exports_external.string(),
|
|
10564
|
-
id: exports_external.any().optional(),
|
|
10565
|
-
method: exports_external.string(),
|
|
10566
|
-
params: exports_external.any().default({})
|
|
10567
|
-
});
|
|
10568
|
-
var JsonRpcResponseSchema = exports_external.object({
|
|
10569
|
-
jsonrpc: exports_external.string(),
|
|
10570
|
-
id: exports_external.any().optional(),
|
|
10571
|
-
result: exports_external.any().optional(),
|
|
10572
|
-
error: JsonRpcErrorSchema.optional()
|
|
10573
|
-
});
|
|
10574
|
-
var McpToolDefSchema = exports_external.object({
|
|
10575
|
-
name: exports_external.string(),
|
|
10576
|
-
description: exports_external.string(),
|
|
10577
|
-
inputSchema: exports_external.any()
|
|
10578
|
-
});
|
|
10579
|
-
function cleanJson(obj) {
|
|
10580
|
-
if (obj === null || obj === undefined)
|
|
10581
|
-
return;
|
|
10582
|
-
if (Array.isArray(obj)) {
|
|
10583
|
-
return obj.map(cleanJson);
|
|
10584
|
-
}
|
|
10585
|
-
if (typeof obj === "object") {
|
|
10586
|
-
const out = {};
|
|
10587
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
10588
|
-
if (v === undefined)
|
|
10589
|
-
continue;
|
|
10590
|
-
if (Array.isArray(v) && v.length === 0)
|
|
10591
|
-
continue;
|
|
10592
|
-
const cleaned = cleanJson(v);
|
|
10593
|
-
if (cleaned !== undefined) {
|
|
10594
|
-
out[k] = cleaned;
|
|
10595
|
-
}
|
|
10596
|
-
}
|
|
10597
|
-
return out;
|
|
10598
|
-
}
|
|
10599
|
-
return obj;
|
|
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);
|
|
10649
|
+
});
|
|
10650
|
+
return program2;
|
|
10600
10651
|
}
|
|
10601
10652
|
|
|
10602
10653
|
// src/version.ts
|
|
10603
|
-
var VERSION = "1.
|
|
10654
|
+
var VERSION = "1.3.1";
|
|
10604
10655
|
|
|
10605
10656
|
// src/index.ts
|
|
10606
|
-
|
|
10607
|
-
const schema = {
|
|
10608
|
-
specVersion: MTP_SPEC_VERSION,
|
|
10609
|
-
name: "mtpcli",
|
|
10610
|
-
version: VERSION,
|
|
10611
|
-
description: "Unified CLI for discovering, authenticating, and bridging --mtp-describe-compatible tools",
|
|
10612
|
-
commands: [
|
|
10613
|
-
{
|
|
10614
|
-
name: "search",
|
|
10615
|
-
description: "Search across --mtp-describe-compatible tools for commands matching a query",
|
|
10616
|
-
args: [
|
|
10617
|
-
{
|
|
10618
|
-
name: "query",
|
|
10619
|
-
type: "string",
|
|
10620
|
-
required: true,
|
|
10621
|
-
description: "Search query"
|
|
10622
|
-
},
|
|
10623
|
-
{
|
|
10624
|
-
name: "--json",
|
|
10625
|
-
type: "boolean",
|
|
10626
|
-
default: false,
|
|
10627
|
-
description: "Output as JSON"
|
|
10628
|
-
},
|
|
10629
|
-
{
|
|
10630
|
-
name: "--scan-path",
|
|
10631
|
-
type: "boolean",
|
|
10632
|
-
default: false,
|
|
10633
|
-
description: "Scan PATH for tools"
|
|
10634
|
-
},
|
|
10635
|
-
{
|
|
10636
|
-
name: "--jobs",
|
|
10637
|
-
type: "integer",
|
|
10638
|
-
default: 16,
|
|
10639
|
-
description: "Parallel jobs for scan-path"
|
|
10640
|
-
}
|
|
10641
|
-
],
|
|
10642
|
-
examples: [
|
|
10643
|
-
{
|
|
10644
|
-
description: "Search specific tools",
|
|
10645
|
-
command: 'mtpcli search "convert files" -- filetool mytool'
|
|
10646
|
-
},
|
|
10647
|
-
{
|
|
10648
|
-
description: "Search cached tools",
|
|
10649
|
-
command: 'mtpcli search "deploy"'
|
|
10650
|
-
},
|
|
10651
|
-
{
|
|
10652
|
-
description: "Scan PATH and search",
|
|
10653
|
-
command: 'mtpcli search --scan-path "git commit"'
|
|
10654
|
-
}
|
|
10655
|
-
]
|
|
10656
|
-
},
|
|
10657
|
-
{
|
|
10658
|
-
name: "auth login",
|
|
10659
|
-
description: "Authenticate with a tool (OAuth2, API key, or bearer token)",
|
|
10660
|
-
args: [
|
|
10661
|
-
{
|
|
10662
|
-
name: "tool",
|
|
10663
|
-
type: "string",
|
|
10664
|
-
description: "Tool name (required unless --url is used)"
|
|
10665
|
-
},
|
|
10666
|
-
{
|
|
10667
|
-
name: "--provider",
|
|
10668
|
-
type: "string",
|
|
10669
|
-
description: "Specific auth provider ID"
|
|
10670
|
-
},
|
|
10671
|
-
{
|
|
10672
|
-
name: "--token",
|
|
10673
|
-
type: "string",
|
|
10674
|
-
description: "API key or bearer token"
|
|
10675
|
-
},
|
|
10676
|
-
{
|
|
10677
|
-
name: "--url",
|
|
10678
|
-
type: "string",
|
|
10679
|
-
description: "HTTP MCP server URL (triggers OAuth discovery and login)"
|
|
10680
|
-
},
|
|
10681
|
-
{
|
|
10682
|
-
name: "--client-id",
|
|
10683
|
-
type: "string",
|
|
10684
|
-
description: "Pre-registered OAuth client ID (for --url)"
|
|
10685
|
-
}
|
|
10686
|
-
],
|
|
10687
|
-
examples: [
|
|
10688
|
-
{ description: "OAuth2 login", command: "mtpcli auth login gh-tool" },
|
|
10689
|
-
{
|
|
10690
|
-
description: "API key login",
|
|
10691
|
-
command: "mtpcli auth login my-tool --token sk-xxx"
|
|
10692
|
-
},
|
|
10693
|
-
{
|
|
10694
|
-
description: "Login to HTTP MCP server",
|
|
10695
|
-
command: "mtpcli auth login --url https://mcp.example.com/v1/mcp"
|
|
10696
|
-
}
|
|
10697
|
-
]
|
|
10698
|
-
},
|
|
10699
|
-
{
|
|
10700
|
-
name: "auth logout",
|
|
10701
|
-
description: "Remove stored tokens for a tool",
|
|
10702
|
-
args: [
|
|
10703
|
-
{
|
|
10704
|
-
name: "tool",
|
|
10705
|
-
type: "string",
|
|
10706
|
-
description: "Tool name (required unless --url is used)"
|
|
10707
|
-
},
|
|
10708
|
-
{
|
|
10709
|
-
name: "--url",
|
|
10710
|
-
type: "string",
|
|
10711
|
-
description: "HTTP MCP server URL"
|
|
10712
|
-
}
|
|
10713
|
-
],
|
|
10714
|
-
examples: [
|
|
10715
|
-
{ command: "mtpcli auth logout gh-tool" },
|
|
10716
|
-
{
|
|
10717
|
-
description: "Logout from HTTP MCP server",
|
|
10718
|
-
command: "mtpcli auth logout --url https://mcp.example.com/v1/mcp"
|
|
10719
|
-
}
|
|
10720
|
-
]
|
|
10721
|
-
},
|
|
10722
|
-
{
|
|
10723
|
-
name: "auth status",
|
|
10724
|
-
description: "Show authentication status for a tool",
|
|
10725
|
-
args: [
|
|
10726
|
-
{
|
|
10727
|
-
name: "tool",
|
|
10728
|
-
type: "string",
|
|
10729
|
-
description: "Tool name (required unless --url is used)"
|
|
10730
|
-
},
|
|
10731
|
-
{
|
|
10732
|
-
name: "--url",
|
|
10733
|
-
type: "string",
|
|
10734
|
-
description: "HTTP MCP server URL"
|
|
10735
|
-
}
|
|
10736
|
-
],
|
|
10737
|
-
examples: [
|
|
10738
|
-
{ command: "mtpcli auth status gh-tool" },
|
|
10739
|
-
{
|
|
10740
|
-
description: "Status for HTTP MCP server",
|
|
10741
|
-
command: "mtpcli auth status --url https://mcp.example.com/v1/mcp"
|
|
10742
|
-
}
|
|
10743
|
-
]
|
|
10744
|
-
},
|
|
10745
|
-
{
|
|
10746
|
-
name: "auth token",
|
|
10747
|
-
description: "Print the access token for a tool",
|
|
10748
|
-
args: [
|
|
10749
|
-
{
|
|
10750
|
-
name: "tool",
|
|
10751
|
-
type: "string",
|
|
10752
|
-
description: "Tool name (required unless --url is used)"
|
|
10753
|
-
},
|
|
10754
|
-
{
|
|
10755
|
-
name: "--url",
|
|
10756
|
-
type: "string",
|
|
10757
|
-
description: "HTTP MCP server URL"
|
|
10758
|
-
}
|
|
10759
|
-
],
|
|
10760
|
-
examples: [
|
|
10761
|
-
{ command: "mtpcli auth token gh-tool" },
|
|
10762
|
-
{
|
|
10763
|
-
description: "Token for HTTP MCP server",
|
|
10764
|
-
command: "mtpcli auth token --url https://mcp.example.com/v1/mcp"
|
|
10765
|
-
}
|
|
10766
|
-
]
|
|
10767
|
-
},
|
|
10768
|
-
{
|
|
10769
|
-
name: "auth env",
|
|
10770
|
-
description: "Print shell export statement for eval $(mtpcli auth env <tool>)",
|
|
10771
|
-
args: [
|
|
10772
|
-
{
|
|
10773
|
-
name: "tool",
|
|
10774
|
-
type: "string",
|
|
10775
|
-
required: true,
|
|
10776
|
-
description: "Tool name"
|
|
10777
|
-
}
|
|
10778
|
-
],
|
|
10779
|
-
examples: [{ command: "eval $(mtpcli auth env gh-tool)" }]
|
|
10780
|
-
},
|
|
10781
|
-
{
|
|
10782
|
-
name: "auth refresh",
|
|
10783
|
-
description: "Force-refresh the stored OAuth token for a tool",
|
|
10784
|
-
args: [
|
|
10785
|
-
{
|
|
10786
|
-
name: "tool",
|
|
10787
|
-
type: "string",
|
|
10788
|
-
description: "Tool name (required unless --url is used)"
|
|
10789
|
-
},
|
|
10790
|
-
{
|
|
10791
|
-
name: "--url",
|
|
10792
|
-
type: "string",
|
|
10793
|
-
description: "HTTP MCP server URL"
|
|
10794
|
-
}
|
|
10795
|
-
],
|
|
10796
|
-
examples: [
|
|
10797
|
-
{ command: "mtpcli auth refresh gh-tool" },
|
|
10798
|
-
{
|
|
10799
|
-
description: "Refresh token for HTTP MCP server",
|
|
10800
|
-
command: "mtpcli auth refresh --url https://mcp.example.com/v1/mcp"
|
|
10801
|
-
}
|
|
10802
|
-
]
|
|
10803
|
-
},
|
|
10804
|
-
{
|
|
10805
|
-
name: "serve",
|
|
10806
|
-
description: "Serve CLI tools as an MCP server over stdio. Not meant to be run directly; add to your MCP client config instead.",
|
|
10807
|
-
args: [
|
|
10808
|
-
{
|
|
10809
|
-
name: "--tool",
|
|
10810
|
-
type: "array",
|
|
10811
|
-
required: true,
|
|
10812
|
-
description: "Tool name(s) to serve (must support --mtp-describe)"
|
|
10813
|
-
}
|
|
10814
|
-
],
|
|
10815
|
-
examples: [
|
|
10816
|
-
{
|
|
10817
|
-
description: "Add to ~/.claude.json as an MCP server",
|
|
10818
|
-
command: '{ "mcpServers": { "my-tools": { "type": "stdio", "command": "mtpcli", "args": ["serve", "--tool", "my-cli-tool"] } } }'
|
|
10819
|
-
},
|
|
10820
|
-
{
|
|
10821
|
-
description: "Serve multiple tools in one MCP server",
|
|
10822
|
-
command: '{ "mcpServers": { "my-tools": { "type": "stdio", "command": "mtpcli", "args": ["serve", "--tool", "tool1", "--tool", "tool2"] } } }'
|
|
10823
|
-
}
|
|
10824
|
-
]
|
|
10825
|
-
},
|
|
10826
|
-
{
|
|
10827
|
-
name: "wrap",
|
|
10828
|
-
description: "Wrap an MCP server as a --mtp-describe-compatible CLI",
|
|
10829
|
-
args: [
|
|
10830
|
-
{
|
|
10831
|
-
name: "--server",
|
|
10832
|
-
type: "string",
|
|
10833
|
-
description: "MCP server command (stdio transport)"
|
|
10834
|
-
},
|
|
10835
|
-
{
|
|
10836
|
-
name: "--url",
|
|
10837
|
-
type: "string",
|
|
10838
|
-
description: "MCP server URL (Streamable HTTP transport). Mutually exclusive with --server."
|
|
10839
|
-
},
|
|
10840
|
-
{
|
|
10841
|
-
name: "--header",
|
|
10842
|
-
type: "array",
|
|
10843
|
-
description: "HTTP header(s) for --url, e.g. 'Authorization: Bearer tok'. Repeatable."
|
|
10844
|
-
},
|
|
10845
|
-
{
|
|
10846
|
-
name: "--client-id",
|
|
10847
|
-
type: "string",
|
|
10848
|
-
description: "Pre-registered OAuth client ID (for servers without dynamic registration)"
|
|
10849
|
-
},
|
|
10850
|
-
{
|
|
10851
|
-
name: "--mtp-describe",
|
|
10852
|
-
type: "boolean",
|
|
10853
|
-
description: "Output --mtp-describe JSON"
|
|
10854
|
-
},
|
|
10855
|
-
{
|
|
10856
|
-
name: "tool_name",
|
|
10857
|
-
type: "string",
|
|
10858
|
-
description: "Tool to invoke"
|
|
10859
|
-
}
|
|
10860
|
-
],
|
|
10861
|
-
examples: [
|
|
10862
|
-
{
|
|
10863
|
-
description: "Describe a stdio MCP server",
|
|
10864
|
-
command: 'mtpcli wrap --server "npx @mcp/server-github" --mtp-describe'
|
|
10865
|
-
},
|
|
10866
|
-
{
|
|
10867
|
-
description: "Call a tool on a stdio server",
|
|
10868
|
-
command: 'mtpcli wrap --server "npx @mcp/server-github" search_repos -- --query mtpcli'
|
|
10869
|
-
},
|
|
10870
|
-
{
|
|
10871
|
-
description: "Describe an HTTP MCP server",
|
|
10872
|
-
command: "mtpcli wrap --url http://localhost:3000/mcp --mtp-describe"
|
|
10873
|
-
},
|
|
10874
|
-
{
|
|
10875
|
-
description: "Call a tool on an HTTP server",
|
|
10876
|
-
command: "mtpcli wrap --url http://localhost:3000/mcp search_repos -- --query mtpcli"
|
|
10877
|
-
}
|
|
10878
|
-
]
|
|
10879
|
-
},
|
|
10880
|
-
{
|
|
10881
|
-
name: "validate",
|
|
10882
|
-
description: "Validate a tool's --mtp-describe output against the MTP spec",
|
|
10883
|
-
args: [
|
|
10884
|
-
{
|
|
10885
|
-
name: "tool",
|
|
10886
|
-
type: "string",
|
|
10887
|
-
description: "Tool name to validate"
|
|
10888
|
-
},
|
|
10889
|
-
{
|
|
10890
|
-
name: "--json",
|
|
10891
|
-
type: "boolean",
|
|
10892
|
-
default: false,
|
|
10893
|
-
description: "Output as JSON"
|
|
10894
|
-
},
|
|
10895
|
-
{
|
|
10896
|
-
name: "--stdin",
|
|
10897
|
-
type: "boolean",
|
|
10898
|
-
default: false,
|
|
10899
|
-
description: "Read JSON from stdin instead of running tool"
|
|
10900
|
-
},
|
|
10901
|
-
{
|
|
10902
|
-
name: "--skip-help",
|
|
10903
|
-
type: "boolean",
|
|
10904
|
-
default: false,
|
|
10905
|
-
description: "Skip --help cross-reference check"
|
|
10906
|
-
}
|
|
10907
|
-
],
|
|
10908
|
-
examples: [
|
|
10909
|
-
{
|
|
10910
|
-
description: "Validate a tool",
|
|
10911
|
-
command: "mtpcli validate mytool"
|
|
10912
|
-
},
|
|
10913
|
-
{
|
|
10914
|
-
description: "Validate from stdin",
|
|
10915
|
-
command: "cat describe.json | mtpcli validate --stdin"
|
|
10916
|
-
},
|
|
10917
|
-
{
|
|
10918
|
-
description: "JSON output for CI",
|
|
10919
|
-
command: "mtpcli validate mytool --json"
|
|
10920
|
-
}
|
|
10921
|
-
]
|
|
10922
|
-
},
|
|
10923
|
-
{
|
|
10924
|
-
name: "completions",
|
|
10925
|
-
description: "Generate shell completions for a --mtp-describe-compatible tool",
|
|
10926
|
-
args: [
|
|
10927
|
-
{
|
|
10928
|
-
name: "shell",
|
|
10929
|
-
type: "enum",
|
|
10930
|
-
required: true,
|
|
10931
|
-
values: ["bash", "zsh", "fish"],
|
|
10932
|
-
description: "Target shell"
|
|
10933
|
-
},
|
|
10934
|
-
{
|
|
10935
|
-
name: "tool",
|
|
10936
|
-
type: "string",
|
|
10937
|
-
required: true,
|
|
10938
|
-
description: "Tool name"
|
|
10939
|
-
}
|
|
10940
|
-
],
|
|
10941
|
-
examples: [
|
|
10942
|
-
{
|
|
10943
|
-
description: "Install bash completions",
|
|
10944
|
-
command: "eval $(mtpcli completions bash mytool)"
|
|
10945
|
-
},
|
|
10946
|
-
{
|
|
10947
|
-
description: "Install zsh completions",
|
|
10948
|
-
command: "eval $(mtpcli completions zsh mytool)"
|
|
10949
|
-
},
|
|
10950
|
-
{
|
|
10951
|
-
description: "Install fish completions",
|
|
10952
|
-
command: "mtpcli completions fish mytool | source"
|
|
10953
|
-
}
|
|
10954
|
-
]
|
|
10955
|
-
}
|
|
10956
|
-
]
|
|
10957
|
-
};
|
|
10958
|
-
console.log(JSON.stringify(cleanJson(schema), null, 2));
|
|
10959
|
-
}
|
|
10960
|
-
var program2 = new Command().name("mtpcli").version(VERSION).description("Unified CLI for discovering, authenticating, and bridging --mtp-describe-compatible tools").option("--mtp-describe", "Print self-describing JSON (MTP spec)").action(async (opts) => {
|
|
10961
|
-
if (opts.mtpDescribe) {
|
|
10962
|
-
selfDescribe();
|
|
10963
|
-
return;
|
|
10964
|
-
}
|
|
10965
|
-
program2.help();
|
|
10966
|
-
});
|
|
10657
|
+
var program2 = new Command().name("mtpcli").version(VERSION).description("Unified CLI for discovering, authenticating, and bridging --mtp-describe-compatible tools");
|
|
10967
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) => {
|
|
10968
10659
|
const { search: search2, loadSchemas: loadSchemas2, scanPath: scanPath2 } = await Promise.resolve().then(() => (init_search(), exports_search));
|
|
10969
10660
|
const schemas = opts.scanPath ? await scanPath2(parseInt(opts.jobs, 10)) : await loadSchemas2(tools);
|
|
@@ -11111,7 +10802,7 @@ Multiple tools can be combined into a single MCP server:
|
|
|
11111
10802
|
const { run: run5 } = await Promise.resolve().then(() => (init_serve(), exports_serve));
|
|
11112
10803
|
await run5(opts.tool);
|
|
11113
10804
|
});
|
|
11114
|
-
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)").
|
|
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) => {
|
|
11115
10806
|
if (opts.server && opts.url) {
|
|
11116
10807
|
process.stderr.write(`error: --server and --url are mutually exclusive
|
|
11117
10808
|
`);
|
|
@@ -11133,7 +10824,7 @@ program2.command("wrap").description("Wrap an MCP server as a CLI tool (mcp2cli
|
|
|
11133
10824
|
process.exit(1);
|
|
11134
10825
|
}
|
|
11135
10826
|
const { run: run5 } = await Promise.resolve().then(() => (init_wrap(), exports_wrap));
|
|
11136
|
-
await run5(opts.server, opts.url,
|
|
10827
|
+
await run5(opts.server, opts.url, toolName, args, opts.header ?? [], opts.clientId);
|
|
11137
10828
|
});
|
|
11138
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) => {
|
|
11139
10830
|
const { run: run5 } = await Promise.resolve().then(() => (init_validate(), exports_validate));
|
|
@@ -11147,6 +10838,83 @@ program2.command("completions").description("Generate shell completions from --m
|
|
|
11147
10838
|
const { run: run5 } = await Promise.resolve().then(() => (init_completions(), exports_completions));
|
|
11148
10839
|
await run5(shell, tool);
|
|
11149
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"' },
|
|
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" },
|
|
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
|
+
}
|
|
10916
|
+
};
|
|
10917
|
+
withDescribe(program2, describeOptions);
|
|
11150
10918
|
try {
|
|
11151
10919
|
await program2.parseAsync(process.argv);
|
|
11152
10920
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modeltoolsprotocol/mtpcli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"typecheck": "tsc --noEmit"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"@modeltoolsprotocol/sdk": "^0.4.0",
|
|
20
21
|
"commander": "^14.0.0",
|
|
21
22
|
"jaro-winkler": "^0.2.8",
|
|
22
23
|
"open": "^11.0.0",
|