mcp-caller 0.0.4 → 0.0.6
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 +6 -0
- package/index.js +37 -1
- package/package.json +9 -1
package/README.md
CHANGED
|
@@ -48,6 +48,12 @@ Read JSON from files instead of inline values:
|
|
|
48
48
|
npx -y mcp-caller --server-file server.json --call-file call.json
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
+
Short call form:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx -y mcp-caller --server-file server.json --tool say_hello --params-json '{"name":"world"}'
|
|
55
|
+
```
|
|
56
|
+
|
|
51
57
|
List callable tools:
|
|
52
58
|
|
|
53
59
|
```bash
|
package/index.js
CHANGED
|
@@ -9,6 +9,7 @@ function printUsage() {
|
|
|
9
9
|
console.error(`Usage:
|
|
10
10
|
mcp-caller --server-json <json> --list-tools
|
|
11
11
|
mcp-caller --server-json <json> --inspect
|
|
12
|
+
mcp-caller --server-json <json> --tool <name> [--params-json <json>]
|
|
12
13
|
mcp-caller --server-json <json> --call-json <json>
|
|
13
14
|
mcp-caller --server-file <path> --call-file <path>
|
|
14
15
|
|
|
@@ -59,6 +60,16 @@ function readSource(options, jsonKey, fileKey, label) {
|
|
|
59
60
|
throw new Error(`Missing ${label}`);
|
|
60
61
|
}
|
|
61
62
|
|
|
63
|
+
function readParams(options) {
|
|
64
|
+
if (options.paramsFile) {
|
|
65
|
+
return parseJson(readFileSync(options.paramsFile, "utf8"), "--params-json/--params-file");
|
|
66
|
+
}
|
|
67
|
+
if (options.paramsJson) {
|
|
68
|
+
return parseJson(options.paramsJson, "--params-json/--params-file");
|
|
69
|
+
}
|
|
70
|
+
return {};
|
|
71
|
+
}
|
|
72
|
+
|
|
62
73
|
function parseArgs(argv) {
|
|
63
74
|
const options = {};
|
|
64
75
|
for (let i = 0; i < argv.length; i += 1) {
|
|
@@ -83,6 +94,18 @@ function parseArgs(argv) {
|
|
|
83
94
|
options.callFile = argv[++i];
|
|
84
95
|
continue;
|
|
85
96
|
}
|
|
97
|
+
if (token === "--tool") {
|
|
98
|
+
options.tool = argv[++i];
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (token === "--params-json") {
|
|
102
|
+
options.paramsJson = argv[++i];
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (token === "--params-file") {
|
|
106
|
+
options.paramsFile = argv[++i];
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
86
109
|
if (token === "--list-tools") {
|
|
87
110
|
options.listTools = true;
|
|
88
111
|
continue;
|
|
@@ -196,9 +219,22 @@ async function main() {
|
|
|
196
219
|
}
|
|
197
220
|
|
|
198
221
|
const serverSource = readSource(options, "serverJson", "serverFile", "--server-json/--server-file");
|
|
222
|
+
if (options.tool && (options.callJson || options.callFile)) {
|
|
223
|
+
throw new Error("Use either --tool/--params-json or --call-json/--call-file, not both");
|
|
224
|
+
}
|
|
225
|
+
if (options.tool && options.tool.trim().length === 0) {
|
|
226
|
+
throw new Error('Option "--tool" must be a non-empty string');
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const shorthandCall = options.tool
|
|
230
|
+
? {
|
|
231
|
+
tool: options.tool,
|
|
232
|
+
params: readParams(options)
|
|
233
|
+
}
|
|
234
|
+
: null;
|
|
199
235
|
const callSource = options.listTools || options.inspect
|
|
200
236
|
? null
|
|
201
|
-
: readSource(options, "callJson", "callFile", "--call-json/--call-file");
|
|
237
|
+
: shorthandCall ?? readSource(options, "callJson", "callFile", "--call-json/--call-file");
|
|
202
238
|
|
|
203
239
|
if (callSource) {
|
|
204
240
|
if (typeof callSource !== "object") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mcp-caller",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "A small MCP client CLI that can start a server and call a tool from JSON input.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -31,6 +31,14 @@
|
|
|
31
31
|
"stdio",
|
|
32
32
|
"streamable-http"
|
|
33
33
|
],
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/ab498/mcp-caller.git"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/ab498/mcp-caller/issues"
|
|
40
|
+
},
|
|
41
|
+
"homepage": "https://github.com/ab498/mcp-caller#readme",
|
|
34
42
|
"author": "ab498",
|
|
35
43
|
"license": "MIT",
|
|
36
44
|
"engines": {
|