specrun 1.0.0
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/LICENSE.md +21 -0
- package/README.md +319 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +123 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts.d.ts +38 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +537 -0
- package/dist/prompts.js.map +1 -0
- package/dist/server.d.ts +38 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +305 -0
- package/dist/server.js.map +1 -0
- package/dist/tools.d.ts +43 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +249 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +60 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/auth.d.ts +6 -0
- package/dist/utils/auth.d.ts.map +1 -0
- package/dist/utils/auth.js +173 -0
- package/dist/utils/auth.js.map +1 -0
- package/dist/utils/http-client.d.ts +17 -0
- package/dist/utils/http-client.d.ts.map +1 -0
- package/dist/utils/http-client.js +233 -0
- package/dist/utils/http-client.js.map +1 -0
- package/dist/utils/openapi-parser.d.ts +6 -0
- package/dist/utils/openapi-parser.d.ts.map +1 -0
- package/dist/utils/openapi-parser.js +398 -0
- package/dist/utils/openapi-parser.js.map +1 -0
- package/package.json +62 -0
- package/specs/.env +20 -0
- package/specs/cars.swagger.json +105 -0
- package/specs/github.yaml +164 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pavlo Piga
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
<h1 >
|
|
2
|
+
SpecRun
|
|
3
|
+
</h1>
|
|
4
|
+
An MCP server that turns OpenAPI specifications into MCP tools. Scans a folder for OpenAPI spec files and automatically generate corresponding tools. These tools can then be used in any MCP client to interact with the APIs defined by the specs, with built-in support for authentication and server URL management via a simple `.env` file.
|
|
5
|
+
|
|
6
|
+
Built with [FastMCP](https://www.npmjs.com/package/fastmcp) for TypeScript.
|
|
7
|
+
|
|
8
|
+
## ✨ Features
|
|
9
|
+
|
|
10
|
+
- **Zero Configuration**: Filesystem is the interface - just drop OpenAPI specs in a folder
|
|
11
|
+
- **Supports OpenAPI 3.0 and 2.0**: Works with both OpenAPI 3.x and Swagger 2.0 specs
|
|
12
|
+
- **Namespace Isolation**: Multiple APIs coexist cleanly
|
|
13
|
+
- **Full OpenAPI Support**: Handles parameters, request bodies, authentication, and responses
|
|
14
|
+
- **Run Any Tool to Interact with APIs**: For example, `cars_addCar` to call `POST /cars` from `cars.json` spec to create a new car, or `github_get_user_repos` to call `GET /user/repos` from `github.yaml` spec to list repos.
|
|
15
|
+
- **Run Any Tool with Custom Inputs**: Pass structured JSON inputs for parameters and request bodies
|
|
16
|
+
- **Run Any Tool to see Spec Details**: Get the original OpenAPI spec details for any tool, including parameters, request body schema, and response schema
|
|
17
|
+
- **Run Any Tool to get API responses as resources**: Each tool call returns a JSON resource containing request URL, request body, and response
|
|
18
|
+
- **Run Any Tool in Batch**: One `specrun_batch` tool can execute any tool with multiple inputs and returns a consolidated JSON resource
|
|
19
|
+
- **Auto Authentication**: Simple `.env` file with `{API_NAME}_API_KEY` pattern
|
|
20
|
+
- **Auto .env Placeholders**: Adds `{API_NAME}_SERVER_URL` and `{API_NAME}_BEARER_TOKEN` entries when missing
|
|
21
|
+
- **Multiple Transports**: Support for stdio and HTTP streaming
|
|
22
|
+
- **Built-in Debugging**: List command to see loaded specs and tools
|
|
23
|
+
- **MCP Prompts**: Built-in prompts for listing tools, generating inputs, and explaining schemas
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
### Requirements
|
|
28
|
+
|
|
29
|
+
- Node.js 22 or newer
|
|
30
|
+
|
|
31
|
+
### 1️⃣ Install (optional)
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npm install -g specrun
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 2️⃣ Create a specs folder where the server can read OpenAPI spec files. For example:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
mkdir ~/specs
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 3️⃣ Add OpenAPI specs
|
|
44
|
+
|
|
45
|
+
Drop any `.json`, `.yaml`, or `.yml` OpenAPI specification files into your specs folder
|
|
46
|
+
|
|
47
|
+
### 4️⃣ Configure authentication (optional)
|
|
48
|
+
|
|
49
|
+
Create a `.env` file in your specs folder:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# ~/specs/.env
|
|
53
|
+
CARS_API_KEY=your_api_key_here
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
SpecRun will also ensure `{API_NAME}_SERVER_URL` and `{API_NAME}_BEARER_TOKEN` entries exist for each spec, adding empty placeholders when missing.
|
|
57
|
+
When `{API_NAME}_SERVER_URL` has a value, SpecRun updates the spec file on load:
|
|
58
|
+
|
|
59
|
+
- OpenAPI 3.0: updates the first `servers` entry.
|
|
60
|
+
- OpenAPI 2.0 (formerly Swagger 2.0): updates `host`, `schemes`, and `basePath` (no `servers` section in OpenAPI 2.0).
|
|
61
|
+
|
|
62
|
+
SpecRun also watches the `.env` file and refreshes server URLs and auth config automatically after changes.
|
|
63
|
+
|
|
64
|
+
### 5️⃣ Add to MCP client configuration
|
|
65
|
+
|
|
66
|
+
For Claude Desktop or Cursor, add to your MCP configuration:
|
|
67
|
+
|
|
68
|
+
If installed on your machine:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"mcpServers": {
|
|
73
|
+
"specrun": {
|
|
74
|
+
"command": "specrun",
|
|
75
|
+
"args": ["--specs", "/path/to/your/specs/folder"]
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Otherwise:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"mcpServers": {
|
|
86
|
+
"specrun": {
|
|
87
|
+
"command": "npx",
|
|
88
|
+
"args": ["-y", "specrun", "--specs", "/absolute/path/to/your/specs"]
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 💻 CLI Usage
|
|
95
|
+
|
|
96
|
+
### 🚀 Start the server
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Default: stdio transport, current directory
|
|
100
|
+
specrun
|
|
101
|
+
|
|
102
|
+
# Custom specs folder
|
|
103
|
+
specrun --specs ~/specs
|
|
104
|
+
|
|
105
|
+
# HTTP transport mode
|
|
106
|
+
specrun --transport httpStream --port 8080
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 📋 List loaded specs and tools
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# List all loaded specifications and their tools
|
|
113
|
+
specrun list
|
|
114
|
+
|
|
115
|
+
# List specs from custom folder
|
|
116
|
+
specrun list --specs ~/specs
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## 🔑 Authentication Patterns
|
|
121
|
+
|
|
122
|
+
The server automatically detects authentication from environment variables using these patterns:
|
|
123
|
+
|
|
124
|
+
| Pattern | Auth Type | Usage |
|
|
125
|
+
| --------------------------------------------- | --------------- | ------------------------------- |
|
|
126
|
+
| `{API_NAME}_API_KEY` | 🗝️ API Key | `X-API-Key` header |
|
|
127
|
+
| `{API_NAME}_TOKEN` | 🎫 Bearer Token | `Authorization: Bearer {token}` |
|
|
128
|
+
| `{API_NAME}_BEARER_TOKEN` | 🎫 Bearer Token | `Authorization: Bearer {token}` |
|
|
129
|
+
| `{API_NAME}_USERNAME` + `{API_NAME}_PASSWORD` | 👤 Basic Auth | `Authorization: Basic {base64}` |
|
|
130
|
+
|
|
131
|
+
SpecRun also creates `.env` placeholders for:
|
|
132
|
+
|
|
133
|
+
| Pattern | Purpose |
|
|
134
|
+
| ------------------------- | ---------------------------- |
|
|
135
|
+
| `{API_NAME}_SERVER_URL` | Base URL for the API |
|
|
136
|
+
| `{API_NAME}_BEARER_TOKEN` | Token placeholder if missing |
|
|
137
|
+
|
|
138
|
+
If `{API_NAME}_SERVER_URL` is set, SpecRun writes that value into the spec before generating tools:
|
|
139
|
+
|
|
140
|
+
- OpenAPI 3.0: writes the first `servers` entry.
|
|
141
|
+
- OpenAPI 2.0 (formerly Swagger 2.0): writes `host`, `schemes`, and `basePath`.
|
|
142
|
+
|
|
143
|
+
Updates to `.env` are applied automatically without restarting the MCP server.
|
|
144
|
+
|
|
145
|
+
The `{API_NAME}` is derived from the filename of your OpenAPI spec:
|
|
146
|
+
|
|
147
|
+
- `cars.json` → `CARS_API_KEY`
|
|
148
|
+
- `github-api.yaml` → `GITHUB_TOKEN`
|
|
149
|
+
- `my_custom_api.yml` → `MY_CUSTOM_API_KEY`
|
|
150
|
+
|
|
151
|
+
## 🏷️ Tool Naming
|
|
152
|
+
|
|
153
|
+
Tools are automatically named using this pattern:
|
|
154
|
+
|
|
155
|
+
- **With operationId**: `{api_name}_{operationId}`
|
|
156
|
+
- **Without operationId**: `{api_name}_{method}_{path_segments}`
|
|
157
|
+
|
|
158
|
+
Specs:
|
|
159
|
+
|
|
160
|
+
- `cars_getCarById` (from operationId)
|
|
161
|
+
- `github_get_user_repos` (generated from `GET /user/repos`)
|
|
162
|
+
|
|
163
|
+
Use the shared batch tool to run any tool with an array of inputs:
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"toolName": "cars_getCarById",
|
|
168
|
+
"items": [{ "id": "123" }, { "id": "456" }],
|
|
169
|
+
"failFast": false
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Batch responses return a consolidated JSON resource with per-item outputs.
|
|
174
|
+
|
|
175
|
+
For batches over 200 items, SpecRun requires explicit confirmation. This is to prevent accidental large runs that could cause performance issues or unintended consequences. The server will return a message asking for confirmation, and you can retry with `confirmLargeBatch: true` and the provided `confirmLargeBatchToken` to proceed.
|
|
176
|
+
|
|
177
|
+
## 📦 Resource Outputs
|
|
178
|
+
|
|
179
|
+
Tool responses are returned as MCP resources with `application/json` content. Each resource includes:
|
|
180
|
+
|
|
181
|
+
1. Request URL
|
|
182
|
+
2. Request body
|
|
183
|
+
3. Response status and body
|
|
184
|
+
|
|
185
|
+
Example resource payload:
|
|
186
|
+
|
|
187
|
+
```json
|
|
188
|
+
{
|
|
189
|
+
"requestUrl": "https://api.example.com/v1/users/123",
|
|
190
|
+
"requestBody": null,
|
|
191
|
+
"response": {
|
|
192
|
+
"status": 200,
|
|
193
|
+
"body": {
|
|
194
|
+
"id": "123",
|
|
195
|
+
"name": "Jane Doe"
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Batch runs return a single consolidated resource containing all item results.
|
|
202
|
+
|
|
203
|
+
## 📁 File Structure
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
your-project/
|
|
207
|
+
── specs/ # Your OpenAPI specs folder
|
|
208
|
+
├── .env # Authentication credentials
|
|
209
|
+
└── custom-api.yml # Your OpenAPI spec files
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## 🧭 MCP Prompts
|
|
213
|
+
|
|
214
|
+
SpecRun exposes MCP prompts for common workflows:
|
|
215
|
+
|
|
216
|
+
- `list_apis`: List loaded APIs/tools and ask the user to choose an endpoint
|
|
217
|
+
- `generate_api_call`: Generate a ready-to-run JSON input payload for a tool
|
|
218
|
+
- `explain_api_schema`: Explain parameters and request body schema with examples
|
|
219
|
+
|
|
220
|
+
## 📄 Example OpenAPI Spec
|
|
221
|
+
|
|
222
|
+
Here's a minimal example that creates two tools:
|
|
223
|
+
|
|
224
|
+
```yaml
|
|
225
|
+
# ~/specs/example.yaml
|
|
226
|
+
openapi: 3.0.0
|
|
227
|
+
info:
|
|
228
|
+
title: Example API
|
|
229
|
+
version: 1.0.0
|
|
230
|
+
servers:
|
|
231
|
+
- url: https://api-server.placeholder
|
|
232
|
+
paths:
|
|
233
|
+
/users/{id}:
|
|
234
|
+
get:
|
|
235
|
+
operationId: getUser
|
|
236
|
+
summary: Get user by ID
|
|
237
|
+
parameters:
|
|
238
|
+
- name: id
|
|
239
|
+
in: path
|
|
240
|
+
required: true
|
|
241
|
+
schema:
|
|
242
|
+
type: string
|
|
243
|
+
responses:
|
|
244
|
+
"200":
|
|
245
|
+
description: User found
|
|
246
|
+
/users:
|
|
247
|
+
post:
|
|
248
|
+
operationId: createUser
|
|
249
|
+
summary: Create a new user
|
|
250
|
+
requestBody:
|
|
251
|
+
required: true
|
|
252
|
+
content:
|
|
253
|
+
application/json:
|
|
254
|
+
schema:
|
|
255
|
+
type: object
|
|
256
|
+
properties:
|
|
257
|
+
name:
|
|
258
|
+
type: string
|
|
259
|
+
email:
|
|
260
|
+
type: string
|
|
261
|
+
responses:
|
|
262
|
+
"201":
|
|
263
|
+
description: User created
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
This creates tools named:
|
|
267
|
+
|
|
268
|
+
- `example_getUser`
|
|
269
|
+
- `example_createUser`
|
|
270
|
+
|
|
271
|
+
## 🔧 Troubleshooting
|
|
272
|
+
|
|
273
|
+
### ❌ No tools appearing?
|
|
274
|
+
|
|
275
|
+
1. Check that your OpenAPI specs are valid:
|
|
276
|
+
|
|
277
|
+
```bash
|
|
278
|
+
specrun list --specs /path/to/specs
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
2. Ensure files have correct extensions (`.json`, `.yaml`, `.yml`)
|
|
282
|
+
|
|
283
|
+
3. Check the server logs for parsing errors
|
|
284
|
+
|
|
285
|
+
> **⚠️ Note:** SpecRun works best when you use absolute paths (with no spaces) for the `--specs` argument and other file paths. Relative paths or paths containing spaces may cause issues on some platforms or with some MCP clients.
|
|
286
|
+
|
|
287
|
+
### 🔐 Authentication not working?
|
|
288
|
+
|
|
289
|
+
1. Verify your `.env` file is in the specs directory
|
|
290
|
+
2. Check the naming pattern matches your spec filename
|
|
291
|
+
3. Use the list command to verify auth configuration:
|
|
292
|
+
```bash
|
|
293
|
+
specrun list
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### 🔄 Tools not updating after spec changes?
|
|
297
|
+
|
|
298
|
+
1. Restart the MCP server to reload the specs
|
|
299
|
+
2. Check file permissions
|
|
300
|
+
3. Restart the MCP client if needed
|
|
301
|
+
|
|
302
|
+
## 🛠️ Development
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
# Clone and install
|
|
306
|
+
git clone git@github.com:Pavel-Piha/specrun.git
|
|
307
|
+
cd specrun
|
|
308
|
+
npm install
|
|
309
|
+
|
|
310
|
+
# Build
|
|
311
|
+
npm run build
|
|
312
|
+
|
|
313
|
+
# Test locally
|
|
314
|
+
npm run dev -- --specs ./specs
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
## 🤝 Contributing
|
|
318
|
+
|
|
319
|
+
Contributions are welcome! Please feel free to submit issues and pull requests.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const server_1 = require("./server");
|
|
10
|
+
const program = new commander_1.Command();
|
|
11
|
+
program
|
|
12
|
+
.name("specrun")
|
|
13
|
+
.description("Converts OpenAPI specifications to MCP tools - automatically generates tools from OpenAPI specs")
|
|
14
|
+
.version("1.0.0")
|
|
15
|
+
.option("--specs <path>", "Path to directory containing OpenAPI spec files", process.cwd())
|
|
16
|
+
.option("--port <number>", "Port number for HTTP transport (enables HTTP mode)", (val) => parseInt(val, 10))
|
|
17
|
+
.option("--transport <type>", "Transport type: stdio or httpStream", "stdio")
|
|
18
|
+
.action(async (options) => {
|
|
19
|
+
try {
|
|
20
|
+
// Debug: log raw options without breaking JSON protocol
|
|
21
|
+
const globalOptions = program.opts();
|
|
22
|
+
const specsPath = path_1.default.resolve(options.specs || globalOptions.specs || process.cwd());
|
|
23
|
+
const config = {
|
|
24
|
+
specsPath,
|
|
25
|
+
port: options.port,
|
|
26
|
+
transportType: options.transport,
|
|
27
|
+
};
|
|
28
|
+
// Validate transport configuration
|
|
29
|
+
if (config.transportType === "httpStream" && !config.port) {
|
|
30
|
+
console.error("Error: --port is required when using httpStream transport");
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
const server = new server_1.OpenApiMcpServer(config);
|
|
34
|
+
// Handle graceful shutdown
|
|
35
|
+
const shutdown = async () => {
|
|
36
|
+
console.log("\nShutting down...");
|
|
37
|
+
await server.stop();
|
|
38
|
+
process.exit(0);
|
|
39
|
+
};
|
|
40
|
+
process.on("SIGINT", shutdown);
|
|
41
|
+
process.on("SIGTERM", shutdown);
|
|
42
|
+
// Start the server
|
|
43
|
+
await server.start();
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
console.error("Failed to start server:", error);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
// Add a command to list loaded specs (useful for debugging)
|
|
51
|
+
program
|
|
52
|
+
.command("list")
|
|
53
|
+
.description("List all loaded OpenAPI specifications and their tools")
|
|
54
|
+
.option("--specs <path>", "Path to directory containing OpenAPI spec files")
|
|
55
|
+
.action(async (options) => {
|
|
56
|
+
try {
|
|
57
|
+
// Debug: log raw options without breaking JSON protocol
|
|
58
|
+
const globalOptions = program.opts();
|
|
59
|
+
const specsPath = path_1.default.resolve(globalOptions.specs || options.specs || process.cwd());
|
|
60
|
+
const config = {
|
|
61
|
+
specsPath,
|
|
62
|
+
};
|
|
63
|
+
const server = new server_1.OpenApiMcpServer(config);
|
|
64
|
+
await server.loadSpecs();
|
|
65
|
+
const specs = server.getLoadedSpecs();
|
|
66
|
+
const authConfig = server.getAuthConfig();
|
|
67
|
+
console.log("\n=== SpecRun Status ===\n");
|
|
68
|
+
console.log(`Specs Directory: ${config.specsPath}`);
|
|
69
|
+
console.log(`Loaded Specifications: ${specs.length}`);
|
|
70
|
+
if (specs.length === 0) {
|
|
71
|
+
console.log("\nNo OpenAPI specifications found.");
|
|
72
|
+
console.log("Add .json, .yaml, or .yml files to the specs directory.");
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
for (const spec of specs) {
|
|
76
|
+
console.log(`\n📋 ${spec.apiName.toUpperCase()}`);
|
|
77
|
+
console.log(` File: ${path_1.default.basename(spec.filePath)}`);
|
|
78
|
+
console.log(` Base URL: ${spec.tools[0]?.baseUrl || "N/A"}`);
|
|
79
|
+
console.log(` Tools: ${spec.tools.length}`);
|
|
80
|
+
if (authConfig[spec.apiName]) {
|
|
81
|
+
const auth = authConfig[spec.apiName];
|
|
82
|
+
console.log(` Auth: ${auth.type} ${auth.type === "apiKey" ? `(${auth.headerName})` : ""}`);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
console.log(` Auth: None configured`);
|
|
86
|
+
}
|
|
87
|
+
if (spec.tools.length > 0) {
|
|
88
|
+
console.log(" Available tools:");
|
|
89
|
+
for (const tool of spec.tools.slice(0, 5)) {
|
|
90
|
+
// Show first 5 tools
|
|
91
|
+
console.log(` • ${tool.name} - ${tool.description}`);
|
|
92
|
+
}
|
|
93
|
+
if (spec.tools.length > 5) {
|
|
94
|
+
console.log(` ... and ${spec.tools.length - 5} more`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
console.log("\n=== Global Tools ===\n");
|
|
100
|
+
console.log("• specrun_batch - Run any SpecRun tool in batch");
|
|
101
|
+
console.log("\n=== Authentication Configuration ===\n");
|
|
102
|
+
const authKeys = Object.keys(authConfig);
|
|
103
|
+
if (authKeys.length === 0) {
|
|
104
|
+
console.log("No authentication configured.");
|
|
105
|
+
console.log("Add a .env file with credentials like:");
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
for (const apiName of authKeys) {
|
|
109
|
+
const auth = authConfig[apiName];
|
|
110
|
+
console.log(`🔐 ${apiName.toUpperCase()}: ${auth.type}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
await server.stop();
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
console.error("Failed to list specs:", error);
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
if (require.main === module) {
|
|
121
|
+
program.parse();
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,gDAAwB;AACxB,qCAA4C;AAG5C,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,SAAS,CAAC;KACf,WAAW,CACV,iGAAiG,CAClG;KACA,OAAO,CAAC,OAAO,CAAC;KAChB,MAAM,CACL,gBAAgB,EAChB,iDAAiD,EACjD,OAAO,CAAC,GAAG,EAAE,CACd;KACA,MAAM,CACL,iBAAiB,EACjB,oDAAoD,EACpD,CAAC,GAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAChC;KACA,MAAM,CAAC,oBAAoB,EAAE,qCAAqC,EAAE,OAAO,CAAC;KAC5E,MAAM,CAAC,KAAK,EAAE,OAAY,EAAE,EAAE;IAC7B,IAAI,CAAC;QACH,wDAAwD;QACxD,MAAM,aAAa,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QACrC,MAAM,SAAS,GAAG,cAAI,CAAC,OAAO,CAC5B,OAAO,CAAC,KAAK,IAAI,aAAa,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,EAAE,CACtD,CAAC;QAEF,MAAM,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KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;YAC7C,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;gBAC/B,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;gBACjC,OAAO,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;QAED,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IACtB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,OAAO,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { OpenApiMcpServer } from "./server";
|
|
2
|
+
export * from "./types";
|
|
3
|
+
export { loadAuthConfig, applyAuthentication, getApiNameFromFile, } from "./utils/auth";
|
|
4
|
+
export { parseOpenApiSpec, isOpenAPIFile } from "./utils/openapi-parser";
|
|
5
|
+
export { HttpClient } from "./utils/http-client";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,cAAc,SAAS,CAAC;AACxB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.HttpClient = exports.isOpenAPIFile = exports.parseOpenApiSpec = exports.getApiNameFromFile = exports.applyAuthentication = exports.loadAuthConfig = exports.OpenApiMcpServer = void 0;
|
|
18
|
+
var server_1 = require("./server");
|
|
19
|
+
Object.defineProperty(exports, "OpenApiMcpServer", { enumerable: true, get: function () { return server_1.OpenApiMcpServer; } });
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
var auth_1 = require("./utils/auth");
|
|
22
|
+
Object.defineProperty(exports, "loadAuthConfig", { enumerable: true, get: function () { return auth_1.loadAuthConfig; } });
|
|
23
|
+
Object.defineProperty(exports, "applyAuthentication", { enumerable: true, get: function () { return auth_1.applyAuthentication; } });
|
|
24
|
+
Object.defineProperty(exports, "getApiNameFromFile", { enumerable: true, get: function () { return auth_1.getApiNameFromFile; } });
|
|
25
|
+
var openapi_parser_1 = require("./utils/openapi-parser");
|
|
26
|
+
Object.defineProperty(exports, "parseOpenApiSpec", { enumerable: true, get: function () { return openapi_parser_1.parseOpenApiSpec; } });
|
|
27
|
+
Object.defineProperty(exports, "isOpenAPIFile", { enumerable: true, get: function () { return openapi_parser_1.isOpenAPIFile; } });
|
|
28
|
+
var http_client_1 = require("./utils/http-client");
|
|
29
|
+
Object.defineProperty(exports, "HttpClient", { enumerable: true, get: function () { return http_client_1.HttpClient; } });
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mCAA4C;AAAnC,0GAAA,gBAAgB,OAAA;AACzB,0CAAwB;AACxB,qCAIsB;AAHpB,sGAAA,cAAc,OAAA;AACd,2GAAA,mBAAmB,OAAA;AACnB,0GAAA,kBAAkB,OAAA;AAEpB,yDAAyE;AAAhE,kHAAA,gBAAgB,OAAA;AAAE,+GAAA,aAAa,OAAA;AACxC,mDAAiD;AAAxC,yGAAA,UAAU,OAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { FastMCP } from "fastmcp";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { ParsedSpec, GeneratedTool } from "./types";
|
|
4
|
+
type ToolRegistryEntry = {
|
|
5
|
+
spec: ParsedSpec;
|
|
6
|
+
tool: GeneratedTool;
|
|
7
|
+
schema: z.ZodObject<any>;
|
|
8
|
+
};
|
|
9
|
+
type ToolRegistry = Map<string, ToolRegistryEntry>;
|
|
10
|
+
export declare class PromptRegistrar {
|
|
11
|
+
private fastMCP;
|
|
12
|
+
private toolRegistry;
|
|
13
|
+
constructor(options: {
|
|
14
|
+
fastMCP: FastMCP;
|
|
15
|
+
toolRegistry: ToolRegistry;
|
|
16
|
+
});
|
|
17
|
+
registerPrompts(): void;
|
|
18
|
+
private parseMaxResults;
|
|
19
|
+
private parseFilter;
|
|
20
|
+
private parseCursor;
|
|
21
|
+
private parseListApisArgs;
|
|
22
|
+
private parseToolNameArg;
|
|
23
|
+
private normalizeToolName;
|
|
24
|
+
private encodeCursor;
|
|
25
|
+
private decodeCursor;
|
|
26
|
+
private sanitizePromptText;
|
|
27
|
+
private getToolEntries;
|
|
28
|
+
private buildToolListPromptText;
|
|
29
|
+
private completeToolNames;
|
|
30
|
+
private buildRequiredOptionalSummary;
|
|
31
|
+
private buildExamplePayload;
|
|
32
|
+
private buildSchemaExplanation;
|
|
33
|
+
private describeSchemaType;
|
|
34
|
+
private createExampleValue;
|
|
35
|
+
private getRequestBodySchema;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEpD,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;CAC1B,CAAC;AAEF,KAAK,YAAY,GAAG,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAEnD,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,YAAY,CAAe;gBAEvB,OAAO,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,YAAY,EAAE,YAAY,CAAA;KAAE;IAKrE,eAAe,IAAI,I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