@nam088/mcp-swagger-parser 3.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/README.md +224 -0
- package/bin/server.ts +48 -0
- package/dist/bin/server.d.ts +3 -0
- package/dist/bin/server.d.ts.map +1 -0
- package/dist/bin/server.js +39 -0
- package/dist/bin/server.js.map +1 -0
- package/dist/src/index.d.ts +22 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +548 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/types.d.ts +27 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# @nam088/mcp-swagger-parser
|
|
2
|
+
|
|
3
|
+
Enhanced OpenAPI/Swagger MCP plugin with 12 powerful tools, YAML support, and automatic schema resolution.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
✨ **12 Comprehensive Tools**
|
|
8
|
+
- 7 Discovery Tools (search, details, tags, curl generator)
|
|
9
|
+
- 1 Safe Read Tool (GET requests only)
|
|
10
|
+
- 4 Write Tools (POST/PUT/PATCH/DELETE with FULL mode restriction)
|
|
11
|
+
|
|
12
|
+
🔍 **Auto Schema Resolution**
|
|
13
|
+
- Automatically resolves `$ref` references
|
|
14
|
+
- Returns complete schemas in one call
|
|
15
|
+
- No manual dereferencing needed
|
|
16
|
+
|
|
17
|
+
📄 **YAML & JSON Support**
|
|
18
|
+
- Auto-detects `.yaml`/`.yml` files
|
|
19
|
+
- Works with OpenAPI 2.0, 3.0, 3.1
|
|
20
|
+
|
|
21
|
+
🔐 **Authentication**
|
|
22
|
+
- Bearer token support
|
|
23
|
+
- Custom headers
|
|
24
|
+
- Per-request configuration
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install @nam088/mcp-swagger-parser
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
### Configure MCP Server
|
|
35
|
+
|
|
36
|
+
Add to your MCP configuration file:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"mcpServers": {
|
|
41
|
+
"swagger": {
|
|
42
|
+
"command": "npx",
|
|
43
|
+
"args": ["-y", "@nam088/mcp-swagger-parser"],
|
|
44
|
+
"env": {
|
|
45
|
+
"SWAGGER_URL": "http://localhost:3000/docs-json"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### With Authentication
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"env": {
|
|
57
|
+
"SWAGGER_URL": "https://api.example.com/openapi.yaml",
|
|
58
|
+
"SWAGGER_AUTH_TOKEN": "your-bearer-token",
|
|
59
|
+
"SWAGGER_BASE_URL": "https://api.example.com"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Available Tools
|
|
65
|
+
|
|
66
|
+
### Discovery Tools (Always Safe)
|
|
67
|
+
|
|
68
|
+
#### 1. `swagger_search_tools`
|
|
69
|
+
Search for API endpoints by keyword.
|
|
70
|
+
```typescript
|
|
71
|
+
{ query: "user" }
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### 2. `swagger_get_endpoint_details`
|
|
75
|
+
Get complete endpoint specification with resolved schemas.
|
|
76
|
+
```typescript
|
|
77
|
+
{ method: "POST", path: "/api/users" }
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### 3. `swagger_list_tags`
|
|
81
|
+
List all API categories/tags.
|
|
82
|
+
|
|
83
|
+
#### 4. `swagger_list_endpoints_by_tag`
|
|
84
|
+
Filter endpoints by tag.
|
|
85
|
+
```typescript
|
|
86
|
+
{ tag: "Auth" }
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### 5. `swagger_generate_curl`
|
|
90
|
+
Generate ready-to-use curl command.
|
|
91
|
+
```typescript
|
|
92
|
+
{
|
|
93
|
+
method: "POST",
|
|
94
|
+
path: "/api/login",
|
|
95
|
+
body: { email: "test@example.com" }
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### 6. `swagger_generate_example_request`
|
|
100
|
+
Generate example request with placeholder values.
|
|
101
|
+
```typescript
|
|
102
|
+
{ method: "GET", path: "/api/users/{id}" }
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### 7. `swagger_reload`
|
|
106
|
+
Reload OpenAPI specification from source.
|
|
107
|
+
|
|
108
|
+
### Read-Only Tool (READONLY Mode)
|
|
109
|
+
|
|
110
|
+
#### 8. `swagger_execute_get`
|
|
111
|
+
Execute GET requests safely (no side effects).
|
|
112
|
+
```typescript
|
|
113
|
+
{
|
|
114
|
+
path: "/api/users",
|
|
115
|
+
params: { limit: "10" }
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Write Tools (FULL Mode Only)
|
|
120
|
+
|
|
121
|
+
#### 9-12. `swagger_execute_post/put/patch/delete`
|
|
122
|
+
Execute write operations (requires FULL mode).
|
|
123
|
+
```typescript
|
|
124
|
+
{
|
|
125
|
+
path: "/api/users",
|
|
126
|
+
body: { name: "John" }
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Configuration Options
|
|
131
|
+
|
|
132
|
+
| Variable | Description | Default |
|
|
133
|
+
|----------|-------------|---------|
|
|
134
|
+
| `SWAGGER_URL` | OpenAPI spec URL (.json/.yaml) | Required |
|
|
135
|
+
| `SWAGGER_JSON` | Direct JSON spec object | Optional |
|
|
136
|
+
| `SWAGGER_BASE_URL` | Override base API URL | Auto-detected |
|
|
137
|
+
| `SWAGGER_AUTH_TOKEN` | Bearer token | Optional |
|
|
138
|
+
| `SWAGGER_DEFAULT_HEADERS` | JSON object of headers | Optional |
|
|
139
|
+
|
|
140
|
+
## Examples
|
|
141
|
+
|
|
142
|
+
### Basic Usage
|
|
143
|
+
```json
|
|
144
|
+
{
|
|
145
|
+
"SWAGGER_URL": "http://localhost:3000/docs-json"
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### With YAML
|
|
150
|
+
```json
|
|
151
|
+
{
|
|
152
|
+
"SWAGGER_URL": "https://api.example.com/openapi.yaml"
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### With Authentication
|
|
157
|
+
```json
|
|
158
|
+
{
|
|
159
|
+
"SWAGGER_URL": "https://api.example.com/api-docs",
|
|
160
|
+
"SWAGGER_AUTH_TOKEN": "eyJhbGc...",
|
|
161
|
+
"SWAGGER_BASE_URL": "https://api.example.com"
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Programmatic Usage
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
import { SwaggerParserPlugin } from '@nam088/mcp-swagger-parser';
|
|
169
|
+
|
|
170
|
+
const plugin = new SwaggerParserPlugin({
|
|
171
|
+
url: 'http://localhost:3000/docs-json',
|
|
172
|
+
authToken: 'your-token',
|
|
173
|
+
baseUrl: 'http://localhost:3000'
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
await plugin.initialize(context);
|
|
177
|
+
plugin.register(context);
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Features
|
|
181
|
+
|
|
182
|
+
### Automatic Schema Resolution
|
|
183
|
+
All `$ref` references are automatically resolved:
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
// Before: { "$ref": "#/components/schemas/User" }
|
|
187
|
+
// After: {
|
|
188
|
+
// "type": "object",
|
|
189
|
+
// "properties": {
|
|
190
|
+
// "id": { "type": "string" },
|
|
191
|
+
// "name": { "type": "string" }
|
|
192
|
+
// }
|
|
193
|
+
// }
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Mode-Based Security
|
|
197
|
+
- **Discovery tools**: Always safe, no restrictions
|
|
198
|
+
- **GET execution**: Safe, available in READONLY mode
|
|
199
|
+
- **Write operations**: Require FULL mode, marked with `isWriteTool: true`
|
|
200
|
+
|
|
201
|
+
## Development
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
# Build
|
|
205
|
+
npm run build
|
|
206
|
+
|
|
207
|
+
# Clean
|
|
208
|
+
npm run clean
|
|
209
|
+
|
|
210
|
+
# Test
|
|
211
|
+
npm test
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## License
|
|
215
|
+
|
|
216
|
+
MIT
|
|
217
|
+
|
|
218
|
+
## Author
|
|
219
|
+
|
|
220
|
+
Nam088
|
|
221
|
+
|
|
222
|
+
## Repository
|
|
223
|
+
|
|
224
|
+
https://github.com/nam088/mcp-server
|
package/bin/server.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
|
+
import { PluginRegistry } from '@nam088/mcp-core';
|
|
6
|
+
import { SwaggerParserPlugin } from '../src/index.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Swagger Parser MCP Server
|
|
10
|
+
* Standalone server for Swagger/OpenAPI plugin
|
|
11
|
+
*/
|
|
12
|
+
async function main(): Promise<void> {
|
|
13
|
+
const server = new McpServer(
|
|
14
|
+
{
|
|
15
|
+
name: 'mcp-swagger-parser',
|
|
16
|
+
version: '1.0.0',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
capabilities: {
|
|
20
|
+
tools: {},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
// Create plugin registry
|
|
26
|
+
const registry = new PluginRegistry(server);
|
|
27
|
+
|
|
28
|
+
// Register SwaggerParser plugin
|
|
29
|
+
// We pass config via environment variables, or it falls back to defaults/empty
|
|
30
|
+
// Use SWAGGER_URL or SWAGGER_JSON env vars to configure
|
|
31
|
+
const config = {
|
|
32
|
+
url: process.env.SWAGGER_URL || 'http://localhost:3000/docs-json',
|
|
33
|
+
json: process.env.SWAGGER_JSON
|
|
34
|
+
? (JSON.parse(process.env.SWAGGER_JSON) as Record<string, unknown>)
|
|
35
|
+
: undefined,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
await registry.registerPlugin(SwaggerParserPlugin, { config });
|
|
39
|
+
|
|
40
|
+
// Connect transport
|
|
41
|
+
const transport = new StdioServerTransport();
|
|
42
|
+
await server.connect(transport);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
main().catch((error) => {
|
|
46
|
+
console.error('[ERROR] [MCPSwaggerServer] Fatal error:', error);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../bin/server.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { PluginRegistry } from '@nam088/mcp-core';
|
|
5
|
+
import { SwaggerParserPlugin } from '../src/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Swagger Parser MCP Server
|
|
8
|
+
* Standalone server for Swagger/OpenAPI plugin
|
|
9
|
+
*/
|
|
10
|
+
async function main() {
|
|
11
|
+
const server = new McpServer({
|
|
12
|
+
name: 'mcp-swagger-parser',
|
|
13
|
+
version: '1.0.0',
|
|
14
|
+
}, {
|
|
15
|
+
capabilities: {
|
|
16
|
+
tools: {},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
// Create plugin registry
|
|
20
|
+
const registry = new PluginRegistry(server);
|
|
21
|
+
// Register SwaggerParser plugin
|
|
22
|
+
// We pass config via environment variables, or it falls back to defaults/empty
|
|
23
|
+
// Use SWAGGER_URL or SWAGGER_JSON env vars to configure
|
|
24
|
+
const config = {
|
|
25
|
+
url: process.env.SWAGGER_URL || 'http://localhost:3000/docs-json',
|
|
26
|
+
json: process.env.SWAGGER_JSON
|
|
27
|
+
? JSON.parse(process.env.SWAGGER_JSON)
|
|
28
|
+
: undefined,
|
|
29
|
+
};
|
|
30
|
+
await registry.registerPlugin(SwaggerParserPlugin, { config });
|
|
31
|
+
// Connect transport
|
|
32
|
+
const transport = new StdioServerTransport();
|
|
33
|
+
await server.connect(transport);
|
|
34
|
+
}
|
|
35
|
+
main().catch((error) => {
|
|
36
|
+
console.error('[ERROR] [MCPSwaggerServer] Fatal error:', error);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../bin/server.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;GAGG;AACH,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;QACE,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,OAAO;KACjB,EACD;QACE,YAAY,EAAE;YACZ,KAAK,EAAE,EAAE;SACV;KACF,CACF,CAAC;IAEF,yBAAyB;IACzB,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;IAE5C,gCAAgC;IAChC,+EAA+E;IAC/E,wDAAwD;IACxD,MAAM,MAAM,GAAG;QACb,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,iCAAiC;QACjE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;YAC5B,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAA6B;YACnE,CAAC,CAAC,SAAS;KACd,CAAC;IAEF,MAAM,QAAQ,CAAC,cAAc,CAAC,mBAAmB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAE/D,oBAAoB;IACpB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,yCAAyC,EAAE,KAAK,CAAC,CAAC;IAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PluginBase, type PluginConfig, type PluginContext } from '@nam088/mcp-core';
|
|
2
|
+
/**
|
|
3
|
+
* Swagger Parser MCP Plugin
|
|
4
|
+
* Enhanced tool suite with discovery, safe reads, and controlled writes
|
|
5
|
+
*/
|
|
6
|
+
export declare class SwaggerParserPlugin extends PluginBase {
|
|
7
|
+
readonly metadata: PluginConfig;
|
|
8
|
+
private swaggerConfig;
|
|
9
|
+
private openApiSpec;
|
|
10
|
+
private baseUrl;
|
|
11
|
+
constructor(config?: Record<string, unknown>);
|
|
12
|
+
initialize(context: PluginContext): Promise<void>;
|
|
13
|
+
private loadSpec;
|
|
14
|
+
private buildHeaders;
|
|
15
|
+
/**
|
|
16
|
+
* Resolve $ref in schema recursively
|
|
17
|
+
*/
|
|
18
|
+
private resolveRef;
|
|
19
|
+
private executeRequest;
|
|
20
|
+
register(context: PluginContext): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAuCrF;;;GAGG;AACH,qBAAa,mBAAoB,SAAQ,UAAU;IACjD,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAK7B;IAEF,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,OAAO,CAAmC;gBAEtC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAQtC,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;YAKzC,QAAQ;IAwCtB,OAAO,CAAC,YAAY;IAapB;;OAEG;IACH,OAAO,CAAC,UAAU;YAiCJ,cAAc;IAgE5B,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;CAkdvC"}
|
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import { URL, URLSearchParams } from 'url';
|
|
4
|
+
import { PluginBase } from '@nam088/mcp-core';
|
|
5
|
+
import yaml from 'js-yaml';
|
|
6
|
+
/**
|
|
7
|
+
* Swagger Parser MCP Plugin
|
|
8
|
+
* Enhanced tool suite with discovery, safe reads, and controlled writes
|
|
9
|
+
*/
|
|
10
|
+
export class SwaggerParserPlugin extends PluginBase {
|
|
11
|
+
metadata = {
|
|
12
|
+
name: 'swagger-parser',
|
|
13
|
+
version: '3.0.0',
|
|
14
|
+
description: 'Enhanced OpenAPI/Swagger tool suite for MCP',
|
|
15
|
+
config: {},
|
|
16
|
+
};
|
|
17
|
+
swaggerConfig = {};
|
|
18
|
+
openApiSpec = null;
|
|
19
|
+
baseUrl = 'http://localhost:3000';
|
|
20
|
+
constructor(config) {
|
|
21
|
+
super(config);
|
|
22
|
+
this.swaggerConfig = config || {};
|
|
23
|
+
if (this.swaggerConfig.baseUrl) {
|
|
24
|
+
this.baseUrl = this.swaggerConfig.baseUrl;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async initialize(context) {
|
|
28
|
+
await super.initialize(context);
|
|
29
|
+
await this.loadSpec();
|
|
30
|
+
}
|
|
31
|
+
async loadSpec() {
|
|
32
|
+
try {
|
|
33
|
+
if (this.swaggerConfig.url) {
|
|
34
|
+
console.log(`[SwaggerParser] Fetching spec from ${this.swaggerConfig.url}`);
|
|
35
|
+
const response = await axios.get(this.swaggerConfig.url, {
|
|
36
|
+
responseType: this.swaggerConfig.url.match(/\.(ya?ml)$/i) ? 'text' : 'json',
|
|
37
|
+
});
|
|
38
|
+
// Parse YAML if needed
|
|
39
|
+
if (this.swaggerConfig.url.match(/\.(ya?ml)$/i)) {
|
|
40
|
+
this.openApiSpec = yaml.load(response.data);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.openApiSpec = response.data;
|
|
44
|
+
}
|
|
45
|
+
if (!this.swaggerConfig.baseUrl) {
|
|
46
|
+
try {
|
|
47
|
+
this.baseUrl = new URL(this.swaggerConfig.url).origin;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
if (this.openApiSpec.servers?.[0]?.url) {
|
|
51
|
+
this.baseUrl = this.openApiSpec.servers[0].url;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (this.swaggerConfig.json) {
|
|
57
|
+
console.log(`[SwaggerParser] Using provided JSON spec`);
|
|
58
|
+
this.openApiSpec = this.swaggerConfig.json;
|
|
59
|
+
if (!this.swaggerConfig.baseUrl && this.openApiSpec.servers?.[0]?.url) {
|
|
60
|
+
this.baseUrl = this.openApiSpec.servers[0].url;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
console.warn('[SwaggerParser] No URL or JSON provided in config');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.error('[ERROR] [SwaggerParser] Initialization failed:', error);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
buildHeaders() {
|
|
73
|
+
const headers = {
|
|
74
|
+
'Content-Type': 'application/json',
|
|
75
|
+
...this.swaggerConfig.defaultHeaders,
|
|
76
|
+
};
|
|
77
|
+
if (this.swaggerConfig.authToken) {
|
|
78
|
+
headers['Authorization'] = `Bearer ${this.swaggerConfig.authToken}`;
|
|
79
|
+
}
|
|
80
|
+
return headers;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Resolve $ref in schema recursively
|
|
84
|
+
*/
|
|
85
|
+
resolveRef(schema, depth = 0) {
|
|
86
|
+
if (depth > 10)
|
|
87
|
+
return schema; // Prevent infinite recursion
|
|
88
|
+
if (!schema || typeof schema !== 'object')
|
|
89
|
+
return schema;
|
|
90
|
+
const schemaObj = schema;
|
|
91
|
+
// Handle $ref
|
|
92
|
+
if ('$ref' in schemaObj && typeof schemaObj.$ref === 'string') {
|
|
93
|
+
const refPath = schemaObj.$ref.replace('#/components/schemas/', '');
|
|
94
|
+
const components = this.openApiSpec?.components;
|
|
95
|
+
const schemas = components?.schemas;
|
|
96
|
+
const refSchema = schemas?.[refPath];
|
|
97
|
+
if (refSchema) {
|
|
98
|
+
return this.resolveRef(refSchema, depth + 1);
|
|
99
|
+
}
|
|
100
|
+
return schema; // Keep $ref if not found
|
|
101
|
+
}
|
|
102
|
+
// Handle arrays
|
|
103
|
+
if (Array.isArray(schemaObj)) {
|
|
104
|
+
return schemaObj.map((item) => this.resolveRef(item, depth + 1));
|
|
105
|
+
}
|
|
106
|
+
// Handle nested objects
|
|
107
|
+
const resolved = {};
|
|
108
|
+
for (const [key, value] of Object.entries(schemaObj)) {
|
|
109
|
+
resolved[key] = this.resolveRef(value, depth + 1);
|
|
110
|
+
}
|
|
111
|
+
return resolved;
|
|
112
|
+
}
|
|
113
|
+
async executeRequest(method, path, params, body) {
|
|
114
|
+
try {
|
|
115
|
+
let finalUrl = `${this.baseUrl}${path}`;
|
|
116
|
+
const queryParams = new URLSearchParams();
|
|
117
|
+
if (params) {
|
|
118
|
+
for (const [key, value] of Object.entries(params)) {
|
|
119
|
+
if (finalUrl.includes(`{${key}}`)) {
|
|
120
|
+
finalUrl = finalUrl.replace(`{${key}}`, String(value));
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
queryParams.append(key, String(value));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const urlWithQuery = queryParams.toString()
|
|
128
|
+
? `${finalUrl}?${queryParams.toString()}`
|
|
129
|
+
: finalUrl;
|
|
130
|
+
const axiosConfig = {
|
|
131
|
+
method: method.toUpperCase(),
|
|
132
|
+
url: urlWithQuery,
|
|
133
|
+
headers: this.buildHeaders(),
|
|
134
|
+
};
|
|
135
|
+
if (body && ['POST', 'PUT', 'PATCH'].includes(method.toUpperCase())) {
|
|
136
|
+
axiosConfig.data = body;
|
|
137
|
+
}
|
|
138
|
+
const apiResponse = await axios(axiosConfig);
|
|
139
|
+
return {
|
|
140
|
+
content: [
|
|
141
|
+
{
|
|
142
|
+
type: 'text',
|
|
143
|
+
text: JSON.stringify(apiResponse.data, null, 2),
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
catch (err) {
|
|
149
|
+
let errorMessage = String(err);
|
|
150
|
+
if (axios.isAxiosError(err)) {
|
|
151
|
+
errorMessage = `Axios Error: ${err.message} - ${JSON.stringify(err.response?.data || {})}`;
|
|
152
|
+
}
|
|
153
|
+
else if (err instanceof Error) {
|
|
154
|
+
errorMessage = err.message;
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
content: [
|
|
158
|
+
{
|
|
159
|
+
type: 'text',
|
|
160
|
+
text: `Error calling API: ${errorMessage}`,
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
isError: true,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
register(context) {
|
|
168
|
+
// Tool 1: Search endpoints
|
|
169
|
+
this.registerTool({
|
|
170
|
+
context,
|
|
171
|
+
name: 'swagger_search_tools',
|
|
172
|
+
schema: {
|
|
173
|
+
description: 'Search for available API tools/endpoints in the Swagger spec',
|
|
174
|
+
inputSchema: {
|
|
175
|
+
query: z.string().describe('Search term (keywords, resource name, or path)'),
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
handler: async ({ query }) => {
|
|
179
|
+
await Promise.resolve();
|
|
180
|
+
if (!this.openApiSpec?.paths) {
|
|
181
|
+
return {
|
|
182
|
+
content: [{ type: 'text', text: 'Error: No OpenAPI spec loaded.' }],
|
|
183
|
+
isError: true,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
const matches = [];
|
|
187
|
+
const lowerQuery = query.toLowerCase();
|
|
188
|
+
for (const [path, methods] of Object.entries(this.openApiSpec.paths)) {
|
|
189
|
+
for (const [method, op] of Object.entries(methods)) {
|
|
190
|
+
const searchableText = `${method} ${path} ${op.summary || ''} ${op.description || ''} ${op.operationId || ''}`.toLowerCase();
|
|
191
|
+
if (searchableText.includes(lowerQuery)) {
|
|
192
|
+
const params = op.parameters
|
|
193
|
+
?.map((p) => `${p.name} (${p.in}${p.required ? '*' : ''})`)
|
|
194
|
+
.join(', ') || 'None';
|
|
195
|
+
matches.push({
|
|
196
|
+
method: method.toUpperCase(),
|
|
197
|
+
path,
|
|
198
|
+
...(op.summary ? { summary: op.summary } : {}),
|
|
199
|
+
...(op.description
|
|
200
|
+
? { description: op.description.substring(0, 100) + '...' }
|
|
201
|
+
: {}),
|
|
202
|
+
...(op.operationId ? { operationId: op.operationId } : {}),
|
|
203
|
+
paramsHint: params,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const limitedMatches = matches.slice(0, 20);
|
|
209
|
+
return {
|
|
210
|
+
content: [
|
|
211
|
+
{
|
|
212
|
+
type: 'text',
|
|
213
|
+
text: `Found ${matches.length} matches (showing top ${limitedMatches.length}):\n\n` +
|
|
214
|
+
JSON.stringify(limitedMatches, null, 2),
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
};
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
// Tool 2: Get endpoint details
|
|
221
|
+
this.registerTool({
|
|
222
|
+
context,
|
|
223
|
+
name: 'swagger_get_endpoint_details',
|
|
224
|
+
schema: {
|
|
225
|
+
description: 'Get detailed information about a specific API endpoint',
|
|
226
|
+
inputSchema: {
|
|
227
|
+
method: z.string().describe('HTTP method (GET, POST, etc.)'),
|
|
228
|
+
path: z.string().describe('API path (e.g., /users/{id})'),
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
handler: async ({ method, path }) => {
|
|
232
|
+
await Promise.resolve();
|
|
233
|
+
if (!this.openApiSpec?.paths) {
|
|
234
|
+
return {
|
|
235
|
+
content: [{ type: 'text', text: 'Error: No OpenAPI spec loaded.' }],
|
|
236
|
+
isError: true,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
const op = this.openApiSpec.paths[path]?.[method.toLowerCase()];
|
|
240
|
+
if (!op) {
|
|
241
|
+
return {
|
|
242
|
+
content: [{ type: 'text', text: `Endpoint not found: ${method} ${path}` }],
|
|
243
|
+
isError: true,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
const details = {
|
|
247
|
+
method: method.toUpperCase(),
|
|
248
|
+
path,
|
|
249
|
+
summary: op.summary,
|
|
250
|
+
description: op.description,
|
|
251
|
+
operationId: op.operationId,
|
|
252
|
+
tags: op.tags,
|
|
253
|
+
parameters: op.parameters || [],
|
|
254
|
+
requestBody: this.resolveRef(op.requestBody),
|
|
255
|
+
responses: this.resolveRef(op.responses),
|
|
256
|
+
};
|
|
257
|
+
return {
|
|
258
|
+
content: [
|
|
259
|
+
{
|
|
260
|
+
type: 'text',
|
|
261
|
+
text: JSON.stringify(details, null, 2),
|
|
262
|
+
},
|
|
263
|
+
],
|
|
264
|
+
};
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
// Tool 3: List all tags
|
|
268
|
+
this.registerTool({
|
|
269
|
+
context,
|
|
270
|
+
name: 'swagger_list_tags',
|
|
271
|
+
schema: {
|
|
272
|
+
description: 'List all API tags/categories',
|
|
273
|
+
inputSchema: {},
|
|
274
|
+
},
|
|
275
|
+
handler: async () => {
|
|
276
|
+
await Promise.resolve();
|
|
277
|
+
if (!this.openApiSpec) {
|
|
278
|
+
return {
|
|
279
|
+
content: [{ type: 'text', text: 'Error: No OpenAPI spec loaded.' }],
|
|
280
|
+
isError: true,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
const tags = this.openApiSpec.tags || [];
|
|
284
|
+
const tagSet = new Set();
|
|
285
|
+
// Also collect tags from operations
|
|
286
|
+
for (const methods of Object.values(this.openApiSpec.paths)) {
|
|
287
|
+
for (const op of Object.values(methods)) {
|
|
288
|
+
if (op.tags) {
|
|
289
|
+
op.tags.forEach((tag) => tagSet.add(tag));
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
const allTags = [...new Set([...tags.map((t) => t.name), ...Array.from(tagSet)])];
|
|
294
|
+
return {
|
|
295
|
+
content: [
|
|
296
|
+
{
|
|
297
|
+
type: 'text',
|
|
298
|
+
text: JSON.stringify({ tags: allTags, count: allTags.length }, null, 2),
|
|
299
|
+
},
|
|
300
|
+
],
|
|
301
|
+
};
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
// Tool 4: List endpoints by tag
|
|
305
|
+
this.registerTool({
|
|
306
|
+
context,
|
|
307
|
+
name: 'swagger_list_endpoints_by_tag',
|
|
308
|
+
schema: {
|
|
309
|
+
description: 'List all endpoints belonging to a specific tag',
|
|
310
|
+
inputSchema: {
|
|
311
|
+
tag: z.string().describe('Tag name'),
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
handler: async ({ tag }) => {
|
|
315
|
+
await Promise.resolve();
|
|
316
|
+
if (!this.openApiSpec?.paths) {
|
|
317
|
+
return {
|
|
318
|
+
content: [{ type: 'text', text: 'Error: No OpenAPI spec loaded.' }],
|
|
319
|
+
isError: true,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
const endpoints = [];
|
|
323
|
+
for (const [path, methods] of Object.entries(this.openApiSpec.paths)) {
|
|
324
|
+
for (const [method, op] of Object.entries(methods)) {
|
|
325
|
+
if (op.tags?.includes(tag)) {
|
|
326
|
+
endpoints.push({
|
|
327
|
+
method: method.toUpperCase(),
|
|
328
|
+
path,
|
|
329
|
+
...(op.summary ? { summary: op.summary } : {}),
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return {
|
|
335
|
+
content: [
|
|
336
|
+
{
|
|
337
|
+
type: 'text',
|
|
338
|
+
text: JSON.stringify({ tag, endpoints, count: endpoints.length }, null, 2),
|
|
339
|
+
},
|
|
340
|
+
],
|
|
341
|
+
};
|
|
342
|
+
},
|
|
343
|
+
});
|
|
344
|
+
// Tool 5: Generate curl command
|
|
345
|
+
this.registerTool({
|
|
346
|
+
context,
|
|
347
|
+
name: 'swagger_generate_curl',
|
|
348
|
+
schema: {
|
|
349
|
+
description: 'Generate a curl command for an API endpoint',
|
|
350
|
+
inputSchema: {
|
|
351
|
+
method: z.string().describe('HTTP method'),
|
|
352
|
+
path: z.string().describe('API path'),
|
|
353
|
+
params: z.record(z.unknown()).optional().describe('Parameters'),
|
|
354
|
+
body: z.record(z.unknown()).optional().describe('Request body'),
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
handler: async ({ method, path, params, body, }) => {
|
|
358
|
+
await Promise.resolve();
|
|
359
|
+
let finalUrl = `${this.baseUrl}${path}`;
|
|
360
|
+
const queryParams = new URLSearchParams();
|
|
361
|
+
if (params) {
|
|
362
|
+
for (const [key, value] of Object.entries(params)) {
|
|
363
|
+
if (finalUrl.includes(`{${key}}`)) {
|
|
364
|
+
finalUrl = finalUrl.replace(`{${key}}`, String(value));
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
queryParams.append(key, String(value));
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (queryParams.toString()) {
|
|
372
|
+
finalUrl += `?${queryParams.toString()}`;
|
|
373
|
+
}
|
|
374
|
+
let curlCmd = `curl -X ${method.toUpperCase()} "${finalUrl}"`;
|
|
375
|
+
const headers = this.buildHeaders();
|
|
376
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
377
|
+
curlCmd += ` \\\n -H "${key}: ${value}"`;
|
|
378
|
+
}
|
|
379
|
+
if (body) {
|
|
380
|
+
curlCmd += ` \\\n -d '${JSON.stringify(body)}'`;
|
|
381
|
+
}
|
|
382
|
+
return {
|
|
383
|
+
content: [
|
|
384
|
+
{
|
|
385
|
+
type: 'text',
|
|
386
|
+
text: curlCmd,
|
|
387
|
+
},
|
|
388
|
+
],
|
|
389
|
+
};
|
|
390
|
+
},
|
|
391
|
+
});
|
|
392
|
+
// Tool 6: Generate example request
|
|
393
|
+
this.registerTool({
|
|
394
|
+
context,
|
|
395
|
+
name: 'swagger_generate_example_request',
|
|
396
|
+
schema: {
|
|
397
|
+
description: 'Generate an example request with sample values',
|
|
398
|
+
inputSchema: {
|
|
399
|
+
method: z.string().describe('HTTP method'),
|
|
400
|
+
path: z.string().describe('API path'),
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
|
+
handler: async ({ method, path }) => {
|
|
404
|
+
await Promise.resolve();
|
|
405
|
+
if (!this.openApiSpec?.paths) {
|
|
406
|
+
return {
|
|
407
|
+
content: [{ type: 'text', text: 'Error: No OpenAPI spec loaded.' }],
|
|
408
|
+
isError: true,
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
const op = this.openApiSpec.paths[path]?.[method.toLowerCase()];
|
|
412
|
+
if (!op) {
|
|
413
|
+
return {
|
|
414
|
+
content: [{ type: 'text', text: `Endpoint not found: ${method} ${path}` }],
|
|
415
|
+
isError: true,
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
const example = {
|
|
419
|
+
method: method.toUpperCase(),
|
|
420
|
+
path,
|
|
421
|
+
};
|
|
422
|
+
if (op.parameters) {
|
|
423
|
+
example.params = {};
|
|
424
|
+
for (const param of op.parameters) {
|
|
425
|
+
example.params[param.name] = `<${param.name}>`;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (op.requestBody) {
|
|
429
|
+
example.body = '<request body>';
|
|
430
|
+
}
|
|
431
|
+
return {
|
|
432
|
+
content: [
|
|
433
|
+
{
|
|
434
|
+
type: 'text',
|
|
435
|
+
text: JSON.stringify(example, null, 2),
|
|
436
|
+
},
|
|
437
|
+
],
|
|
438
|
+
};
|
|
439
|
+
},
|
|
440
|
+
});
|
|
441
|
+
// Tool 7: Reload spec
|
|
442
|
+
this.registerTool({
|
|
443
|
+
context,
|
|
444
|
+
name: 'swagger_reload',
|
|
445
|
+
schema: {
|
|
446
|
+
description: 'Reload the OpenAPI specification from source',
|
|
447
|
+
inputSchema: {},
|
|
448
|
+
},
|
|
449
|
+
handler: async () => {
|
|
450
|
+
try {
|
|
451
|
+
await this.loadSpec();
|
|
452
|
+
return {
|
|
453
|
+
content: [{ type: 'text', text: 'OpenAPI spec reloaded successfully.' }],
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
catch (err) {
|
|
457
|
+
return {
|
|
458
|
+
content: [{ type: 'text', text: `Failed to reload spec: ${String(err)}` }],
|
|
459
|
+
isError: true,
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
},
|
|
463
|
+
});
|
|
464
|
+
// Tool 8: Execute GET (READONLY mode OK)
|
|
465
|
+
this.registerTool({
|
|
466
|
+
context,
|
|
467
|
+
name: 'swagger_execute_get',
|
|
468
|
+
schema: {
|
|
469
|
+
description: 'Execute a GET request (read-only, safe)',
|
|
470
|
+
inputSchema: {
|
|
471
|
+
path: z.string().describe('API path'),
|
|
472
|
+
params: z.record(z.unknown()).optional().describe('Query/path parameters'),
|
|
473
|
+
},
|
|
474
|
+
},
|
|
475
|
+
handler: async ({ path, params }) => {
|
|
476
|
+
return await this.executeRequest('GET', path, params);
|
|
477
|
+
},
|
|
478
|
+
});
|
|
479
|
+
// Tool 9: Execute POST (FULL mode only)
|
|
480
|
+
this.registerTool({
|
|
481
|
+
context,
|
|
482
|
+
name: 'swagger_execute_post',
|
|
483
|
+
schema: {
|
|
484
|
+
description: 'Execute a POST request (requires FULL mode)',
|
|
485
|
+
inputSchema: {
|
|
486
|
+
path: z.string().describe('API path'),
|
|
487
|
+
params: z.record(z.unknown()).optional().describe('Query/path parameters'),
|
|
488
|
+
body: z.record(z.unknown()).optional().describe('Request body'),
|
|
489
|
+
},
|
|
490
|
+
},
|
|
491
|
+
handler: async ({ path, params, body, }) => {
|
|
492
|
+
return await this.executeRequest('POST', path, params, body);
|
|
493
|
+
},
|
|
494
|
+
isWriteTool: true,
|
|
495
|
+
});
|
|
496
|
+
// Tool 10: Execute PUT (FULL mode only)
|
|
497
|
+
this.registerTool({
|
|
498
|
+
context,
|
|
499
|
+
name: 'swagger_execute_put',
|
|
500
|
+
schema: {
|
|
501
|
+
description: 'Execute a PUT request (requires FULL mode)',
|
|
502
|
+
inputSchema: {
|
|
503
|
+
path: z.string().describe('API path'),
|
|
504
|
+
params: z.record(z.unknown()).optional().describe('Query/path parameters'),
|
|
505
|
+
body: z.record(z.unknown()).optional().describe('Request body'),
|
|
506
|
+
},
|
|
507
|
+
},
|
|
508
|
+
handler: async ({ path, params, body, }) => {
|
|
509
|
+
return await this.executeRequest('PUT', path, params, body);
|
|
510
|
+
},
|
|
511
|
+
isWriteTool: true,
|
|
512
|
+
});
|
|
513
|
+
// Tool 11: Execute PATCH (FULL mode only)
|
|
514
|
+
this.registerTool({
|
|
515
|
+
context,
|
|
516
|
+
name: 'swagger_execute_patch',
|
|
517
|
+
schema: {
|
|
518
|
+
description: 'Execute a PATCH request (requires FULL mode)',
|
|
519
|
+
inputSchema: {
|
|
520
|
+
path: z.string().describe('API path'),
|
|
521
|
+
params: z.record(z.unknown()).optional().describe('Query/path parameters'),
|
|
522
|
+
body: z.record(z.unknown()).optional().describe('Request body'),
|
|
523
|
+
},
|
|
524
|
+
},
|
|
525
|
+
handler: async ({ path, params, body, }) => {
|
|
526
|
+
return await this.executeRequest('PATCH', path, params, body);
|
|
527
|
+
},
|
|
528
|
+
isWriteTool: true,
|
|
529
|
+
});
|
|
530
|
+
// Tool 12: Execute DELETE (FULL mode only)
|
|
531
|
+
this.registerTool({
|
|
532
|
+
context,
|
|
533
|
+
name: 'swagger_execute_delete',
|
|
534
|
+
schema: {
|
|
535
|
+
description: 'Execute a DELETE request (requires FULL mode)',
|
|
536
|
+
inputSchema: {
|
|
537
|
+
path: z.string().describe('API path'),
|
|
538
|
+
params: z.record(z.unknown()).optional().describe('Query/path parameters'),
|
|
539
|
+
},
|
|
540
|
+
},
|
|
541
|
+
handler: async ({ path, params }) => {
|
|
542
|
+
return await this.executeRequest('DELETE', path, params);
|
|
543
|
+
},
|
|
544
|
+
isWriteTool: true,
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAkC,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAC3C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E,KAAK,EAAE,EACd,IAAI,EACJ,MAAM,EACN,IAAI,GAKL,EAAE,EAAE;gBACH,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;YAChE,CAAC;YACD,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;QAEH,2CAA2C;QAC3C,IAAI,CAAC,YAAY,CAAC;YAChB,OAAO;YACP,IAAI,EAAE,wBAAwB;YAC9B,MAAM,EAAE;gBACN,WAAW,EAAE,+CAA+C;gBAC5D,WAAW,EAAE;oBACX,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC;oBACrC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;iBAC3E;aACF;YACD,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAsD,EAAE,EAAE;gBACtF,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;YAC3D,CAAC;YACD,WAAW,EAAE,IAAI;SAClB,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PluginConfig } from '@nam088/mcp-core';
|
|
2
|
+
export interface SwaggerParserPluginConfig {
|
|
3
|
+
/**
|
|
4
|
+
* OpenAPI Specification URL or File Path
|
|
5
|
+
*/
|
|
6
|
+
url?: string;
|
|
7
|
+
/**
|
|
8
|
+
* JSON Object
|
|
9
|
+
*/
|
|
10
|
+
json?: Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Base URL for API calls (overrides spec servers)
|
|
13
|
+
*/
|
|
14
|
+
baseUrl?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Authentication token (Bearer token)
|
|
17
|
+
*/
|
|
18
|
+
authToken?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Default headers to include in all requests
|
|
21
|
+
*/
|
|
22
|
+
defaultHeaders?: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
export type SwaggerParserConfig = PluginConfig & {
|
|
25
|
+
config?: SwaggerParserPluginConfig;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE/B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;AAED,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG;IAC/C,MAAM,CAAC,EAAE,yBAAyB,CAAC;CACpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nam088/mcp-swagger-parser",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Enhanced OpenAPI/Swagger MCP plugin with 12 tools, YAML support, and auto-resolved schemas",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"mcp-swagger-parser": "./bin/server.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"clean": "rm -rf dist",
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"mcp",
|
|
17
|
+
"swagger",
|
|
18
|
+
"openapi",
|
|
19
|
+
"api",
|
|
20
|
+
"mcp-server",
|
|
21
|
+
"model-context-protocol",
|
|
22
|
+
"yaml",
|
|
23
|
+
"rest-api"
|
|
24
|
+
],
|
|
25
|
+
"author": "Nam088",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"type": "module",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/nam088/mcp-server.git",
|
|
31
|
+
"directory": "packages/swagger-parser"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"bin",
|
|
36
|
+
"README.md"
|
|
37
|
+
],
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/js-yaml": "^4.0.9",
|
|
40
|
+
"@types/node": "^20.0.0"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"axios": "^1.13.2",
|
|
44
|
+
"js-yaml": "^4.1.1",
|
|
45
|
+
"@nam088/mcp-core": "workspace:*",
|
|
46
|
+
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
47
|
+
"zod": "^3.24.1"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@nam088/mcp-core": "^1.0.0",
|
|
51
|
+
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
52
|
+
}
|
|
53
|
+
}
|