@powerduck/openapi-mcp-server 1.1.0 → 1.3.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/README.md +221 -204
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,278 +1,295 @@
|
|
|
1
1
|
# @powerduck/openapi-mcp-server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@powerduck/openapi-mcp-server)
|
|
4
|
+
[](https://github.com/PowerDuckie/openapi-mcp-server/blob/main/LICENSE)
|
|
5
|
+
[](https://www.npmjs.com/package/@powerduck/openapi-mcp-server)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
Turn any OpenAPI 3.2 document into a fully functional MCP (Model Context Protocol) server. Automatically generates tools, prompts, and resources from your API spec. Supports both stdio and HTTP (SSE) transports.
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
- **Prompts** generated from API metadata and operations
|
|
9
|
-
- **Resources** generated from the OpenAPI catalog
|
|
10
|
-
- **HTTP (SSE)** and **STDIO** MCP transports
|
|
11
|
-
- **Admin Web UI** for managing specs and services
|
|
12
|
-
- **Persistent runtime state** with config storage
|
|
13
|
-
- **Strong validation** and safer request execution
|
|
14
|
-
- **Dual module support**: ESM and CommonJS
|
|
15
|
-
- **TypeScript-first** with full type definitions
|
|
16
|
-
- **91+ tests** covering core utilities, spec loading, and module exports
|
|
9
|
+
---
|
|
17
10
|
|
|
18
|
-
|
|
11
|
+
Powerduck is an open-source developer tooling platform for teams building modern API workflows.
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
- **Auto-Generated Tools** — Every OpenAPI operation becomes an MCP tool with full parameter schemas
|
|
14
|
+
- **Auto-Generated Prompts** — Smart prompt templates for common API workflows
|
|
15
|
+
- **Auto-Generated Resources** — API docs, schemas, and examples accessible as MCP resources
|
|
16
|
+
- **2 Transports** — stdio for local AI clients, HTTP/SSE for remote and cloud deployments
|
|
17
|
+
- **Security Resolution** — Bearer tokens, API keys, Basic auth, OAuth2, and custom schemes
|
|
18
|
+
- **Type-Safe Execution** — Full parameter validation before executing API calls
|
|
19
|
+
- **Error Handling** — Structured MCP errors with API response details
|
|
20
|
+
- **Admin Dashboard** — Built-in web UI for monitoring tools, viewing logs, and testing
|
|
21
|
+
- **Express Integration** — Attach MCP routes to any Express/Node.js HTTP server
|
|
22
|
+
- **CLI & Programmatic** — Full CLI for quick starts, programmatic API for custom setups
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
---
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
## Quick Start
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
### Install
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
openapi-mcp
|
|
32
|
-
--transport web \
|
|
33
|
-
--port 3000 \
|
|
34
|
-
--host 127.0.0.1 \
|
|
35
|
-
--api-key your-admin-key
|
|
31
|
+
npm install @powerduck/openapi-mcp-server
|
|
36
32
|
```
|
|
37
33
|
|
|
38
|
-
|
|
34
|
+
### Run as a stdio server (CLI)
|
|
39
35
|
|
|
40
36
|
```bash
|
|
41
|
-
openapi-mcp serve
|
|
42
|
-
--transport stdio \
|
|
43
|
-
--spec ./openapi.yaml \
|
|
44
|
-
--base-url https://api.example.com
|
|
37
|
+
npx @powerduck/openapi-mcp-server serve --spec ./openapi.json
|
|
45
38
|
```
|
|
46
39
|
|
|
47
|
-
###
|
|
40
|
+
### Run as an HTTP server (CLI)
|
|
48
41
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const spec = await loadOpenApiSpec("./openapi.yaml");
|
|
56
|
-
|
|
57
|
-
// Parse from string content
|
|
58
|
-
const specFromText = await parseSpecContent(
|
|
59
|
-
'{"openapi": "3.1.0", "info": {...}, "paths": {...}}',
|
|
60
|
-
false, // isYaml
|
|
61
|
-
);
|
|
42
|
+
```bash
|
|
43
|
+
npx @powerduck/openapi-mcp-server serve \
|
|
44
|
+
--spec ./openapi.json \
|
|
45
|
+
--transport http \
|
|
46
|
+
--port 3000 \
|
|
47
|
+
--route-prefix /mcp
|
|
62
48
|
```
|
|
63
49
|
|
|
64
|
-
|
|
50
|
+
### Programmatic stdio server
|
|
65
51
|
|
|
66
52
|
```typescript
|
|
67
|
-
import {
|
|
53
|
+
import { startStdioServer } from "@powerduck/openapi-mcp-server";
|
|
68
54
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
55
|
+
await startStdioServer({
|
|
56
|
+
specPath: "./openapi.json",
|
|
57
|
+
serverName: "My API MCP Server",
|
|
58
|
+
serverVersion: "1.0.0",
|
|
59
|
+
});
|
|
74
60
|
```
|
|
75
61
|
|
|
76
|
-
|
|
62
|
+
### Programmatic HTTP server (Express)
|
|
77
63
|
|
|
78
64
|
```typescript
|
|
79
|
-
import
|
|
80
|
-
|
|
81
|
-
const prompts = generatePrompts(spec);
|
|
82
|
-
const resources = generateResources(spec);
|
|
83
|
-
```
|
|
65
|
+
import express from "express";
|
|
66
|
+
import { attachSseRoutes } from "@powerduck/openapi-mcp-server";
|
|
84
67
|
|
|
85
|
-
|
|
68
|
+
const app = express();
|
|
86
69
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
70
|
+
attachSseRoutes(app, {
|
|
71
|
+
specPath: "./openapi.json",
|
|
72
|
+
routePrefix: "/mcp",
|
|
73
|
+
serverName: "My API MCP Server",
|
|
74
|
+
});
|
|
90
75
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
specProvider: async () => spec,
|
|
94
|
-
contextProvider: async () => ({ baseUrl: "https://api.example.com" }),
|
|
76
|
+
app.listen(3000, () => {
|
|
77
|
+
console.log("MCP server running at http://localhost:3000/mcp");
|
|
95
78
|
});
|
|
79
|
+
```
|
|
96
80
|
|
|
97
|
-
|
|
98
|
-
await startStdioServer(server);
|
|
81
|
+
---
|
|
99
82
|
|
|
100
|
-
|
|
101
|
-
const app = express();
|
|
102
|
-
attachSseRoutes(app, server, { path: "/mcp" });
|
|
103
|
-
app.listen(3000);
|
|
104
|
-
```
|
|
83
|
+
## Links
|
|
105
84
|
|
|
106
|
-
|
|
85
|
+
- [Official Website](https://www.powerduck.com/opensource/openapi-mcp-server.html)
|
|
86
|
+
- [Documentation](https://www.powerduck.com/docs/openapi-mcp-server/introduction)
|
|
87
|
+
- [GitHub](https://github.com/PowerDuckie/openapi-mcp-server)
|
|
88
|
+
- [npm](https://www.npmjs.com/package/@powerduck/openapi-mcp-server)
|
|
107
89
|
|
|
108
|
-
|
|
109
|
-
import { executeToolCall } from "@powerduck/openapi-mcp-server";
|
|
110
|
-
|
|
111
|
-
const result = await executeToolCall({
|
|
112
|
-
toolName: "get_user",
|
|
113
|
-
arguments: { id: "123" },
|
|
114
|
-
spec,
|
|
115
|
-
baseUrl: "https://api.example.com",
|
|
116
|
-
headers: { Authorization: "Bearer token" },
|
|
117
|
-
});
|
|
118
|
-
```
|
|
90
|
+
---
|
|
119
91
|
|
|
120
|
-
|
|
92
|
+
## Features
|
|
121
93
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
94
|
+
- **Auto-generated tools** — Every OpenAPI operation becomes an MCP tool with full parameter schemas
|
|
95
|
+
- **Auto-generated prompts** — Smart prompt templates for common API workflows
|
|
96
|
+
- **Auto-generated resources** — API docs, schemas, and examples accessible as MCP resources
|
|
97
|
+
- **2 transports** — stdio for local AI clients, HTTP/SSE for remote and cloud deployments
|
|
98
|
+
- **Security resolution** — Bearer tokens, API keys, Basic auth, OAuth2, and custom schemes
|
|
99
|
+
- **Type-safe execution** — Full parameter validation before executing API calls
|
|
100
|
+
- **Error handling** — Structured MCP errors with API response details
|
|
101
|
+
- **Admin dashboard** — Built-in web UI for monitoring tools, viewing logs, and testing
|
|
102
|
+
- **Express integration** — Attach MCP routes to any Express/Node.js HTTP server
|
|
103
|
+
- **CLI & programmatic** — Full CLI for quick starts, programmatic API for custom setups
|
|
104
|
+
- **Tool filtering** — Include/exclude tools by tag, path, method, or operationId
|
|
105
|
+
- **Custom tool wrappers** — Wrap auto-generated tools with custom logic or validation
|
|
106
|
+
- **Rate limiting** — Configurable rate limits per tool and per client
|
|
107
|
+
- **Request logging** — Structured logging for all MCP requests and API calls
|
|
108
|
+
- **CORS support** — Configurable CORS for HTTP transport
|
|
109
|
+
- **Dual ESM/CJS** — Works with `import` and `require`, with bundled TypeScript declarations
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## CLI Reference
|
|
114
|
+
|
|
115
|
+
### Commands
|
|
135
116
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
console.log(op.method, op.path, op.operation?.operationId);
|
|
139
|
-
}
|
|
117
|
+
```bash
|
|
118
|
+
openapi-mcp-server serve [options]
|
|
140
119
|
|
|
141
|
-
|
|
142
|
-
|
|
120
|
+
# Stdio server (default)
|
|
121
|
+
openapi-mcp-server serve --spec ./openapi.json
|
|
143
122
|
|
|
144
|
-
|
|
145
|
-
|
|
123
|
+
# HTTP/SSE server
|
|
124
|
+
openapi-mcp-server serve --spec ./openapi.json --transport http --port 3000
|
|
146
125
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
126
|
+
# With auth and filtering
|
|
127
|
+
openapi-mcp-server serve \
|
|
128
|
+
--spec ./openapi.json \
|
|
129
|
+
--transport http \
|
|
130
|
+
--port 3000 \
|
|
131
|
+
--bearer $TOKEN \
|
|
132
|
+
--include-tags users,orders \
|
|
133
|
+
--exclude-methods delete
|
|
150
134
|
```
|
|
151
135
|
|
|
152
|
-
|
|
136
|
+
### Options
|
|
137
|
+
|
|
138
|
+
| Option | Type | Default | Description |
|
|
139
|
+
| ------------------- | ---------- | --------- | ------------------------------------------ |
|
|
140
|
+
| `--spec` | `string` | - | Path or URL to OpenAPI spec (required) |
|
|
141
|
+
| `--transport` | `string` | `stdio` | Transport type: `stdio` or `http` |
|
|
142
|
+
| `--port` | `number` | `3000` | HTTP server port |
|
|
143
|
+
| `--host` | `string` | `0.0.0.0` | HTTP server host |
|
|
144
|
+
| `--route-prefix` | `string` | `/mcp` | HTTP route prefix |
|
|
145
|
+
| `--server-name` | `string` | - | MCP server display name |
|
|
146
|
+
| `--server-version` | `string` | `1.0.0` | MCP server version |
|
|
147
|
+
| `--bearer` | `string` | - | Bearer token for API authentication |
|
|
148
|
+
| `--api-key` | `string` | - | API key for API authentication |
|
|
149
|
+
| `--header` | `string[]` | - | Custom headers (Key: Value) |
|
|
150
|
+
| `--include-tags` | `string` | - | Include tools with these tags |
|
|
151
|
+
| `--exclude-tags` | `string` | - | Exclude tools with these tags |
|
|
152
|
+
| `--include-methods` | `string` | - | Include tools with these methods |
|
|
153
|
+
| `--exclude-methods` | `string` | - | Exclude tools with these methods |
|
|
154
|
+
| `--include-paths` | `string` | - | Include tools matching these path patterns |
|
|
155
|
+
| `--exclude-paths` | `string` | - | Exclude tools matching these path patterns |
|
|
156
|
+
| `--admin` | `boolean` | `true` | Enable admin dashboard |
|
|
157
|
+
| `--admin-port` | `number` | `3001` | Admin dashboard port |
|
|
158
|
+
| `--log-level` | `string` | `info` | Log level: debug, info, warn, error |
|
|
159
|
+
| `--cors-origin` | `string` | `*` | CORS allowed origin |
|
|
160
|
+
| `--rate-limit` | `number` | `100` | Max requests per minute per tool |
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Programmatic API
|
|
165
|
+
|
|
166
|
+
### `startStdioServer(options)`
|
|
167
|
+
|
|
168
|
+
Start an MCP server over stdio.
|
|
153
169
|
|
|
154
170
|
```typescript
|
|
155
|
-
import {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
171
|
+
import { startStdioServer } from "@powerduck/openapi-mcp-server";
|
|
172
|
+
|
|
173
|
+
await startStdioServer({
|
|
174
|
+
specPath: "./openapi.json",
|
|
175
|
+
serverName: "My API",
|
|
176
|
+
serverVersion: "1.0.0",
|
|
177
|
+
securityValues: { bearerAuth: "token" },
|
|
178
|
+
toolFilter: { includeTags: ["users", "orders"] },
|
|
179
|
+
logLevel: "info",
|
|
162
180
|
});
|
|
163
|
-
|
|
164
|
-
// request contains: method, url, headers, body
|
|
165
181
|
```
|
|
166
182
|
|
|
167
|
-
|
|
183
|
+
### `attachSseRoutes(app, options)`
|
|
184
|
+
|
|
185
|
+
Attach MCP SSE routes to an Express app.
|
|
168
186
|
|
|
169
187
|
```typescript
|
|
170
|
-
import
|
|
188
|
+
import express from "express";
|
|
189
|
+
import { attachSseRoutes } from "@powerduck/openapi-mcp-server";
|
|
190
|
+
|
|
191
|
+
const app = express();
|
|
171
192
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
193
|
+
attachSseRoutes(app, {
|
|
194
|
+
specPath: "./openapi.json",
|
|
195
|
+
routePrefix: "/mcp",
|
|
196
|
+
serverName: "My API",
|
|
197
|
+
corsOrigin: "https://my-app.com",
|
|
176
198
|
});
|
|
177
199
|
|
|
178
|
-
|
|
179
|
-
import express from "express";
|
|
180
|
-
const myApp = express();
|
|
181
|
-
myApp.use("/admin", createAuthMiddleware({ apiKey: "secret" }));
|
|
200
|
+
app.listen(3000);
|
|
182
201
|
```
|
|
183
202
|
|
|
184
|
-
|
|
203
|
+
### `startAdminServer(options)`
|
|
185
204
|
|
|
186
|
-
|
|
187
|
-
src/
|
|
188
|
-
├── core/
|
|
189
|
-
│ ├── openapi-loader.ts # Spec loading, validation, dereferencing
|
|
190
|
-
│ ├── spec-utils.ts # Operation traversal, parameter normalization
|
|
191
|
-
│ ├── tool-generator.ts # MCP tool generation from operations
|
|
192
|
-
│ ├── request-builder.ts # HTTP request construction with serialization
|
|
193
|
-
│ ├── http-executor.ts # Safe HTTP request execution
|
|
194
|
-
│ └── global-utils.ts # Shared utilities (IDs, error detection)
|
|
195
|
-
├── mcp/
|
|
196
|
-
│ ├── create-server.ts # MCP server construction
|
|
197
|
-
│ ├── transport-stdio.ts # STDIO transport
|
|
198
|
-
│ └── transport-http.ts # HTTP/SSE transport
|
|
199
|
-
├── registry/
|
|
200
|
-
│ ├── prompt-registry.ts # Prompt generation and resolution
|
|
201
|
-
│ └── resource-registry.ts # Resource generation and reading
|
|
202
|
-
├── runtime/
|
|
203
|
-
│ └── service-registry.ts # Runtime service management
|
|
204
|
-
├── server/
|
|
205
|
-
│ ├── admin-server.ts # Admin HTTP server with Web UI
|
|
206
|
-
│ └── auth.ts # Authentication middleware
|
|
207
|
-
├── config/
|
|
208
|
-
│ └── config-store.ts # Persistent configuration storage
|
|
209
|
-
├── webui/
|
|
210
|
-
│ └── index.html # Admin Web UI
|
|
211
|
-
├── types.ts # Shared TypeScript types
|
|
212
|
-
├── cli.ts # CLI entry point
|
|
213
|
-
└── index.ts # Library exports
|
|
214
|
-
```
|
|
205
|
+
Start the admin dashboard server.
|
|
215
206
|
|
|
216
|
-
|
|
207
|
+
```typescript
|
|
208
|
+
import { startAdminServer } from "@powerduck/openapi-mcp-server";
|
|
217
209
|
|
|
218
|
-
|
|
210
|
+
await startAdminServer({
|
|
211
|
+
port: 3001,
|
|
212
|
+
mcpServerUrl: "http://localhost:3000/mcp",
|
|
213
|
+
});
|
|
214
|
+
```
|
|
219
215
|
|
|
220
|
-
|
|
221
|
-
- View generated tools, prompts, and resources
|
|
222
|
-
- Inspect running runtime services
|
|
223
|
-
- Stop services
|
|
224
|
-
- Basic MCP debugging hints
|
|
225
|
-
- SSE endpoint discovery
|
|
226
|
-
- STDIO configuration guidance
|
|
216
|
+
### `createMcpServer(options)`
|
|
227
217
|
|
|
228
|
-
|
|
218
|
+
Create a low-level MCP server instance for custom integration.
|
|
229
219
|
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
npm test
|
|
220
|
+
```typescript
|
|
221
|
+
import { createMcpServer } from "@powerduck/openapi-mcp-server";
|
|
233
222
|
|
|
234
|
-
|
|
235
|
-
|
|
223
|
+
const server = createMcpServer({
|
|
224
|
+
spec: openApiDocument,
|
|
225
|
+
serverName: "My API",
|
|
226
|
+
securityValues: { bearerAuth: "token" },
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// List tools
|
|
230
|
+
const tools = await server.listTools();
|
|
236
231
|
|
|
237
|
-
|
|
238
|
-
|
|
232
|
+
// Call a tool
|
|
233
|
+
const result = await server.callTool("getUser", { id: "123" });
|
|
239
234
|
```
|
|
240
235
|
|
|
241
|
-
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## MCP Client Configuration
|
|
239
|
+
|
|
240
|
+
### Claude Desktop (stdio)
|
|
241
|
+
|
|
242
|
+
```json
|
|
243
|
+
{
|
|
244
|
+
"mcpServers": {
|
|
245
|
+
"my-api": {
|
|
246
|
+
"command": "npx",
|
|
247
|
+
"args": [
|
|
248
|
+
"@powerduck/openapi-mcp-server",
|
|
249
|
+
"serve",
|
|
250
|
+
"--spec",
|
|
251
|
+
"./openapi.json"
|
|
252
|
+
],
|
|
253
|
+
"env": {
|
|
254
|
+
"BEARER_TOKEN": "your-token"
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
```
|
|
242
260
|
|
|
243
|
-
|
|
244
|
-
- **Spec utilities**: operation iteration, parameter normalization, name uniqueness
|
|
245
|
-
- **OpenAPI loader**: JSON/YAML parsing, validation, dereferencing, error handling
|
|
246
|
-
- **Module exports**: all public API surface verification
|
|
261
|
+
### Cursor / VS Code (HTTP)
|
|
247
262
|
|
|
248
|
-
|
|
263
|
+
```json
|
|
264
|
+
{
|
|
265
|
+
"mcpServers": {
|
|
266
|
+
"my-api": {
|
|
267
|
+
"url": "http://localhost:3000/mcp"
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
```
|
|
249
272
|
|
|
250
|
-
|
|
273
|
+
---
|
|
251
274
|
|
|
252
|
-
|
|
253
|
-
- Database-backed project registry
|
|
254
|
-
- Rate limits
|
|
255
|
-
- Audit logs
|
|
256
|
-
- Role-based access control (RBAC)
|
|
257
|
-
- Secure secret storage
|
|
258
|
-
- Upstream host allowlists
|
|
275
|
+
## TypeScript Types
|
|
259
276
|
|
|
260
|
-
|
|
277
|
+
```typescript
|
|
278
|
+
import type {
|
|
279
|
+
StdioServerOptions,
|
|
280
|
+
HttpServerOptions,
|
|
281
|
+
McpServerOptions,
|
|
282
|
+
ToolFilter,
|
|
283
|
+
SecurityValues,
|
|
284
|
+
McpTool,
|
|
285
|
+
McpPrompt,
|
|
286
|
+
McpResource,
|
|
287
|
+
ToolCallResult,
|
|
288
|
+
} from "@powerduck/openapi-mcp-server";
|
|
289
|
+
```
|
|
261
290
|
|
|
262
|
-
|
|
263
|
-
- `@modelcontextprotocol/sdk` — MCP protocol implementation
|
|
264
|
-
- `express` — HTTP server for admin UI and SSE transport
|
|
265
|
-
- `axios` — HTTP client for tool execution
|
|
266
|
-
- `commander` — CLI framework
|
|
267
|
-
- `js-yaml` — YAML parsing
|
|
268
|
-
- `multer` — File upload handling
|
|
269
|
-
- `cors` — CORS middleware
|
|
270
|
-
- `terser` — Minification for embedded assets
|
|
291
|
+
---
|
|
271
292
|
|
|
272
293
|
## License
|
|
273
294
|
|
|
274
|
-
MIT ©
|
|
275
|
-
|
|
276
|
-
## Important Implementation Policy
|
|
277
|
-
|
|
278
|
-
All source comments are written in American English. No Chinese characters are permitted in the codebase.
|
|
295
|
+
MIT © [POWERDUCK LIMITED](https://www.powerduck.com)
|
package/package.json
CHANGED