swagger-doc-explorer-mcp 0.0.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/LICENSE +21 -0
- package/README.md +159 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +3 -0
- package/dist/constants.js.map +1 -0
- package/dist/formatters.d.ts +27 -0
- package/dist/formatters.d.ts.map +1 -0
- package/dist/formatters.js +163 -0
- package/dist/formatters.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +72 -0
- package/dist/index.js.map +1 -0
- package/dist/services/swagger-service.d.ts +21 -0
- package/dist/services/swagger-service.d.ts.map +1 -0
- package/dist/services/swagger-service.js +339 -0
- package/dist/services/swagger-service.js.map +1 -0
- package/dist/tools/info.d.ts +3 -0
- package/dist/tools/info.d.ts.map +1 -0
- package/dist/tools/info.js +161 -0
- package/dist/tools/info.js.map +1 -0
- package/dist/tools/load-spec.d.ts +3 -0
- package/dist/tools/load-spec.d.ts.map +1 -0
- package/dist/tools/load-spec.js +278 -0
- package/dist/tools/load-spec.js.map +1 -0
- package/dist/tools/paths.d.ts +3 -0
- package/dist/tools/paths.d.ts.map +1 -0
- package/dist/tools/paths.js +216 -0
- package/dist/tools/paths.js.map +1 -0
- package/dist/tools/schemas.d.ts +3 -0
- package/dist/tools/schemas.d.ts.map +1 -0
- package/dist/tools/schemas.js +142 -0
- package/dist/tools/schemas.js.map +1 -0
- package/dist/tools/search.d.ts +3 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +100 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/types.d.ts +139 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 anuoua
|
|
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,159 @@
|
|
|
1
|
+
# Swagger Doc Explorer MCP
|
|
2
|
+
|
|
3
|
+
MCP server for progressive exploration of Swagger/OpenAPI documentation. Supports **stdio** (local) and **HTTP** (remote) transports.
|
|
4
|
+
|
|
5
|
+
Each loaded spec is identified by a unique name (`{title} v{version}`) assigned at load time. All downstream tools reference the spec by name, so you can load and inspect multiple specs simultaneously.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | Description |
|
|
10
|
+
|------|-------------|
|
|
11
|
+
| `swagger_load_spec` | Load spec from a remote URL. `url` (required), `auth_header` (optional). Returns the assigned `spec_name` |
|
|
12
|
+
| `swagger_load_local_spec` | Load spec from a local JSON file. `file_path` (required). Returns the assigned `spec_name` |
|
|
13
|
+
| `swagger_list_loaded` | List all specs currently loaded (name, title, version, source) |
|
|
14
|
+
| `swagger_remove_spec` | Remove a loaded spec from memory. `spec_name` (required) |
|
|
15
|
+
| `swagger_get_info` | Get API title, version, description, server URL. `spec_name` (required) |
|
|
16
|
+
| `swagger_list_tags` | List all tags/groups with endpoint counts. `spec_name` (required) |
|
|
17
|
+
| `swagger_list_paths` | List endpoints, optionally filtered by `tag`. Supports `limit` (default 50) and `offset` pagination. `spec_name` (required) |
|
|
18
|
+
| `swagger_get_endpoint` | Drill into a specific endpoint: `path`, `method`. `spec_name` (required) |
|
|
19
|
+
| `swagger_list_schemas` | List all data models/schemas. Supports `limit` and `offset`. `spec_name` (required) |
|
|
20
|
+
| `swagger_get_schema` | Get full details of a specific schema: `schema_name`. `spec_name` (required) |
|
|
21
|
+
| `swagger_search` | Full-text search across endpoints and schemas: `query`. `spec_name` (required) |
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install -g swagger-doc-explorer-mcp
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or use directly with `npx` (no install needed):
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx -y swagger-doc-explorer-mcp
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
### stdio (default)
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npx -y swagger-doc-explorer-mcp
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### HTTP
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
SWAGGER_HTTP_PORT=3000 npx -y swagger-doc-explorer-mcp
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The HTTP server accepts POST requests at `/` following the [MCP Streamable HTTP](https://spec.modelcontextprotocol.io) protocol. Clients must include `Accept: application/json, text/event-stream` and use the `mcp-session-id` header for session affinity:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Initialize session
|
|
53
|
+
curl -X POST http://localhost:3000/ \
|
|
54
|
+
-H "Content-Type: application/json" \
|
|
55
|
+
-H "Accept: application/json, text/event-stream" \
|
|
56
|
+
-d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"my-client","version":"1.0"}}}'
|
|
57
|
+
|
|
58
|
+
# Copy the mcp-session-id from response headers, then:
|
|
59
|
+
curl -X POST http://localhost:3000/ \
|
|
60
|
+
-H "Content-Type: application/json" \
|
|
61
|
+
-H "Accept: application/json, text/event-stream" \
|
|
62
|
+
-H "mcp-session-id: <session-id>" \
|
|
63
|
+
-d '{"jsonrpc":"2.0","method":"notifications/initialized"}'
|
|
64
|
+
|
|
65
|
+
curl -X POST http://localhost:3000/ \
|
|
66
|
+
-H "Content-Type: application/json" \
|
|
67
|
+
-H "Accept: application/json, text/event-stream" \
|
|
68
|
+
-H "mcp-session-id: <session-id>" \
|
|
69
|
+
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"swagger_load_spec","arguments":{"url":"https://petstore.swagger.io/v2/swagger.json"}}}'
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Development
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm run dev # stdio mode with hot reload
|
|
76
|
+
npm run dev:http # HTTP mode on port 3000 with hot reload
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### MCP client configuration
|
|
80
|
+
|
|
81
|
+
Use `npx` so the client auto-installs the package:
|
|
82
|
+
|
|
83
|
+
**Claude Desktop** (`claude_desktop_config.json`):
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"mcpServers": {
|
|
88
|
+
"swagger-doc-explorer": {
|
|
89
|
+
"command": "npx",
|
|
90
|
+
"args": ["-y", "swagger-doc-explorer-mcp"]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**VS Code** (`.vscode/mcp.json`):
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"servers": {
|
|
101
|
+
"swagger-doc-explorer": {
|
|
102
|
+
"type": "stdio",
|
|
103
|
+
"command": "npx",
|
|
104
|
+
"args": ["-y", "swagger-doc-explorer-mcp"]
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
If installed globally, use `swagger-doc-explorer-mcp` directly as the command.
|
|
111
|
+
|
|
112
|
+
**opencode** (`~/.config/opencode/opencode.json`):
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"mcp": {
|
|
117
|
+
"swagger-doc-explorer": {
|
|
118
|
+
"type": "local",
|
|
119
|
+
"command": ["npx", "-y", "swagger-doc-explorer-mcp"],
|
|
120
|
+
"enabled": true
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Environment Variables
|
|
127
|
+
|
|
128
|
+
| Variable | Description |
|
|
129
|
+
|----------|-------------|
|
|
130
|
+
| `SWAGGER_HTTP_PORT` | Set to enable HTTP mode (e.g. `3000`). Omit for stdio mode |
|
|
131
|
+
|
|
132
|
+
## Progressive Exploration Workflow
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
1. swagger_load_spec / swagger_load_local_spec → load the API spec (returns spec_name)
|
|
136
|
+
2. swagger_get_info(spec_name="...") → overview of the API
|
|
137
|
+
3. swagger_list_tags(spec_name="...") → see available groups
|
|
138
|
+
4. swagger_list_paths(spec_name="...", tag="users") → browse endpoints in a group
|
|
139
|
+
5. swagger_get_endpoint(spec_name="...", path, method) → drill into endpoint details
|
|
140
|
+
6. swagger_list_schemas(spec_name="...") → see available data models
|
|
141
|
+
7. swagger_get_schema(spec_name="...", schema_name) → inspect a model
|
|
142
|
+
8. swagger_search(spec_name="...", query) → find anything across the spec
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Multiple specs can be loaded and queried simultaneously — each identified by its unique `spec_name`.
|
|
146
|
+
|
|
147
|
+
## Compatibility
|
|
148
|
+
|
|
149
|
+
- OpenAPI v3.x (`openapi` field)
|
|
150
|
+
- Swagger v2 (`swagger` field)
|
|
151
|
+
- JSON format only (YAML is not supported)
|
|
152
|
+
- Remote URLs and local file paths
|
|
153
|
+
|
|
154
|
+
## Build & Test
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
npm run build
|
|
158
|
+
npm test
|
|
159
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC,eAAO,MAAM,YAAY,uEAAwE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AAErC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAU,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { SchemaObject, ParameterObject } from "./types.js";
|
|
2
|
+
export declare function formatSchema(schema: SchemaObject, indent?: number): string;
|
|
3
|
+
export declare function formatEndpointDetail(endpoint: {
|
|
4
|
+
path: string;
|
|
5
|
+
method: string;
|
|
6
|
+
summary?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
operationId?: string;
|
|
9
|
+
tags?: string[];
|
|
10
|
+
deprecated?: boolean;
|
|
11
|
+
parameters?: ParameterObject[];
|
|
12
|
+
requestBody?: {
|
|
13
|
+
description?: string;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
content: Record<string, {
|
|
16
|
+
schema?: SchemaObject;
|
|
17
|
+
}>;
|
|
18
|
+
};
|
|
19
|
+
responses?: Record<string, {
|
|
20
|
+
description: string;
|
|
21
|
+
content?: Record<string, {
|
|
22
|
+
schema?: SchemaObject;
|
|
23
|
+
}>;
|
|
24
|
+
}>;
|
|
25
|
+
security?: Array<Record<string, string[]>>;
|
|
26
|
+
}): string;
|
|
27
|
+
//# sourceMappingURL=formatters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatters.d.ts","sourceRoot":"","sources":["../src/formatters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEhE,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,GAAE,MAAU,GAAG,MAAM,CAkF7E;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,eAAe,EAAE,CAAC;IAC/B,WAAW,CAAC,EAAE;QACZ,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,MAAM,CAAC,EAAE,YAAY,CAAA;SAAE,CAAC,CAAC;KACpD,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,MAAM,CAAC,EAAE,YAAY,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAC;IACzG,QAAQ,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;CAC5C,GAAG,MAAM,CAiGT"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
export function formatSchema(schema, indent = 0) {
|
|
2
|
+
const pad = " ".repeat(indent);
|
|
3
|
+
const parts = [];
|
|
4
|
+
if (schema.description) {
|
|
5
|
+
parts.push(`${pad}// ${schema.description}`);
|
|
6
|
+
}
|
|
7
|
+
if (schema.$ref) {
|
|
8
|
+
const refName = schema.$ref.split("/").pop() || schema.$ref;
|
|
9
|
+
parts.push(`${pad}$ref: "${refName}"`);
|
|
10
|
+
return parts.join("\n");
|
|
11
|
+
}
|
|
12
|
+
if (schema.enum) {
|
|
13
|
+
parts.push(`${pad}enum: [${schema.enum.map((v) => JSON.stringify(v)).join(", ")}]`);
|
|
14
|
+
return parts.join("\n");
|
|
15
|
+
}
|
|
16
|
+
if (schema.oneOf) {
|
|
17
|
+
parts.push(`${pad}oneOf:`);
|
|
18
|
+
for (const s of schema.oneOf) {
|
|
19
|
+
parts.push(formatSchema(s, indent + 1));
|
|
20
|
+
}
|
|
21
|
+
return parts.join("\n");
|
|
22
|
+
}
|
|
23
|
+
if (schema.anyOf) {
|
|
24
|
+
parts.push(`${pad}anyOf:`);
|
|
25
|
+
for (const s of schema.anyOf) {
|
|
26
|
+
parts.push(formatSchema(s, indent + 1));
|
|
27
|
+
}
|
|
28
|
+
return parts.join("\n");
|
|
29
|
+
}
|
|
30
|
+
if (schema.allOf) {
|
|
31
|
+
parts.push(`${pad}allOf:`);
|
|
32
|
+
for (const s of schema.allOf) {
|
|
33
|
+
parts.push(formatSchema(s, indent + 1));
|
|
34
|
+
}
|
|
35
|
+
return parts.join("\n");
|
|
36
|
+
}
|
|
37
|
+
const typeStr = schema.type || "any";
|
|
38
|
+
const formatStr = schema.format ? `<${schema.format}>` : "";
|
|
39
|
+
const nullableStr = schema.nullable ? " | null" : "";
|
|
40
|
+
parts.push(`${pad}type: ${typeStr}${formatStr}${nullableStr}`);
|
|
41
|
+
if (schema.properties) {
|
|
42
|
+
const required = new Set(schema.required || []);
|
|
43
|
+
for (const [propName, propSchema] of Object.entries(schema.properties)) {
|
|
44
|
+
const req = required.has(propName) ? " (required)" : "";
|
|
45
|
+
parts.push(`${pad}${propName}${req}:`);
|
|
46
|
+
parts.push(formatSchema(propSchema, indent + 1));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (schema.items) {
|
|
50
|
+
parts.push(`${pad}items:`);
|
|
51
|
+
parts.push(formatSchema(schema.items, indent + 1));
|
|
52
|
+
}
|
|
53
|
+
if (schema.additionalProperties && typeof schema.additionalProperties === "object") {
|
|
54
|
+
parts.push(`${pad}additionalProperties:`);
|
|
55
|
+
parts.push(formatSchema(schema.additionalProperties, indent + 1));
|
|
56
|
+
}
|
|
57
|
+
if (schema.example !== undefined) {
|
|
58
|
+
parts.push(`${pad}example: ${JSON.stringify(schema.example)}`);
|
|
59
|
+
}
|
|
60
|
+
if (schema.default !== undefined) {
|
|
61
|
+
parts.push(`${pad}default: ${JSON.stringify(schema.default)}`);
|
|
62
|
+
}
|
|
63
|
+
if (schema.minLength !== undefined)
|
|
64
|
+
parts.push(`${pad}minLength: ${schema.minLength}`);
|
|
65
|
+
if (schema.maxLength !== undefined)
|
|
66
|
+
parts.push(`${pad}maxLength: ${schema.maxLength}`);
|
|
67
|
+
if (schema.minimum !== undefined)
|
|
68
|
+
parts.push(`${pad}minimum: ${schema.minimum}`);
|
|
69
|
+
if (schema.maximum !== undefined)
|
|
70
|
+
parts.push(`${pad}maximum: ${schema.maximum}`);
|
|
71
|
+
if (schema.pattern)
|
|
72
|
+
parts.push(`${pad}pattern: ${schema.pattern}`);
|
|
73
|
+
return parts.join("\n");
|
|
74
|
+
}
|
|
75
|
+
export function formatEndpointDetail(endpoint) {
|
|
76
|
+
const lines = [];
|
|
77
|
+
lines.push(`# ${endpoint.method.toUpperCase()} ${endpoint.path}`);
|
|
78
|
+
if (endpoint.deprecated) {
|
|
79
|
+
lines.push("");
|
|
80
|
+
lines.push("> **DEPRECATED**");
|
|
81
|
+
}
|
|
82
|
+
if (endpoint.summary) {
|
|
83
|
+
lines.push("");
|
|
84
|
+
lines.push(endpoint.summary);
|
|
85
|
+
}
|
|
86
|
+
if (endpoint.description) {
|
|
87
|
+
lines.push("");
|
|
88
|
+
lines.push(endpoint.description);
|
|
89
|
+
}
|
|
90
|
+
if (endpoint.operationId) {
|
|
91
|
+
lines.push("");
|
|
92
|
+
lines.push(`**Operation ID**: \`${endpoint.operationId}\``);
|
|
93
|
+
}
|
|
94
|
+
if (endpoint.tags && endpoint.tags.length > 0) {
|
|
95
|
+
lines.push("");
|
|
96
|
+
lines.push(`**Tags**: ${endpoint.tags.map((t) => `\`${t}\``).join(", ")}`);
|
|
97
|
+
}
|
|
98
|
+
if (endpoint.parameters && endpoint.parameters.length > 0) {
|
|
99
|
+
lines.push("");
|
|
100
|
+
lines.push("## Parameters");
|
|
101
|
+
lines.push("");
|
|
102
|
+
lines.push("| Name | In | Type | Required | Description |");
|
|
103
|
+
lines.push("|------|----|------|----------|-------------|");
|
|
104
|
+
for (const param of endpoint.parameters) {
|
|
105
|
+
const typeStr = param.schema?.type || param.type || "string";
|
|
106
|
+
const requiredStr = param.required ? "Yes" : "No";
|
|
107
|
+
const desc = param.description || "";
|
|
108
|
+
lines.push(`| \`${param.name}\` | ${param.in} | ${typeStr} | ${requiredStr} | ${desc} |`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (endpoint.requestBody) {
|
|
112
|
+
lines.push("");
|
|
113
|
+
lines.push("## Request Body");
|
|
114
|
+
if (endpoint.requestBody.required) {
|
|
115
|
+
lines.push("> **Required**");
|
|
116
|
+
}
|
|
117
|
+
if (endpoint.requestBody.description) {
|
|
118
|
+
lines.push("");
|
|
119
|
+
lines.push(endpoint.requestBody.description);
|
|
120
|
+
}
|
|
121
|
+
for (const [contentType, mediaType] of Object.entries(endpoint.requestBody.content)) {
|
|
122
|
+
lines.push("");
|
|
123
|
+
lines.push(`**${contentType}**:`);
|
|
124
|
+
if (mediaType.schema) {
|
|
125
|
+
lines.push("```");
|
|
126
|
+
lines.push(formatSchema(mediaType.schema));
|
|
127
|
+
lines.push("```");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (endpoint.responses) {
|
|
132
|
+
lines.push("");
|
|
133
|
+
lines.push("## Responses");
|
|
134
|
+
for (const [statusCode, response] of Object.entries(endpoint.responses)) {
|
|
135
|
+
lines.push("");
|
|
136
|
+
lines.push(`### ${statusCode}`);
|
|
137
|
+
lines.push(response.description);
|
|
138
|
+
if (response.content) {
|
|
139
|
+
for (const [contentType, mediaType] of Object.entries(response.content)) {
|
|
140
|
+
lines.push("");
|
|
141
|
+
lines.push(`**${contentType}**:`);
|
|
142
|
+
if (mediaType.schema) {
|
|
143
|
+
lines.push("```");
|
|
144
|
+
lines.push(formatSchema(mediaType.schema));
|
|
145
|
+
lines.push("```");
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (endpoint.security && endpoint.security.length > 0) {
|
|
152
|
+
lines.push("");
|
|
153
|
+
lines.push("## Security");
|
|
154
|
+
for (const sec of endpoint.security) {
|
|
155
|
+
for (const [scheme, scopes] of Object.entries(sec)) {
|
|
156
|
+
const scopeStr = scopes.length > 0 ? ` [${scopes.join(", ")}]` : "";
|
|
157
|
+
lines.push(`- \`${scheme}\`${scopeStr}`);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return lines.join("\n");
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=formatters.js.map
|
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EAAE,CAAC;YACpC,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;gBACnD,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpE,KAAK,CAAC,IAAI,CAAC,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
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 { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
5
|
+
import { randomUUID } from "crypto";
|
|
6
|
+
import { createServer } from "http";
|
|
7
|
+
import { registerLoadSpecTools } from "./tools/load-spec.js";
|
|
8
|
+
import { registerPathsTools } from "./tools/paths.js";
|
|
9
|
+
import { registerSchemasTools } from "./tools/schemas.js";
|
|
10
|
+
import { registerInfoTools } from "./tools/info.js";
|
|
11
|
+
import { registerSearchTools } from "./tools/search.js";
|
|
12
|
+
const server = new McpServer({
|
|
13
|
+
name: "swagger-doc-explorer-mcp",
|
|
14
|
+
version: "1.0.0",
|
|
15
|
+
});
|
|
16
|
+
registerLoadSpecTools(server);
|
|
17
|
+
registerPathsTools(server);
|
|
18
|
+
registerSchemasTools(server);
|
|
19
|
+
registerInfoTools(server);
|
|
20
|
+
registerSearchTools(server);
|
|
21
|
+
async function startHttpServer(port) {
|
|
22
|
+
const transport = new StreamableHTTPServerTransport({
|
|
23
|
+
sessionIdGenerator: () => randomUUID(),
|
|
24
|
+
enableJsonResponse: true,
|
|
25
|
+
});
|
|
26
|
+
await server.connect(transport);
|
|
27
|
+
const httpServer = createServer(async (req, res) => {
|
|
28
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
29
|
+
res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
|
|
30
|
+
res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, mcp-session-id");
|
|
31
|
+
res.setHeader("Access-Control-Expose-Headers", "mcp-session-id");
|
|
32
|
+
if (req.method === "OPTIONS") {
|
|
33
|
+
res.writeHead(204);
|
|
34
|
+
res.end();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (req.method === "POST") {
|
|
38
|
+
try {
|
|
39
|
+
await transport.handleRequest(req, res);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
res.writeHead(400, { "Content-Type": "application/json" });
|
|
43
|
+
res.end(JSON.stringify({ error: "Invalid request" }));
|
|
44
|
+
}
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
res.writeHead(200, { "Content-Type": "text/plain" });
|
|
48
|
+
res.end("Swagger Doc Explorer MCP Server\n");
|
|
49
|
+
});
|
|
50
|
+
return new Promise((resolve) => {
|
|
51
|
+
httpServer.listen(port, () => {
|
|
52
|
+
console.error(`Swagger Doc Explorer MCP server running via HTTP on port ${port}`);
|
|
53
|
+
resolve();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async function main() {
|
|
58
|
+
const httpPort = process.env.SWAGGER_HTTP_PORT;
|
|
59
|
+
if (httpPort) {
|
|
60
|
+
await startHttpServer(parseInt(httpPort, 10));
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const transport = new StdioServerTransport();
|
|
64
|
+
await server.connect(transport);
|
|
65
|
+
console.error("Swagger Doc Explorer MCP server running via stdio");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
main().catch((error) => {
|
|
69
|
+
console.error("Server error:", error);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAExD,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;IAC3B,IAAI,EAAE,0BAA0B;IAChC,OAAO,EAAE,OAAO;CACjB,CAAC,CAAC;AAEH,qBAAqB,CAAC,MAAM,CAAC,CAAC;AAC9B,kBAAkB,CAAC,MAAM,CAAC,CAAC;AAC3B,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAC7B,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAC1B,mBAAmB,CAAC,MAAM,CAAC,CAAC;AAE5B,KAAK,UAAU,eAAe,CAAC,IAAY;IACzC,MAAM,SAAS,GAAG,IAA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;IAEH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;YAC3B,OAAO,CAAC,KAAK,CAAC,4DAA4D,IAAI,EAAE,CAAC,CAAC;YAClF,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IAE/C,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,eAAe,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;SAAM,CAAC;QACN,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAChC,OAAO,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACrE,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SpecStore, OperationObject, EndpointSummary, SchemaSummary, SearchResult, SchemaObject, HttpMethod } from "../types.js";
|
|
2
|
+
export declare function isLoaded(name: string): boolean;
|
|
3
|
+
export declare function getLoadedUrls(): string[];
|
|
4
|
+
export declare function getSpecKeys(): string[];
|
|
5
|
+
export declare function getSpec(name: string): SpecStore | undefined;
|
|
6
|
+
export declare function removeSpec(name: string): boolean;
|
|
7
|
+
export declare function loadSpecFromFile(filePath: string): Promise<SpecStore>;
|
|
8
|
+
export declare function loadSpec(url: string, authHeader?: string): Promise<SpecStore>;
|
|
9
|
+
export declare function getEndpoints(name: string, tag?: string): EndpointSummary[];
|
|
10
|
+
export declare function getEndpointDetail(name: string, path: string, method: HttpMethod): OperationObject | null;
|
|
11
|
+
export declare function getPathParameterNames(path: string): string[];
|
|
12
|
+
export declare function getSchemas(name: string): SchemaSummary[];
|
|
13
|
+
export declare function getSchemaDetail(name: string, schemaName: string): SchemaObject | null;
|
|
14
|
+
export declare function getTags(name: string): Array<{
|
|
15
|
+
name: string;
|
|
16
|
+
count: number;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function searchSpec(name: string, query: string): SearchResult[];
|
|
19
|
+
export declare function resolveRef(ref: string, name: string): unknown;
|
|
20
|
+
export declare function getServerUrl(name: string): string;
|
|
21
|
+
//# sourceMappingURL=swagger-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swagger-service.d.ts","sourceRoot":"","sources":["../../src/services/swagger-service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,SAAS,EAET,eAAe,EACf,eAAe,EACf,aAAa,EACb,YAAY,EACZ,YAAY,EAEZ,UAAU,EACX,MAAM,aAAa,CAAC;AAyBrB,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9C;AAED,wBAAgB,aAAa,IAAI,MAAM,EAAE,CAExC;AAED,wBAAgB,WAAW,IAAI,MAAM,EAAE,CAEtC;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAE3D;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CA8C3E;AAED,wBAAsB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAoFnF;AAED,wBAAgB,YAAY,CAAC,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