@modeltoolsprotocol/mtpcli 0.3.1 → 0.3.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 +36 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ LLM agents need to discover and use tools. Right now there are two worlds:
|
|
|
20
20
|
| **Scriptable without an LLM** | Yes, that's the whole point of CLIs | Not really, designed for LLM interaction |
|
|
21
21
|
| **Adoption cost** | One flag/decorator | New protocol, server scaffolding, SDK |
|
|
22
22
|
|
|
23
|
-
The gap is discovery. `mtpcli` fills it.
|
|
23
|
+
The gap for CLIs is discovery. `mtpcli` fills it.
|
|
24
24
|
|
|
25
25
|
## Install
|
|
26
26
|
|
package/dist/index.js
CHANGED
|
@@ -8738,7 +8738,7 @@ function argToJsonSchema(arg) {
|
|
|
8738
8738
|
return schema;
|
|
8739
8739
|
}
|
|
8740
8740
|
function commandToMcpTool(toolName, cmd) {
|
|
8741
|
-
const mcpName = cmd.name === "_root" ? toolName : `${toolName}__${cmd.name}`;
|
|
8741
|
+
const mcpName = cmd.name === "_root" ? toolName : `${toolName}__${cmd.name.replace(/ /g, "_")}`;
|
|
8742
8742
|
const properties = {};
|
|
8743
8743
|
const required = [];
|
|
8744
8744
|
for (const arg of cmd.args) {
|
|
@@ -8772,7 +8772,7 @@ function commandToMcpTool(toolName, cmd) {
|
|
|
8772
8772
|
function buildCliCommand(toolName, commandName, arguments_, commandSchema) {
|
|
8773
8773
|
const cmd = [toolName];
|
|
8774
8774
|
if (commandName !== "_root")
|
|
8775
|
-
cmd.push(commandName);
|
|
8775
|
+
cmd.push(...commandName.split(" "));
|
|
8776
8776
|
const argSchemas = new Map;
|
|
8777
8777
|
for (const a of commandSchema.args) {
|
|
8778
8778
|
argSchemas.set(a.name.replace(/^-+/, ""), a);
|
|
@@ -8826,29 +8826,57 @@ function invokeCliTool(toolName, commandName, arguments_, commandSchema, authEnv
|
|
|
8826
8826
|
stdio: [stdinStr !== undefined ? "pipe" : "ignore", "pipe", "pipe"],
|
|
8827
8827
|
env: { ...process.env, ...authEnv }
|
|
8828
8828
|
});
|
|
8829
|
+
const timer = setTimeout(() => {
|
|
8830
|
+
child.kill();
|
|
8831
|
+
resolve({
|
|
8832
|
+
content: [{ type: "text", text: `Error: tool timed out after ${TOOL_TIMEOUT_MS / 1000}s` }],
|
|
8833
|
+
isError: true
|
|
8834
|
+
});
|
|
8835
|
+
}, TOOL_TIMEOUT_MS);
|
|
8829
8836
|
if (stdinStr !== undefined && child.stdin) {
|
|
8830
8837
|
child.stdin.write(stdinStr);
|
|
8831
8838
|
child.stdin.end();
|
|
8832
8839
|
}
|
|
8833
8840
|
let stdout = "";
|
|
8834
8841
|
let stderr = "";
|
|
8835
|
-
|
|
8836
|
-
|
|
8842
|
+
let stdoutBytes = 0;
|
|
8843
|
+
let stderrBytes = 0;
|
|
8844
|
+
let truncated = false;
|
|
8845
|
+
child.stdout?.on("data", (d) => {
|
|
8846
|
+
stdoutBytes += d.length;
|
|
8847
|
+
if (stdoutBytes <= MAX_OUTPUT_BYTES) {
|
|
8848
|
+
stdout += d;
|
|
8849
|
+
} else if (!truncated) {
|
|
8850
|
+
truncated = true;
|
|
8851
|
+
child.kill();
|
|
8852
|
+
}
|
|
8853
|
+
});
|
|
8854
|
+
child.stderr?.on("data", (d) => {
|
|
8855
|
+
stderrBytes += d.length;
|
|
8856
|
+
if (stderrBytes <= MAX_OUTPUT_BYTES) {
|
|
8857
|
+
stderr += d;
|
|
8858
|
+
}
|
|
8859
|
+
});
|
|
8837
8860
|
child.on("error", (e) => {
|
|
8861
|
+
clearTimeout(timer);
|
|
8838
8862
|
resolve({
|
|
8839
8863
|
content: [{ type: "text", text: `Error: ${e.message}` }],
|
|
8840
8864
|
isError: true
|
|
8841
8865
|
});
|
|
8842
8866
|
});
|
|
8843
8867
|
child.on("close", (code) => {
|
|
8868
|
+
clearTimeout(timer);
|
|
8844
8869
|
const content = [];
|
|
8870
|
+
if (truncated) {
|
|
8871
|
+
content.push({ type: "text", text: `[truncated: output exceeded ${MAX_OUTPUT_BYTES / 1024 / 1024}MB]` });
|
|
8872
|
+
}
|
|
8845
8873
|
if (stdout.trim())
|
|
8846
8874
|
content.push({ type: "text", text: stdout.trim() });
|
|
8847
8875
|
if (stderr.trim())
|
|
8848
8876
|
content.push({ type: "text", text: `[stderr] ${stderr.trim()}` });
|
|
8849
8877
|
if (content.length === 0)
|
|
8850
8878
|
content.push({ type: "text", text: "(no output)" });
|
|
8851
|
-
resolve({ content, isError: code !== 0 });
|
|
8879
|
+
resolve({ content, isError: code !== 0 || truncated });
|
|
8852
8880
|
});
|
|
8853
8881
|
});
|
|
8854
8882
|
}
|
|
@@ -8948,13 +8976,14 @@ async function run(toolNames) {
|
|
|
8948
8976
|
}
|
|
8949
8977
|
}
|
|
8950
8978
|
}
|
|
8951
|
-
var execFileAsync7, VERSION = "0.1.0";
|
|
8979
|
+
var execFileAsync7, VERSION = "0.1.0", TOOL_TIMEOUT_MS = 60000, MAX_OUTPUT_BYTES;
|
|
8952
8980
|
var init_serve = __esm(() => {
|
|
8953
8981
|
init_auth();
|
|
8954
8982
|
init_mcp();
|
|
8955
8983
|
init_models();
|
|
8956
8984
|
init_search2();
|
|
8957
8985
|
execFileAsync7 = promisify9(execFile9);
|
|
8986
|
+
MAX_OUTPUT_BYTES = 1024 * 1024 * 1024;
|
|
8958
8987
|
});
|
|
8959
8988
|
|
|
8960
8989
|
// src/mcp-oauth.ts
|
|
@@ -10564,7 +10593,7 @@ function cleanJson(obj) {
|
|
|
10564
10593
|
}
|
|
10565
10594
|
|
|
10566
10595
|
// src/index.ts
|
|
10567
|
-
var VERSION3 = "0.3.
|
|
10596
|
+
var VERSION3 = "0.3.2";
|
|
10568
10597
|
function selfDescribe() {
|
|
10569
10598
|
const schema = {
|
|
10570
10599
|
name: "mtpcli",
|