@modeltoolsprotocol/mtpcli 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.js +75 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ The command-line interface for the [Model Tools Protocol](https://github.com/mod
|
|
|
6
6
|
|
|
7
7
|
LLM agents need to discover and use tools. Right now there are two worlds:
|
|
8
8
|
|
|
9
|
-
**CLI tools** are the backbone of software development. They're composable (`|`), scriptable, version-controlled, and work everywhere. But LLMs can't discover what a CLI does -they have to parse `--help` text, guess at arguments, and hope for the best.
|
|
9
|
+
**CLI tools** are the backbone of software development. They're composable (`|`), scriptable, version-controlled, and work everywhere. But LLMs can't discover what a CLI does - they have to parse `--help` text, guess at arguments, and hope for the best.
|
|
10
10
|
|
|
11
11
|
**MCP (Model Context Protocol)** solves discovery beautifully. Tools declare typed schemas, and LLM hosts discover them via a structured handshake. But MCP requires running a server process, speaking JSON-RPC over stdio/SSE, and building within the MCP ecosystem. Your existing CLI tools don't get any of this for free.
|
|
12
12
|
|
package/dist/index.js
CHANGED
|
@@ -7917,17 +7917,38 @@ function sendNotification(writer, method, params) {
|
|
|
7917
7917
|
writer.write(JSON.stringify(req) + `
|
|
7918
7918
|
`);
|
|
7919
7919
|
}
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
const
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7920
|
+
function readResponse(rl) {
|
|
7921
|
+
return new Promise((resolve, reject) => {
|
|
7922
|
+
const onLine = (line) => {
|
|
7923
|
+
const trimmed = line.trim();
|
|
7924
|
+
if (!trimmed)
|
|
7925
|
+
return;
|
|
7926
|
+
let msg;
|
|
7927
|
+
try {
|
|
7928
|
+
msg = JSON.parse(trimmed);
|
|
7929
|
+
} catch (e) {
|
|
7930
|
+
rl.off("line", onLine);
|
|
7931
|
+
rl.off("close", onClose);
|
|
7932
|
+
reject(e);
|
|
7933
|
+
return;
|
|
7934
|
+
}
|
|
7935
|
+
if ("id" in msg && msg.id !== undefined) {
|
|
7936
|
+
rl.off("line", onLine);
|
|
7937
|
+
rl.off("close", onClose);
|
|
7938
|
+
try {
|
|
7939
|
+
resolve(JsonRpcResponseSchema2.parse(msg));
|
|
7940
|
+
} catch (e) {
|
|
7941
|
+
reject(e);
|
|
7942
|
+
}
|
|
7943
|
+
}
|
|
7944
|
+
};
|
|
7945
|
+
const onClose = () => {
|
|
7946
|
+
rl.off("line", onLine);
|
|
7947
|
+
reject(new Error("MCP server closed connection"));
|
|
7948
|
+
};
|
|
7949
|
+
rl.on("line", onLine);
|
|
7950
|
+
rl.on("close", onClose);
|
|
7951
|
+
});
|
|
7931
7952
|
}
|
|
7932
7953
|
var init_mcp = __esm(() => {
|
|
7933
7954
|
init_models();
|
|
@@ -9187,7 +9208,7 @@ function cleanJson(obj) {
|
|
|
9187
9208
|
}
|
|
9188
9209
|
|
|
9189
9210
|
// src/index.ts
|
|
9190
|
-
var VERSION3 = "0.2.
|
|
9211
|
+
var VERSION3 = "0.2.2";
|
|
9191
9212
|
function selfDescribe() {
|
|
9192
9213
|
const schema = {
|
|
9193
9214
|
name: "mtpcli",
|
|
@@ -9334,23 +9355,23 @@ function selfDescribe() {
|
|
|
9334
9355
|
},
|
|
9335
9356
|
{
|
|
9336
9357
|
name: "serve",
|
|
9337
|
-
description: "Serve CLI tools as an MCP server over stdio",
|
|
9358
|
+
description: "Serve CLI tools as an MCP server over stdio. Not meant to be run directly; add to your MCP client config instead.",
|
|
9338
9359
|
args: [
|
|
9339
9360
|
{
|
|
9340
9361
|
name: "--tool",
|
|
9341
9362
|
type: "array",
|
|
9342
9363
|
required: true,
|
|
9343
|
-
description: "Tool name(s) to serve"
|
|
9364
|
+
description: "Tool name(s) to serve (must support --describe)"
|
|
9344
9365
|
}
|
|
9345
9366
|
],
|
|
9346
9367
|
examples: [
|
|
9347
9368
|
{
|
|
9348
|
-
description: "
|
|
9349
|
-
command: "mtpcli serve --tool
|
|
9369
|
+
description: "Add to ~/.claude.json as an MCP server",
|
|
9370
|
+
command: '{ "mcpServers": { "my-tools": { "type": "stdio", "command": "mtpcli", "args": ["serve", "--tool", "my-cli-tool"] } } }'
|
|
9350
9371
|
},
|
|
9351
9372
|
{
|
|
9352
|
-
description: "Serve multiple tools",
|
|
9353
|
-
command: "mtpcli serve --tool
|
|
9373
|
+
description: "Serve multiple tools in one MCP server",
|
|
9374
|
+
command: '{ "mcpServers": { "my-tools": { "type": "stdio", "command": "mtpcli", "args": ["serve", "--tool", "tool1", "--tool", "tool2"] } } }'
|
|
9354
9375
|
}
|
|
9355
9376
|
]
|
|
9356
9377
|
},
|
|
@@ -9520,7 +9541,42 @@ authCmd.command("refresh").description("Force-refresh the stored OAuth token for
|
|
|
9520
9541
|
const { runRefresh: runRefresh2 } = await Promise.resolve().then(() => (init_auth(), exports_auth));
|
|
9521
9542
|
await runRefresh2(tool);
|
|
9522
9543
|
});
|
|
9523
|
-
program2.command("serve").description("Serve CLI tools as an MCP server (cli2mcp bridge)").requiredOption("--tool <names...>", "Tool(s) to serve").
|
|
9544
|
+
program2.command("serve").description("Serve CLI tools as an MCP server (cli2mcp bridge)").requiredOption("--tool <names...>", "Tool(s) to serve").addHelpText("after", `
|
|
9545
|
+
This command is meant to be used as an MCP server, not run directly.
|
|
9546
|
+
Add it to your MCP client config (e.g. ~/.claude.json):
|
|
9547
|
+
|
|
9548
|
+
{
|
|
9549
|
+
"mcpServers": {
|
|
9550
|
+
"my-tools": {
|
|
9551
|
+
"type": "stdio",
|
|
9552
|
+
"command": "mtpcli",
|
|
9553
|
+
"args": ["serve", "--tool", "my-cli-tool"]
|
|
9554
|
+
}
|
|
9555
|
+
}
|
|
9556
|
+
}
|
|
9557
|
+
|
|
9558
|
+
Any CLI tool on your PATH that supports --describe can be served.
|
|
9559
|
+
Multiple tools can be combined into a single MCP server:
|
|
9560
|
+
|
|
9561
|
+
mtpcli serve --tool tool1 --tool tool2`).action(async (opts) => {
|
|
9562
|
+
if (process.stdin.isTTY) {
|
|
9563
|
+
process.stderr.write(`Error: 'mtpcli serve' is an MCP server and should not be run directly.
|
|
9564
|
+
` + `Add it to your MCP client config instead. For example, in ~/.claude.json:
|
|
9565
|
+
|
|
9566
|
+
` + ` {
|
|
9567
|
+
` + ` "mcpServers": {
|
|
9568
|
+
` + ` "my-tools": {
|
|
9569
|
+
` + ` "type": "stdio",
|
|
9570
|
+
` + ` "command": "mtpcli",
|
|
9571
|
+
` + ` "args": ["serve", "--tool", ${JSON.stringify(opts.tool[0] ?? "my-cli-tool")}]
|
|
9572
|
+
` + ` }
|
|
9573
|
+
` + ` }
|
|
9574
|
+
` + ` }
|
|
9575
|
+
|
|
9576
|
+
` + `Run 'mtpcli serve --help' for more details.
|
|
9577
|
+
`);
|
|
9578
|
+
process.exit(1);
|
|
9579
|
+
}
|
|
9524
9580
|
const { run: run5 } = await Promise.resolve().then(() => (init_serve(), exports_serve));
|
|
9525
9581
|
await run5(opts.tool);
|
|
9526
9582
|
});
|