@titikaka2026/mcptools 0.1.0 → 0.1.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/CHANGELOG.md +33 -0
- package/README.md +34 -13
- package/SECURITY.md +46 -0
- package/dist/commands/create.js +4 -4
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/wrap.js +4 -6
- package/dist/commands/wrap.js.map +1 -1
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +12 -8
- package/dist/core/client.js.map +1 -1
- package/dist/core/wrap-cli.js +7 -5
- package/dist/core/wrap-cli.js.map +1 -1
- package/dist/core/wrap-rest.d.ts.map +1 -1
- package/dist/core/wrap-rest.js +31 -11
- package/dist/core/wrap-rest.js.map +1 -1
- package/docs/RELEASE_CHECKLIST.md +53 -0
- package/examples/docker-cli.json +85 -0
- package/examples/github-api.json +125 -0
- package/examples/weather-api.json +81 -0
- package/package.json +9 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here.
|
|
4
|
+
|
|
5
|
+
## 0.1.1 - 2026-06-04
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Generate complete REST wrapper servers from the programmatic `wrapRestApi()` API.
|
|
10
|
+
- Encode REST path and query parameters before sending generated requests.
|
|
11
|
+
- Generate valid POST request bodies from tool arguments.
|
|
12
|
+
- Support safer generated handler names for REST tools.
|
|
13
|
+
- Quote CLI wrapper command names, subcommands, flags, and hyphenated argument keys.
|
|
14
|
+
- Clear MCP client request timeouts after successful responses so `mcptools test` exits promptly.
|
|
15
|
+
- Update generated next-step commands to use `--command` with `--args`.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- CI coverage for Node.js 20 and 22.
|
|
20
|
+
- Runtime dependency audit through `npm run audit:runtime`.
|
|
21
|
+
- Security policy and generated wrapper review guidance.
|
|
22
|
+
- Release checklist for repeatable maintainer workflow.
|
|
23
|
+
- Issue templates for bug reports and feature requests.
|
|
24
|
+
- Tests for REST and CLI wrapper generation edge cases.
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- Use `npm run check` as the publish gate.
|
|
29
|
+
- Include docs, examples, and security guidance in the published package.
|
|
30
|
+
|
|
31
|
+
## 0.1.0 - 2026-03-27
|
|
32
|
+
|
|
33
|
+
Initial public release of mcptools.
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
Create, test, inspect, and wrap MCP servers with ease.
|
|
8
8
|
|
|
9
|
-
[](https://www.npmjs.com/package/@titikaka2026/mcptools)
|
|
10
10
|
[](https://opensource.org/licenses/MIT)
|
|
11
11
|
[](https://nodejs.org)
|
|
12
12
|
[](https://github.com/titikaka2024/mcptools/stargazers)
|
|
@@ -20,6 +20,15 @@ Create, test, inspect, and wrap MCP servers with ease.
|
|
|
20
20
|
|
|
21
21
|
MCP is the open protocol that lets AI assistants (Claude, GPT, etc.) call external tools, read data, and interact with the world. **mcptools** makes building and debugging MCP servers fast and painless.
|
|
22
22
|
|
|
23
|
+
## Project status
|
|
24
|
+
|
|
25
|
+
mcptools is an early-stage, actively maintained toolkit for MCP server authors. The current focus is reliability over feature count:
|
|
26
|
+
|
|
27
|
+
- reproducible TypeScript builds and Vitest coverage for wrapper generation and validation
|
|
28
|
+
- safe-by-default REST and CLI wrapper generation using `fetch` and `execFile`
|
|
29
|
+
- documented security expectations for generated wrappers in [SECURITY.md](SECURITY.md)
|
|
30
|
+
- release hygiene tracked in [docs/RELEASE_CHECKLIST.md](docs/RELEASE_CHECKLIST.md)
|
|
31
|
+
|
|
23
32
|
## Why mcptools?
|
|
24
33
|
|
|
25
34
|
Building MCP servers today means writing boilerplate JSON-RPC handling, manually testing with `echo | node`, and guessing why your server isn't connecting. mcptools fixes all of that:
|
|
@@ -34,7 +43,7 @@ Building MCP servers today means writing boilerplate JSON-RPC handling, manually
|
|
|
34
43
|
|
|
35
44
|
```bash
|
|
36
45
|
# Install globally
|
|
37
|
-
npm install -g mcptools
|
|
46
|
+
npm install -g @titikaka2026/mcptools
|
|
38
47
|
|
|
39
48
|
# Create a new MCP server
|
|
40
49
|
mcptools create my-server
|
|
@@ -42,19 +51,19 @@ mcptools create my-server
|
|
|
42
51
|
# Build and test it
|
|
43
52
|
cd my-server
|
|
44
53
|
npm install && npm run build
|
|
45
|
-
mcptools test --command
|
|
54
|
+
mcptools test --command node --args dist/index.js
|
|
46
55
|
```
|
|
47
56
|
|
|
48
57
|
## Installation
|
|
49
58
|
|
|
50
59
|
```bash
|
|
51
|
-
npm install -g mcptools
|
|
60
|
+
npm install -g @titikaka2026/mcptools
|
|
52
61
|
```
|
|
53
62
|
|
|
54
63
|
Or use with npx:
|
|
55
64
|
|
|
56
65
|
```bash
|
|
57
|
-
npx mcptools create my-server
|
|
66
|
+
npx @titikaka2026/mcptools create my-server
|
|
58
67
|
```
|
|
59
68
|
|
|
60
69
|
## Commands
|
|
@@ -90,13 +99,13 @@ Connect to an MCP server and verify it responds correctly.
|
|
|
90
99
|
|
|
91
100
|
```bash
|
|
92
101
|
# Test a local server
|
|
93
|
-
mcptools test --command
|
|
102
|
+
mcptools test --command node --args dist/index.js
|
|
94
103
|
|
|
95
104
|
# Test with validation
|
|
96
|
-
mcptools test --command
|
|
105
|
+
mcptools test --command node --args dist/index.js --validate
|
|
97
106
|
|
|
98
107
|
# Output as JSON (for CI/CD)
|
|
99
|
-
mcptools test --command
|
|
108
|
+
mcptools test --command node --args dist/index.js --json
|
|
100
109
|
```
|
|
101
110
|
|
|
102
111
|
**Output includes:**
|
|
@@ -111,10 +120,10 @@ Debug MCP communication by watching all JSON-RPC messages flowing between client
|
|
|
111
120
|
|
|
112
121
|
```bash
|
|
113
122
|
# Inspect server communication
|
|
114
|
-
mcptools inspect --command
|
|
123
|
+
mcptools inspect --command node --args dist/index.js
|
|
115
124
|
|
|
116
125
|
# Show raw JSON messages
|
|
117
|
-
mcptools inspect --command
|
|
126
|
+
mcptools inspect --command node --args dist/index.js --raw
|
|
118
127
|
```
|
|
119
128
|
|
|
120
129
|
**Output shows:**
|
|
@@ -192,7 +201,7 @@ mcptools wrap cli --config cli.json --output ./generated
|
|
|
192
201
|
Use mcptools as a library in your own projects:
|
|
193
202
|
|
|
194
203
|
```typescript
|
|
195
|
-
import { McpClient, McpValidator } from "mcptools";
|
|
204
|
+
import { McpClient, McpValidator } from "@titikaka2026/mcptools";
|
|
196
205
|
|
|
197
206
|
// Connect to an MCP server
|
|
198
207
|
const client = new McpClient({
|
|
@@ -227,7 +236,7 @@ await client.disconnect();
|
|
|
227
236
|
mcptools create hello-world
|
|
228
237
|
cd hello-world
|
|
229
238
|
npm install && npm run build
|
|
230
|
-
mcptools test --command
|
|
239
|
+
mcptools test --command node --args dist/index.js
|
|
231
240
|
```
|
|
232
241
|
|
|
233
242
|
### Wrap the GitHub API
|
|
@@ -264,7 +273,7 @@ mcptools test --command "node dist/index.js"
|
|
|
264
273
|
|
|
265
274
|
```bash
|
|
266
275
|
mcptools wrap rest --config github-api.json
|
|
267
|
-
mcptools test --command
|
|
276
|
+
mcptools test --command node --args github-mcp-mcp-server.mjs
|
|
268
277
|
```
|
|
269
278
|
|
|
270
279
|
### Use with Claude Desktop
|
|
@@ -296,8 +305,20 @@ After building your MCP server, add it to Claude Desktop's config:
|
|
|
296
305
|
| Wrap existing APIs | Write hundreds of lines | One JSON config file |
|
|
297
306
|
| TypeScript + Python | DIY | Templates for both |
|
|
298
307
|
|
|
308
|
+
## Security model for generated wrappers
|
|
309
|
+
|
|
310
|
+
Generated MCP wrappers can bridge AI assistants to external APIs and local commands. mcptools therefore keeps the generated code explicit and reviewable:
|
|
311
|
+
|
|
312
|
+
- REST wrappers use `fetch`, encode path/query parameters, and validate required arguments before calling endpoints.
|
|
313
|
+
- CLI wrappers use `execFile` with an argument array instead of shell string execution.
|
|
314
|
+
- Generated code should be reviewed before connecting it to private APIs, credentials, destructive commands, or production environments.
|
|
315
|
+
|
|
316
|
+
See [SECURITY.md](SECURITY.md) for the maintainer policy, reporting process, and wrapper hardening checklist.
|
|
317
|
+
|
|
299
318
|
## Roadmap
|
|
300
319
|
|
|
320
|
+
- [x] CI for build and test on Node 20
|
|
321
|
+
- [x] Security guidance for REST and CLI wrappers
|
|
301
322
|
- [ ] SSE transport support
|
|
302
323
|
- [ ] OpenAPI → MCP auto-conversion (import Swagger/OpenAPI specs directly)
|
|
303
324
|
- [ ] MCP server registry (discover and install community servers)
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
mcptools generates and validates MCP servers. Some generated servers can connect AI assistants to external APIs, local commands, credentials, and JSON-RPC tool calls. Treat generated wrappers as code that must be reviewed before use with private systems or production data.
|
|
4
|
+
|
|
5
|
+
## Supported Versions
|
|
6
|
+
|
|
7
|
+
The project is early-stage. Security fixes are currently made against the `main` branch and the latest npm release.
|
|
8
|
+
|
|
9
|
+
## Reporting a Vulnerability
|
|
10
|
+
|
|
11
|
+
Please open a private report when GitHub private vulnerability reporting is available. If private reporting is not available, open a minimal public issue without secrets or exploit details and ask for a private follow-up path.
|
|
12
|
+
|
|
13
|
+
Do not include:
|
|
14
|
+
|
|
15
|
+
- API keys, bearer tokens, cookies, or environment values
|
|
16
|
+
- private API responses
|
|
17
|
+
- internal command output
|
|
18
|
+
- customer or personal data
|
|
19
|
+
|
|
20
|
+
Include:
|
|
21
|
+
|
|
22
|
+
- affected command or generated wrapper type
|
|
23
|
+
- Node.js version and operating system
|
|
24
|
+
- minimal config needed to reproduce the issue
|
|
25
|
+
- expected behavior and actual behavior
|
|
26
|
+
|
|
27
|
+
## Wrapper Security Checklist
|
|
28
|
+
|
|
29
|
+
Before using generated wrappers with real systems, review the generated code and config for:
|
|
30
|
+
|
|
31
|
+
- **Command execution:** CLI wrappers use `execFile` with argument arrays. Avoid wrapping shells, package managers, deployment tools, or destructive commands unless you add explicit allowlists.
|
|
32
|
+
- **Argument validation:** keep required parameters explicit and validate values before exposing tools to an assistant.
|
|
33
|
+
- **Secrets:** load credentials from environment variables or a secret manager. Do not hard-code secrets in wrapper configs or generated files.
|
|
34
|
+
- **Permissions:** expose the smallest set of API endpoints or CLI subcommands needed for the task.
|
|
35
|
+
- **Network boundaries:** check base URLs and redirects before connecting wrappers to internal services.
|
|
36
|
+
- **Logging:** avoid logging secrets, request bodies, or private API responses in generated servers.
|
|
37
|
+
|
|
38
|
+
## Maintainer Response
|
|
39
|
+
|
|
40
|
+
For security issues, maintainers should:
|
|
41
|
+
|
|
42
|
+
1. Reproduce with a minimal config.
|
|
43
|
+
2. Add a regression test before or alongside the fix.
|
|
44
|
+
3. Check generated REST and CLI wrapper output for unsafe interpolation.
|
|
45
|
+
4. Run `npm run build`, `npm test`, and `npm audit --omit=dev`.
|
|
46
|
+
5. Document any required user action in the release notes.
|
package/dist/commands/create.js
CHANGED
|
@@ -32,11 +32,11 @@ export const createCommand = new Command("create")
|
|
|
32
32
|
if (options.language === "typescript") {
|
|
33
33
|
console.log(" npm install");
|
|
34
34
|
console.log(" npm run build");
|
|
35
|
-
console.log(
|
|
35
|
+
console.log(" mcptools test --command node --args dist/index.js");
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
38
38
|
console.log(" pip install -r requirements.txt");
|
|
39
|
-
console.log(
|
|
39
|
+
console.log(" mcptools test --command python --args server.py");
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
catch (err) {
|
|
@@ -100,7 +100,7 @@ npm run build
|
|
|
100
100
|
## Test
|
|
101
101
|
|
|
102
102
|
\`\`\`bash
|
|
103
|
-
mcptools test --command
|
|
103
|
+
mcptools test --command node --args dist/index.js
|
|
104
104
|
\`\`\`
|
|
105
105
|
|
|
106
106
|
## Usage
|
|
@@ -236,7 +236,7 @@ pip install -r requirements.txt
|
|
|
236
236
|
## Test
|
|
237
237
|
|
|
238
238
|
\`\`\`bash
|
|
239
|
-
mcptools test --command
|
|
239
|
+
mcptools test --command python --args server.py
|
|
240
240
|
\`\`\`
|
|
241
241
|
`);
|
|
242
242
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,mDAAmD,CAAC;KAChE,QAAQ,CAAC,QAAQ,EAAE,gCAAgC,CAAC;KACpD,MAAM,CAAC,2BAA2B,EAAE,iBAAiB,EAAE,OAAO,CAAC;KAC/D,MAAM,CAAC,uBAAuB,EAAE,gCAAgC,EAAE,YAAY,CAAC;KAC/E,MAAM,CAAC,UAAU,EAAE,yBAAyB,CAAC;KAC7C,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,OAAO,EAAE,EAAE;IACtC,MAAM,OAAO,GAAG,GAAG,CAAC,gCAAgC,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;IAEpE,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;QAC7C,MAAM,KAAK,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7C,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAE1D,IAAI,OAAO,CAAC,QA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0FlB,CACE,CAAC;IAEF,MAAM,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,kBAAkB,CAAC,EAAE,gCAAgC,CAAC,CAAC;IACjF,MAAM,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,EAAE,+BAA+B,CAAC,CAAC;IAE1E,MAAM,SAAS,CACb,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,EACtB,KAAK,IAAI;;;;;;;;;;;;;;;CAeZ,CACE,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY;IACpC,OAAO;;;KAGJ,IAAI;;;;;WAKE,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgGd,CAAC;AACF,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY;IACpC,OAAO;;;KAGJ,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCA4CwB,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmEpC,CAAC;AACF,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAY;IACxC,OAAO;;;KAGJ,IAAI;;;;;;;;;;;;;;;;;;;;;;;;iCAwBwB,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmEpC,CAAC;AACF,CAAC"}
|
package/dist/commands/wrap.js
CHANGED
|
@@ -3,7 +3,7 @@ import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
import ora from "ora";
|
|
6
|
-
import { wrapRestApi
|
|
6
|
+
import { wrapRestApi } from "../core/wrap-rest.js";
|
|
7
7
|
import { wrapCli } from "../core/wrap-cli.js";
|
|
8
8
|
export const wrapCommand = new Command("wrap")
|
|
9
9
|
.description("Convert a REST API or CLI tool into an MCP server")
|
|
@@ -30,19 +30,17 @@ function wrapRestCommand() {
|
|
|
30
30
|
endpoints,
|
|
31
31
|
outputDir: options.output,
|
|
32
32
|
});
|
|
33
|
-
const routerCode = generateToolRouter(endpoints);
|
|
34
|
-
const fullCode = serverCode + "\n" + routerCode;
|
|
35
33
|
const outputDir = options.output;
|
|
36
34
|
await mkdir(outputDir, { recursive: true });
|
|
37
35
|
const outputFile = join(outputDir, `${name}-mcp-server.mjs`);
|
|
38
|
-
await writeFile(outputFile,
|
|
36
|
+
await writeFile(outputFile, serverCode);
|
|
39
37
|
spinner.succeed(chalk.green(`Generated MCP server: ${outputFile}`));
|
|
40
38
|
console.log();
|
|
41
39
|
console.log(chalk.bold("Usage:"));
|
|
42
40
|
console.log(` node ${outputFile}`);
|
|
43
41
|
console.log();
|
|
44
42
|
console.log(chalk.bold("Test:"));
|
|
45
|
-
console.log(` mcptools test --command
|
|
43
|
+
console.log(` mcptools test --command node --args ${outputFile}`);
|
|
46
44
|
}
|
|
47
45
|
catch (err) {
|
|
48
46
|
spinner.fail(chalk.red(`Failed: ${err.message}`));
|
|
@@ -82,7 +80,7 @@ function wrapCliCommand() {
|
|
|
82
80
|
console.log(` node ${outputFile}`);
|
|
83
81
|
console.log();
|
|
84
82
|
console.log(chalk.bold("Test:"));
|
|
85
|
-
console.log(` mcptools test --command
|
|
83
|
+
console.log(` mcptools test --command node --args ${outputFile}`);
|
|
86
84
|
console.log();
|
|
87
85
|
console.log(chalk.bold("Example config format:"));
|
|
88
86
|
console.log(chalk.gray(JSON.stringify({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap.js","sourceRoot":"","sources":["../../src/commands/wrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACp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CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,OAAO,EACP,WAAW,EACX,SAAS,EACT,eAAe,EAChB,MAAM,aAAa,CAAC;AAErB,qBAAa,SAAS;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,OAAO,EACP,WAAW,EACX,SAAS,EACT,eAAe,EAChB,MAAM,aAAa,CAAC;AAErB,qBAAa,SAAS;IAaR,OAAO,CAAC,MAAM;IAZ1B,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,OAAO,CAOX;IACJ,OAAO,CAAC,MAAM,CAAM;gBAEA,MAAM,EAAE,eAAe;IAErC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA2CxB,SAAS,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAM/B,aAAa,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAMvC,WAAW,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAMnC,QAAQ,CACZ,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACjC,OAAO,CAAC,OAAO,CAAC;IAUb,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ3C,SAAS,CACb,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAChC,OAAO,CAAC,OAAO,CAAC;IAQb,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YAOnB,IAAI;IAkClB,OAAO,CAAC,MAAM;IAYd,OAAO,CAAC,aAAa;CAuBtB"}
|
package/dist/core/client.js
CHANGED
|
@@ -23,12 +23,14 @@ export class McpClient {
|
|
|
23
23
|
});
|
|
24
24
|
this.process.on("error", (err) => {
|
|
25
25
|
for (const [, handler] of this.pending) {
|
|
26
|
+
clearTimeout(handler.timeout);
|
|
26
27
|
handler.reject(err);
|
|
27
28
|
}
|
|
28
29
|
this.pending.clear();
|
|
29
30
|
});
|
|
30
31
|
this.process.on("close", () => {
|
|
31
32
|
for (const [, handler] of this.pending) {
|
|
33
|
+
clearTimeout(handler.timeout);
|
|
32
34
|
handler.reject(new Error("MCP server process exited"));
|
|
33
35
|
}
|
|
34
36
|
this.pending.clear();
|
|
@@ -93,21 +95,22 @@ export class McpClient {
|
|
|
93
95
|
params,
|
|
94
96
|
};
|
|
95
97
|
return new Promise((resolve, reject) => {
|
|
96
|
-
|
|
98
|
+
const timeout = setTimeout(() => {
|
|
99
|
+
if (this.pending.has(id)) {
|
|
100
|
+
this.pending.delete(id);
|
|
101
|
+
reject(new Error(`Request ${method} timed out after 30s`));
|
|
102
|
+
}
|
|
103
|
+
}, 30000);
|
|
104
|
+
timeout.unref();
|
|
105
|
+
this.pending.set(id, { resolve, reject, timeout });
|
|
97
106
|
const data = JSON.stringify(request) + "\n";
|
|
98
107
|
this.process?.stdin?.write(data, (err) => {
|
|
99
108
|
if (err) {
|
|
100
109
|
this.pending.delete(id);
|
|
110
|
+
clearTimeout(timeout);
|
|
101
111
|
reject(err);
|
|
102
112
|
}
|
|
103
113
|
});
|
|
104
|
-
// Timeout after 30 seconds
|
|
105
|
-
setTimeout(() => {
|
|
106
|
-
if (this.pending.has(id)) {
|
|
107
|
-
this.pending.delete(id);
|
|
108
|
-
reject(new Error(`Request ${method} timed out after 30s`));
|
|
109
|
-
}
|
|
110
|
-
}, 30000);
|
|
111
114
|
});
|
|
112
115
|
}
|
|
113
116
|
notify(method, params) {
|
|
@@ -131,6 +134,7 @@ export class McpClient {
|
|
|
131
134
|
const handler = this.pending.get(Number(message.id));
|
|
132
135
|
if (handler) {
|
|
133
136
|
this.pending.delete(Number(message.id));
|
|
137
|
+
clearTimeout(handler.timeout);
|
|
134
138
|
handler.resolve(message);
|
|
135
139
|
}
|
|
136
140
|
}
|
package/dist/core/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAU9D,MAAM,OAAO,SAAS;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAU9D,MAAM,OAAO,SAAS;IAaA;IAZZ,OAAO,GAAwB,IAAI,CAAC;IACpC,SAAS,GAAG,CAAC,CAAC;IACd,OAAO,GAAG,IAAI,GAAG,EAOtB,CAAC;IACI,MAAM,GAAG,EAAE,CAAC;IAEpB,YAAoB,MAAuB;QAAvB,WAAM,GAAN,MAAM,CAAiB;IAAG,CAAC;IAE/C,KAAK,CAAC,OAAO;QACX,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;YACvD,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;QACpE,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC;QACpC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,EAAE;YAC9C,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;YAC/B,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE;SAC5C,CAAC,CAAC;QA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,KAAK,SAAS,EAAE,CAAC;oBAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;oBACrD,IAAI,OAAO,EAAE,CAAC;wBACZ,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;wBACxC,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;wBAC9B,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;oBAC3B,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,4BAA4B;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
package/dist/core/wrap-cli.js
CHANGED
|
@@ -128,16 +128,18 @@ function generateCliToolDefinition(sub) {
|
|
|
128
128
|
function generateCliToolHandler(sub, command) {
|
|
129
129
|
const argMapping = sub.args
|
|
130
130
|
.map((arg) => {
|
|
131
|
+
const argName = JSON.stringify(arg.name);
|
|
132
|
+
const flagName = JSON.stringify(`--${arg.name}`);
|
|
131
133
|
if (arg.type === "boolean") {
|
|
132
|
-
return ` if (args
|
|
134
|
+
return ` if (args[${argName}]) cmdArgs.push(${flagName});`;
|
|
133
135
|
}
|
|
134
|
-
return ` if (args
|
|
136
|
+
return ` if (args[${argName}] !== undefined) cmdArgs.push(${flagName}, String(args[${argName}]));`;
|
|
135
137
|
})
|
|
136
138
|
.join("\n");
|
|
137
|
-
return ` case
|
|
138
|
-
const cmdArgs = [
|
|
139
|
+
return ` case ${JSON.stringify(sub.name)}: {
|
|
140
|
+
const cmdArgs = [${JSON.stringify(sub.name)}];
|
|
139
141
|
${argMapping}
|
|
140
|
-
const { stdout, stderr } = await execFileAsync(
|
|
142
|
+
const { stdout, stderr } = await execFileAsync(${JSON.stringify(command)}, cmdArgs);
|
|
141
143
|
return stdout + (stderr ? "\\nSTDERR:\\n" + stderr : "");
|
|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,OAAO,YAAY,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC;yBACpB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC;EAC/C,UAAU;uDAC2C,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;;MAExE,CAAC;AACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap-rest.d.ts","sourceRoot":"","sources":["../../src/core/wrap-rest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAqB,MAAM,aAAa,CAAC;AAEpF,wBAAgB,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"wrap-rest.d.ts","sourceRoot":"","sources":["../../src/core/wrap-rest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAqB,MAAM,aAAa,CAAC;AAEpF,wBAAgB,WAAW,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAoG5D;AAsFD,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,YAAY,EAAE,GAAG,MAAM,CAYpE"}
|
package/dist/core/wrap-rest.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
export function wrapRestApi(options) {
|
|
2
2
|
const { baseUrl, name, endpoints } = options;
|
|
3
3
|
const toolHandlers = endpoints
|
|
4
|
-
.map((ep) => generateToolHandler(ep, baseUrl))
|
|
4
|
+
.map((ep, index) => generateToolHandler(ep, baseUrl, index))
|
|
5
5
|
.join("\n\n");
|
|
6
6
|
const toolDefinitions = endpoints
|
|
7
7
|
.map((ep) => generateToolDefinition(ep))
|
|
8
8
|
.join(",\n ");
|
|
9
|
+
const toolRouter = generateToolRouter(endpoints);
|
|
9
10
|
return `#!/usr/bin/env node
|
|
10
11
|
// Auto-generated MCP server wrapping REST API: ${name}
|
|
11
12
|
// Generated by mcptools
|
|
12
13
|
|
|
13
|
-
import { createServer } from "node:http";
|
|
14
|
-
|
|
15
14
|
const TOOLS = [
|
|
16
15
|
${toolDefinitions}
|
|
17
16
|
];
|
|
@@ -51,6 +50,8 @@ function handleRequest(request) {
|
|
|
51
50
|
|
|
52
51
|
${toolHandlers}
|
|
53
52
|
|
|
53
|
+
${toolRouter}
|
|
54
|
+
|
|
54
55
|
async function handleToolCall(id, toolName, args) {
|
|
55
56
|
try {
|
|
56
57
|
const result = await callTool(toolName, args);
|
|
@@ -116,27 +117,42 @@ function generateToolDefinition(ep) {
|
|
|
116
117
|
},
|
|
117
118
|
}, null, 6);
|
|
118
119
|
}
|
|
119
|
-
function generateToolHandler(ep, baseUrl) {
|
|
120
|
+
function generateToolHandler(ep, baseUrl, index) {
|
|
120
121
|
const pathParams = (ep.parameters ?? []).filter((p) => p.in === "path");
|
|
121
122
|
const queryParams = (ep.parameters ?? []).filter((p) => p.in === "query");
|
|
122
123
|
const bodyParams = (ep.parameters ?? []).filter((p) => p.in === "body");
|
|
123
|
-
|
|
124
|
+
const requiredParams = (ep.parameters ?? []).filter((p) => p.required);
|
|
125
|
+
let urlExpr = `${baseUrl}${ep.path}`;
|
|
124
126
|
for (const p of pathParams) {
|
|
125
|
-
urlExpr = urlExpr.replace(`{${p.name}}`, `\${args
|
|
127
|
+
urlExpr = urlExpr.replace(`{${p.name}}`, `\${encodeURIComponent(String(args[${JSON.stringify(p.name)}]))}`);
|
|
126
128
|
}
|
|
127
129
|
const queryParts = queryParams
|
|
128
|
-
.map((p) =>
|
|
130
|
+
.map((p) => {
|
|
131
|
+
const name = JSON.stringify(p.name);
|
|
132
|
+
return `args[${name}] !== undefined ? ${name} + "=" + encodeURIComponent(String(args[${name}])) : ""`;
|
|
133
|
+
})
|
|
134
|
+
.join(", ");
|
|
135
|
+
const requiredChecks = requiredParams
|
|
136
|
+
.map((p) => {
|
|
137
|
+
const name = JSON.stringify(p.name);
|
|
138
|
+
return ` if (args[${name}] === undefined) throw new Error("Missing required parameter: ${p.name}");`;
|
|
139
|
+
})
|
|
140
|
+
.join("\n");
|
|
141
|
+
const bodyEntries = bodyParams
|
|
142
|
+
.map((p) => `${JSON.stringify(p.name)}: args[${JSON.stringify(p.name)}]`)
|
|
129
143
|
.join(", ");
|
|
130
144
|
const hasQuery = queryParams.length > 0;
|
|
131
145
|
const hasBody = bodyParams.length > 0 && ep.method !== "GET";
|
|
132
|
-
|
|
133
|
-
|
|
146
|
+
const handlerName = getRestHandlerName(ep, index);
|
|
147
|
+
return `async function ${handlerName}(args) {
|
|
148
|
+
${requiredChecks}
|
|
149
|
+
let url = \`${urlExpr}\`;
|
|
134
150
|
${hasQuery ? `const query = [${queryParts}].filter(Boolean).join("&");
|
|
135
151
|
if (query) url += "?" + query;` : ""}
|
|
136
152
|
const response = await fetch(url, {
|
|
137
153
|
method: "${ep.method}",
|
|
138
154
|
headers: { "Content-Type": "application/json" },
|
|
139
|
-
${hasBody ? `body: JSON.stringify({ ${
|
|
155
|
+
${hasBody ? `body: JSON.stringify({ ${bodyEntries} }),` : ""}
|
|
140
156
|
});
|
|
141
157
|
if (!response.ok) throw new Error(\`HTTP \${response.status}: \${await response.text()}\`);
|
|
142
158
|
return response.json();
|
|
@@ -144,7 +160,7 @@ function generateToolHandler(ep, baseUrl) {
|
|
|
144
160
|
}
|
|
145
161
|
export function generateToolRouter(endpoints) {
|
|
146
162
|
const cases = endpoints
|
|
147
|
-
.map((ep) => ` case
|
|
163
|
+
.map((ep, index) => ` case ${JSON.stringify(ep.name)}: return ${getRestHandlerName(ep, index)}(args);`)
|
|
148
164
|
.join("\n");
|
|
149
165
|
return `async function callTool(name, args) {
|
|
150
166
|
switch (name) {
|
|
@@ -154,4 +170,8 @@ ${cases}
|
|
|
154
170
|
}
|
|
155
171
|
}`;
|
|
156
172
|
}
|
|
173
|
+
function getRestHandlerName(ep, index) {
|
|
174
|
+
const safeName = ep.name.replace(/[^A-Za-z0-9_$]/g, "_").replace(/^[^A-Za-z_$]/, "_");
|
|
175
|
+
return `call_${index}_${safeName}`;
|
|
176
|
+
}
|
|
157
177
|
//# sourceMappingURL=wrap-rest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap-rest.js","sourceRoot":"","sources":["../../src/core/wrap-rest.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,WAAW,CAAC,OAAwB;IAClD,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAE7C,MAAM,YAAY,GAAG,SAAS;SAC3B,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,mBAAmB,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"wrap-rest.js","sourceRoot":"","sources":["../../src/core/wrap-rest.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,WAAW,CAAC,OAAwB;IAClD,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAE7C,MAAM,YAAY,GAAG,SAAS;SAC3B,GAAG,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,mBAAmB,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;SAC3D,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhB,MAAM,eAAe,GAAG,SAAS;SAC9B,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC;SACvC,IAAI,CAAC,SAAS,CAAC,CAAC;IAEnB,MAAM,UAAU,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAEjD,OAAO;kDACyC,IAAI;;;;MAIhD,eAAe;;;;;;;;;;;;;;iCAcY,IAAI;;;;;;;;;;;;;;;;;;;;;;EAsBnC,YAAY;;EAEZ,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CX,CAAC;AACF,CAAC;AAED,SAAS,sBAAsB,CAAC,EAAgB;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|
9
|
+
npm install
|
|
10
|
+
npm run check
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Do not publish with unrelated local changes.
|
|
14
|
+
|
|
15
|
+
## 2. Validate Generated Wrappers
|
|
16
|
+
|
|
17
|
+
For REST wrappers:
|
|
18
|
+
|
|
19
|
+
- required path, query, and body parameters are checked before calling the endpoint
|
|
20
|
+
- path and query parameters are URL encoded
|
|
21
|
+
- body fields are read from `args`
|
|
22
|
+
- generated handler names are valid JavaScript identifiers
|
|
23
|
+
|
|
24
|
+
For CLI wrappers:
|
|
25
|
+
|
|
26
|
+
- commands run through `execFile`, not a shell
|
|
27
|
+
- subcommands and flags are generated as quoted string literals
|
|
28
|
+
- arguments are read with bracket notation, so hyphenated names are safe
|
|
29
|
+
|
|
30
|
+
## 3. Review User-Facing Docs
|
|
31
|
+
|
|
32
|
+
- README install commands match `package.json`
|
|
33
|
+
- examples still work with the generated output
|
|
34
|
+
- security guidance links to `SECURITY.md`
|
|
35
|
+
- roadmap reflects shipped work and near-term priorities
|
|
36
|
+
|
|
37
|
+
## 4. Prepare Release Notes
|
|
38
|
+
|
|
39
|
+
Release notes should include:
|
|
40
|
+
|
|
41
|
+
- fixed bugs
|
|
42
|
+
- new commands or templates
|
|
43
|
+
- security hardening
|
|
44
|
+
- breaking changes
|
|
45
|
+
- migration steps, if any
|
|
46
|
+
|
|
47
|
+
## 5. Publish
|
|
48
|
+
|
|
49
|
+
Only publish after the checks above pass and the release commit is reviewed.
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm publish --access public
|
|
53
|
+
```
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "docker-cli",
|
|
3
|
+
"command": "docker",
|
|
4
|
+
"description": "Docker container management as an MCP server",
|
|
5
|
+
"subcommands": [
|
|
6
|
+
{
|
|
7
|
+
"name": "ps",
|
|
8
|
+
"description": "List running containers",
|
|
9
|
+
"args": [
|
|
10
|
+
{
|
|
11
|
+
"name": "--all",
|
|
12
|
+
"type": "boolean",
|
|
13
|
+
"description": "Show all containers (default shows just running)",
|
|
14
|
+
"required": false
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "--format",
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "Format output using a Go template or 'json' for JSON output",
|
|
20
|
+
"required": false
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "--filter",
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "Filter output based on conditions (e.g., status=running, name=my-container)",
|
|
26
|
+
"required": false
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "images",
|
|
32
|
+
"description": "List locally available Docker images",
|
|
33
|
+
"args": [
|
|
34
|
+
{
|
|
35
|
+
"name": "--all",
|
|
36
|
+
"type": "boolean",
|
|
37
|
+
"description": "Show all images (default hides intermediate images)",
|
|
38
|
+
"required": false
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "--format",
|
|
42
|
+
"type": "string",
|
|
43
|
+
"description": "Format output using a Go template or 'json' for JSON output",
|
|
44
|
+
"required": false
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "--filter",
|
|
48
|
+
"type": "string",
|
|
49
|
+
"description": "Filter output based on conditions (e.g., dangling=true, reference=alpine)",
|
|
50
|
+
"required": false
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "logs",
|
|
56
|
+
"description": "Fetch the logs of a container",
|
|
57
|
+
"args": [
|
|
58
|
+
{
|
|
59
|
+
"name": "container",
|
|
60
|
+
"type": "string",
|
|
61
|
+
"description": "Container name or ID to fetch logs from",
|
|
62
|
+
"required": true
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "--tail",
|
|
66
|
+
"type": "string",
|
|
67
|
+
"description": "Number of lines to show from the end of the logs (e.g., 100)",
|
|
68
|
+
"required": false
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "--since",
|
|
72
|
+
"type": "string",
|
|
73
|
+
"description": "Show logs since timestamp or relative time (e.g., 2024-01-01, 1h)",
|
|
74
|
+
"required": false
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"name": "--timestamps",
|
|
78
|
+
"type": "boolean",
|
|
79
|
+
"description": "Show timestamps with each log line",
|
|
80
|
+
"required": false
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "github-api",
|
|
3
|
+
"baseUrl": "https://api.github.com",
|
|
4
|
+
"headers": {
|
|
5
|
+
"Accept": "application/vnd.github.v3+json",
|
|
6
|
+
"User-Agent": "mcptools-github-wrapper"
|
|
7
|
+
},
|
|
8
|
+
"endpoints": [
|
|
9
|
+
{
|
|
10
|
+
"method": "GET",
|
|
11
|
+
"path": "/repos/{owner}/{repo}",
|
|
12
|
+
"name": "get_repo",
|
|
13
|
+
"description": "Get detailed information about a GitHub repository",
|
|
14
|
+
"parameters": [
|
|
15
|
+
{
|
|
16
|
+
"name": "owner",
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Repository owner (user or organization)",
|
|
19
|
+
"required": true,
|
|
20
|
+
"in": "path"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "repo",
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "Repository name",
|
|
26
|
+
"required": true,
|
|
27
|
+
"in": "path"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"method": "GET",
|
|
33
|
+
"path": "/repos/{owner}/{repo}/issues",
|
|
34
|
+
"name": "list_issues",
|
|
35
|
+
"description": "List issues for a GitHub repository",
|
|
36
|
+
"parameters": [
|
|
37
|
+
{
|
|
38
|
+
"name": "owner",
|
|
39
|
+
"type": "string",
|
|
40
|
+
"description": "Repository owner (user or organization)",
|
|
41
|
+
"required": true,
|
|
42
|
+
"in": "path"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "repo",
|
|
46
|
+
"type": "string",
|
|
47
|
+
"description": "Repository name",
|
|
48
|
+
"required": true,
|
|
49
|
+
"in": "path"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "state",
|
|
53
|
+
"type": "string",
|
|
54
|
+
"description": "Filter by state: open, closed, or all",
|
|
55
|
+
"required": false,
|
|
56
|
+
"in": "query"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "labels",
|
|
60
|
+
"type": "string",
|
|
61
|
+
"description": "Comma-separated list of label names to filter by",
|
|
62
|
+
"required": false,
|
|
63
|
+
"in": "query"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "per_page",
|
|
67
|
+
"type": "number",
|
|
68
|
+
"description": "Number of results per page (max 100)",
|
|
69
|
+
"required": false,
|
|
70
|
+
"in": "query"
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"method": "GET",
|
|
76
|
+
"path": "/repos/{owner}/{repo}/pulls",
|
|
77
|
+
"name": "list_pulls",
|
|
78
|
+
"description": "List pull requests for a GitHub repository",
|
|
79
|
+
"parameters": [
|
|
80
|
+
{
|
|
81
|
+
"name": "owner",
|
|
82
|
+
"type": "string",
|
|
83
|
+
"description": "Repository owner (user or organization)",
|
|
84
|
+
"required": true,
|
|
85
|
+
"in": "path"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"name": "repo",
|
|
89
|
+
"type": "string",
|
|
90
|
+
"description": "Repository name",
|
|
91
|
+
"required": true,
|
|
92
|
+
"in": "path"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "state",
|
|
96
|
+
"type": "string",
|
|
97
|
+
"description": "Filter by state: open, closed, or all",
|
|
98
|
+
"required": false,
|
|
99
|
+
"in": "query"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"name": "sort",
|
|
103
|
+
"type": "string",
|
|
104
|
+
"description": "Sort by: created, updated, popularity, long-running",
|
|
105
|
+
"required": false,
|
|
106
|
+
"in": "query"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"name": "direction",
|
|
110
|
+
"type": "string",
|
|
111
|
+
"description": "Sort direction: asc or desc",
|
|
112
|
+
"required": false,
|
|
113
|
+
"in": "query"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"name": "per_page",
|
|
117
|
+
"type": "number",
|
|
118
|
+
"description": "Number of results per page (max 100)",
|
|
119
|
+
"required": false,
|
|
120
|
+
"in": "query"
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "weather-api",
|
|
3
|
+
"baseUrl": "https://api.weatherapi.com/v1",
|
|
4
|
+
"headers": {
|
|
5
|
+
"Accept": "application/json"
|
|
6
|
+
},
|
|
7
|
+
"endpoints": [
|
|
8
|
+
{
|
|
9
|
+
"method": "GET",
|
|
10
|
+
"path": "/current.json",
|
|
11
|
+
"name": "get_current",
|
|
12
|
+
"description": "Get current weather conditions for a location",
|
|
13
|
+
"parameters": [
|
|
14
|
+
{
|
|
15
|
+
"name": "key",
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "API key for authentication",
|
|
18
|
+
"required": true,
|
|
19
|
+
"in": "query"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "q",
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "Location query: city name, zip code, IP address, or lat,lon coordinates",
|
|
25
|
+
"required": true,
|
|
26
|
+
"in": "query"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "aqi",
|
|
30
|
+
"type": "string",
|
|
31
|
+
"description": "Include air quality data: yes or no",
|
|
32
|
+
"required": false,
|
|
33
|
+
"in": "query"
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"method": "GET",
|
|
39
|
+
"path": "/forecast.json",
|
|
40
|
+
"name": "get_forecast",
|
|
41
|
+
"description": "Get weather forecast for a location for up to 14 days",
|
|
42
|
+
"parameters": [
|
|
43
|
+
{
|
|
44
|
+
"name": "key",
|
|
45
|
+
"type": "string",
|
|
46
|
+
"description": "API key for authentication",
|
|
47
|
+
"required": true,
|
|
48
|
+
"in": "query"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "q",
|
|
52
|
+
"type": "string",
|
|
53
|
+
"description": "Location query: city name, zip code, IP address, or lat,lon coordinates",
|
|
54
|
+
"required": true,
|
|
55
|
+
"in": "query"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "days",
|
|
59
|
+
"type": "number",
|
|
60
|
+
"description": "Number of days of forecast (1-14)",
|
|
61
|
+
"required": true,
|
|
62
|
+
"in": "query"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "aqi",
|
|
66
|
+
"type": "string",
|
|
67
|
+
"description": "Include air quality data: yes or no",
|
|
68
|
+
"required": false,
|
|
69
|
+
"in": "query"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"name": "alerts",
|
|
73
|
+
"type": "string",
|
|
74
|
+
"description": "Include weather alerts: yes or no",
|
|
75
|
+
"required": false,
|
|
76
|
+
"in": "query"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@titikaka2026/mcptools",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "The Swiss Army knife for MCP (Model Context Protocol) — create, test, inspect, and wrap MCP servers with ease.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -31,16 +31,20 @@
|
|
|
31
31
|
"types": "./dist/index.d.ts",
|
|
32
32
|
"files": [
|
|
33
33
|
"dist",
|
|
34
|
-
"
|
|
34
|
+
"docs",
|
|
35
|
+
"examples",
|
|
36
|
+
"CHANGELOG.md",
|
|
37
|
+
"SECURITY.md"
|
|
35
38
|
],
|
|
36
39
|
"scripts": {
|
|
37
40
|
"build": "tsc",
|
|
41
|
+
"check": "npm run build && npm test && npm run audit:runtime",
|
|
38
42
|
"dev": "tsc --watch",
|
|
39
43
|
"start": "node dist/cli.js",
|
|
40
44
|
"test": "vitest run",
|
|
41
45
|
"test:watch": "vitest",
|
|
42
|
-
"
|
|
43
|
-
"prepublishOnly": "npm run
|
|
46
|
+
"audit:runtime": "npm audit --omit=dev",
|
|
47
|
+
"prepublishOnly": "npm run check"
|
|
44
48
|
},
|
|
45
49
|
"dependencies": {
|
|
46
50
|
"chalk": "^5.3.0",
|
|
@@ -54,7 +58,7 @@
|
|
|
54
58
|
"@types/node": "^22.0.0",
|
|
55
59
|
"@types/ws": "^8.5.12",
|
|
56
60
|
"typescript": "^5.6.0",
|
|
57
|
-
"vitest": "^
|
|
61
|
+
"vitest": "^4.1.8"
|
|
58
62
|
},
|
|
59
63
|
"engines": {
|
|
60
64
|
"node": ">=18.0.0"
|