@tyvm/swagger-mcp 0.0.1 → 0.0.3
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 +24 -22
- package/dist/generator.d.ts +2 -1
- package/dist/generator.d.ts.map +1 -1
- package/dist/generator.js +122 -80
- package/dist/generator.js.map +1 -1
- package/dist/index.js +32 -10
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +14 -10
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -5,26 +5,28 @@ Generate MCP (Model Context Protocol) servers from Swagger/OpenAPI specification
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npx swagger-mcp
|
|
8
|
+
npx @tyvm/swagger-mcp <swagger-url> [output-dir] [--start-stdio]
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
By default, the output directory is generated based on the domain name of the swagger URL. For example, `https://api.dev.knowhow.tyvm.ai/docs/` would create `./generated/api_dev_knowhow_tyvm_ai/`.
|
|
12
|
+
|
|
11
13
|
### Examples
|
|
12
14
|
|
|
13
15
|
```bash
|
|
14
|
-
# Generate MCP server from Swagger spec
|
|
15
|
-
npx swagger-mcp
|
|
16
|
+
# Generate MCP server from Swagger spec (creates ./generated/api_example_com/)
|
|
17
|
+
npx @tyvm/swagger-mcp https://api.example.com/swagger.json
|
|
16
18
|
|
|
17
19
|
# Generate with custom output directory
|
|
18
|
-
npx swagger-mcp
|
|
20
|
+
npx @tyvm/swagger-mcp https://api.example.com/swagger.json ./my-mcp-server
|
|
19
21
|
|
|
20
|
-
# Generate and immediately start the server
|
|
21
|
-
npx swagger-mcp
|
|
22
|
+
# Generate and immediately start the server (creates ./generated/api_example_com/)
|
|
23
|
+
npx @tyvm/swagger-mcp https://api.example.com/swagger.json --start-stdio
|
|
22
24
|
|
|
23
25
|
# Generate with custom output directory and start the server
|
|
24
|
-
npx swagger-mcp
|
|
26
|
+
npx @tyvm/swagger-mcp https://api.example.com/swagger.json ./my-mcp-server --start-stdio
|
|
25
27
|
|
|
26
28
|
# Generate with authentication headers
|
|
27
|
-
HEADER_AUTHORIZATION="Bearer abc123" npx swagger-mcp
|
|
29
|
+
HEADER_AUTHORIZATION="Bearer abc123" npx @tyvm/swagger-mcp https://api.example.com/swagger.json
|
|
28
30
|
```
|
|
29
31
|
|
|
30
32
|
## Options
|
|
@@ -51,23 +53,23 @@ The tool creates:
|
|
|
51
53
|
|
|
52
54
|
## Using the Generated MCP Server
|
|
53
55
|
|
|
54
|
-
After generation:
|
|
56
|
+
After generation (assuming URL `https://api.example.com/swagger.json`):
|
|
55
57
|
|
|
56
|
-
1.
|
|
57
|
-
2.
|
|
58
|
-
3.
|
|
58
|
+
1. Navigate to the generated directory: `cd ./generated/api_example_com/`
|
|
59
|
+
2. Install dependencies: `npm install`
|
|
60
|
+
3. Build the project: `npm run build`
|
|
61
|
+
4. Add to your MCP client configuration:
|
|
59
62
|
|
|
60
63
|
```json
|
|
61
64
|
{
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
65
|
+
"name": "knowhow-web",
|
|
66
|
+
"command": "npx",
|
|
67
|
+
"args": [
|
|
68
|
+
"-y",
|
|
69
|
+
"@tyvm/swagger-mcp",
|
|
70
|
+
"https://api.dev.knowhow.tyvm.ai/docs/swagger.json",
|
|
71
|
+
"--start-stdio"
|
|
72
|
+
]
|
|
71
73
|
}
|
|
72
74
|
```
|
|
73
75
|
|
|
@@ -88,4 +90,4 @@ After generation:
|
|
|
88
90
|
|
|
89
91
|
## License
|
|
90
92
|
|
|
91
|
-
MIT
|
|
93
|
+
MIT
|
package/dist/generator.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Tool, SwaggerSpec } from
|
|
1
|
+
import { Tool, SwaggerSpec } from "./types";
|
|
2
2
|
export declare class SwaggerMcpGenerator {
|
|
3
3
|
private swaggerSpec;
|
|
4
4
|
private baseUrl;
|
|
@@ -6,6 +6,7 @@ export declare class SwaggerMcpGenerator {
|
|
|
6
6
|
constructor(swaggerUrl: string);
|
|
7
7
|
private setupHeaders;
|
|
8
8
|
loadSwaggerSpec(): Promise<SwaggerSpec>;
|
|
9
|
+
private getApiBaseUrl;
|
|
9
10
|
private convertSwaggerTypeToToolProp;
|
|
10
11
|
private resolveSchemaRef;
|
|
11
12
|
generateTools(): Tool[];
|
package/dist/generator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAY,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtD,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,WAAW,CAAe;IAClC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAA8B;gBAEjC,UAAU,EAAE,MAAM;IAK9B,OAAO,CAAC,YAAY;IAed,eAAe,IAAI,OAAO,CAAC,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAY,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtD,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,WAAW,CAAe;IAClC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAA8B;gBAEjC,UAAU,EAAE,MAAM;IAK9B,OAAO,CAAC,YAAY;IAed,eAAe,IAAI,OAAO,CAAC,WAAW,CAAC;IAqB7C,OAAO,CAAC,aAAa;IAuBrB,OAAO,CAAC,4BAA4B;IAwCpC,OAAO,CAAC,gBAAgB;IAsBxB,aAAa,IAAI,IAAI,EAAE;IAmGvB,uBAAuB,IAAI,MAAM;IAqFjC,iBAAiB,IAAI,MAAM;IAuGrB,kBAAkB,CAAC,SAAS,GAAE,MAAsB;CA4E3D"}
|
package/dist/generator.js
CHANGED
|
@@ -16,14 +16,14 @@ class SwaggerMcpGenerator {
|
|
|
16
16
|
setupHeaders() {
|
|
17
17
|
// Parse environment variables for headers starting with HEADER_
|
|
18
18
|
for (const [key, value] of Object.entries(process.env)) {
|
|
19
|
-
if (key.startsWith(
|
|
19
|
+
if (key.startsWith("HEADER_")) {
|
|
20
20
|
const headerName = key.substring(7); // Remove 'HEADER_' prefix
|
|
21
|
-
this.headers[headerName] = value ||
|
|
21
|
+
this.headers[headerName] = value || "";
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
// Special handling for HEADER_AUTHORIZATION
|
|
25
25
|
if (process.env.HEADER_AUTHORIZATION) {
|
|
26
|
-
this.headers[
|
|
26
|
+
this.headers["Authorization"] = process.env.HEADER_AUTHORIZATION;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
async loadSwaggerSpec() {
|
|
@@ -31,42 +31,64 @@ class SwaggerMcpGenerator {
|
|
|
31
31
|
console.log(`Loading Swagger spec from: ${this.baseUrl}`);
|
|
32
32
|
const response = await axios_1.default.get(this.baseUrl, {
|
|
33
33
|
headers: {
|
|
34
|
-
|
|
35
|
-
...this.headers
|
|
36
|
-
}
|
|
34
|
+
Accept: "application/json",
|
|
35
|
+
...this.headers,
|
|
36
|
+
},
|
|
37
37
|
});
|
|
38
38
|
this.swaggerSpec = response.data;
|
|
39
39
|
console.log(`Loaded Swagger spec: ${this.swaggerSpec.info.title} v${this.swaggerSpec.info.version}`);
|
|
40
40
|
return this.swaggerSpec;
|
|
41
41
|
}
|
|
42
42
|
catch (error) {
|
|
43
|
-
console.error(
|
|
43
|
+
console.error("Failed to load Swagger spec:", error.message);
|
|
44
44
|
throw error;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
getApiBaseUrl() {
|
|
48
|
+
// Extract the base URL from the swagger URL (remove the swagger.json path)
|
|
49
|
+
const swaggerUrl = new URL(this.baseUrl);
|
|
50
|
+
const baseUrl = `${swaggerUrl.protocol}//${swaggerUrl.host}`;
|
|
51
|
+
// Get the server path from the OpenAPI spec
|
|
52
|
+
let serverPath = '/';
|
|
53
|
+
if (this.swaggerSpec.servers && this.swaggerSpec.servers.length > 0) {
|
|
54
|
+
const firstServer = this.swaggerSpec.servers[0];
|
|
55
|
+
if (firstServer.url) {
|
|
56
|
+
// If it's a relative URL, use it as is
|
|
57
|
+
if (firstServer.url.startsWith('/')) {
|
|
58
|
+
serverPath = firstServer.url;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// If it's an absolute URL, extract the path
|
|
62
|
+
serverPath = new URL(firstServer.url).pathname;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return baseUrl + serverPath;
|
|
67
|
+
}
|
|
47
68
|
convertSwaggerTypeToToolProp(swaggerType) {
|
|
48
69
|
if (!swaggerType) {
|
|
49
|
-
return { type:
|
|
70
|
+
return { type: "string" };
|
|
50
71
|
}
|
|
51
72
|
const toolProp = {
|
|
52
|
-
type: swaggerType.type ||
|
|
53
|
-
description: swaggerType.description
|
|
73
|
+
type: swaggerType.type || "string",
|
|
74
|
+
description: swaggerType.description,
|
|
54
75
|
};
|
|
55
76
|
if (swaggerType.enum) {
|
|
56
77
|
toolProp.enum = swaggerType.enum;
|
|
57
78
|
}
|
|
58
|
-
if (swaggerType.type ===
|
|
79
|
+
if (swaggerType.type === "array" && swaggerType.items) {
|
|
59
80
|
toolProp.items = {
|
|
60
|
-
type: swaggerType.items.type ||
|
|
81
|
+
type: swaggerType.items.type || "string",
|
|
61
82
|
};
|
|
62
83
|
if (swaggerType.items.properties) {
|
|
63
84
|
toolProp.items.properties = {};
|
|
64
85
|
for (const [key, value] of Object.entries(swaggerType.items.properties)) {
|
|
65
|
-
toolProp.items.properties[key] =
|
|
86
|
+
toolProp.items.properties[key] =
|
|
87
|
+
this.convertSwaggerTypeToToolProp(value);
|
|
66
88
|
}
|
|
67
89
|
}
|
|
68
90
|
}
|
|
69
|
-
if (swaggerType.type ===
|
|
91
|
+
if (swaggerType.type === "object" && swaggerType.properties) {
|
|
70
92
|
toolProp.properties = {};
|
|
71
93
|
for (const [key, value] of Object.entries(swaggerType.properties)) {
|
|
72
94
|
toolProp.properties[key] = this.convertSwaggerTypeToToolProp(value);
|
|
@@ -76,24 +98,27 @@ class SwaggerMcpGenerator {
|
|
|
76
98
|
}
|
|
77
99
|
resolveSchemaRef(ref) {
|
|
78
100
|
// Handle OpenAPI 3.0 format
|
|
79
|
-
if (ref.startsWith(
|
|
80
|
-
const schemaName = ref.replace(
|
|
81
|
-
return this.swaggerSpec.components?.schemas?.[schemaName] || { type:
|
|
101
|
+
if (ref.startsWith("#/components/schemas/")) {
|
|
102
|
+
const schemaName = ref.replace("#/components/schemas/", "");
|
|
103
|
+
return (this.swaggerSpec.components?.schemas?.[schemaName] || { type: "string" });
|
|
82
104
|
}
|
|
83
105
|
// Handle Swagger 2.0 format
|
|
84
|
-
if (ref.startsWith(
|
|
85
|
-
const schemaName = ref.replace(
|
|
86
|
-
return this.swaggerSpec.definitions?.[schemaName] || {
|
|
106
|
+
if (ref.startsWith("#/definitions/")) {
|
|
107
|
+
const schemaName = ref.replace("#/definitions/", "");
|
|
108
|
+
return (this.swaggerSpec.definitions?.[schemaName] || {
|
|
109
|
+
type: "string",
|
|
110
|
+
});
|
|
87
111
|
}
|
|
88
|
-
return { type:
|
|
112
|
+
return { type: "string" };
|
|
89
113
|
}
|
|
90
114
|
generateTools() {
|
|
91
115
|
const tools = [];
|
|
92
116
|
for (const [path, pathItem] of Object.entries(this.swaggerSpec.paths)) {
|
|
93
117
|
for (const [method, operation] of Object.entries(pathItem)) {
|
|
94
|
-
if (typeof operation !==
|
|
118
|
+
if (typeof operation !== "object" || !operation)
|
|
95
119
|
continue;
|
|
96
|
-
const operationId = operation.operationId ||
|
|
120
|
+
const operationId = operation.operationId ||
|
|
121
|
+
`${method}_${path.replace(/[^a-zA-Z0-9]/g, "_")}`;
|
|
97
122
|
const summary = operation.summary || `${method.toUpperCase()} ${path}`;
|
|
98
123
|
const description = operation.description || summary;
|
|
99
124
|
const properties = {};
|
|
@@ -104,8 +129,8 @@ class SwaggerMcpGenerator {
|
|
|
104
129
|
for (const param of pathParams) {
|
|
105
130
|
const paramName = param.slice(1, -1); // Remove { and }
|
|
106
131
|
properties[paramName] = {
|
|
107
|
-
type:
|
|
108
|
-
description: `Path parameter: ${paramName}
|
|
132
|
+
type: "string",
|
|
133
|
+
description: `Path parameter: ${paramName}`,
|
|
109
134
|
};
|
|
110
135
|
required.push(paramName);
|
|
111
136
|
}
|
|
@@ -113,7 +138,7 @@ class SwaggerMcpGenerator {
|
|
|
113
138
|
// Add query parameters
|
|
114
139
|
if (operation.parameters) {
|
|
115
140
|
for (const param of operation.parameters) {
|
|
116
|
-
if (param.in ===
|
|
141
|
+
if (param.in === "query") {
|
|
117
142
|
// Handle OpenAPI 3.0 format (has schema property)
|
|
118
143
|
let schema = param.schema || param;
|
|
119
144
|
if (schema && schema.$ref) {
|
|
@@ -122,13 +147,15 @@ class SwaggerMcpGenerator {
|
|
|
122
147
|
else if (!schema || !schema.type) {
|
|
123
148
|
// Swagger 2.0 format (properties directly on param)
|
|
124
149
|
schema = {
|
|
125
|
-
type: param.type ||
|
|
126
|
-
description: param.description
|
|
150
|
+
type: param.type || "string",
|
|
151
|
+
description: param.description,
|
|
127
152
|
};
|
|
128
153
|
}
|
|
129
|
-
properties[param.name] =
|
|
154
|
+
properties[param.name] =
|
|
155
|
+
this.convertSwaggerTypeToToolProp(schema);
|
|
130
156
|
if (!properties[param.name].description) {
|
|
131
|
-
properties[param.name].description =
|
|
157
|
+
properties[param.name].description =
|
|
158
|
+
param.description || `Query parameter: ${param.name}`;
|
|
132
159
|
}
|
|
133
160
|
if (param.required) {
|
|
134
161
|
required.push(param.name);
|
|
@@ -139,7 +166,7 @@ class SwaggerMcpGenerator {
|
|
|
139
166
|
// Add request body properties
|
|
140
167
|
if (operation.requestBody) {
|
|
141
168
|
const content = operation.requestBody.content;
|
|
142
|
-
const jsonContent = content[
|
|
169
|
+
const jsonContent = content["application/json"];
|
|
143
170
|
if (jsonContent && jsonContent.schema) {
|
|
144
171
|
let schema = jsonContent.schema;
|
|
145
172
|
if (schema.$ref) {
|
|
@@ -156,16 +183,13 @@ class SwaggerMcpGenerator {
|
|
|
156
183
|
}
|
|
157
184
|
}
|
|
158
185
|
const tool = {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
required
|
|
167
|
-
}
|
|
168
|
-
}
|
|
186
|
+
name: operationId,
|
|
187
|
+
description: description,
|
|
188
|
+
inputSchema: {
|
|
189
|
+
type: "object",
|
|
190
|
+
properties,
|
|
191
|
+
required,
|
|
192
|
+
},
|
|
169
193
|
};
|
|
170
194
|
tools.push(tool);
|
|
171
195
|
}
|
|
@@ -211,9 +235,10 @@ export class SwaggerClient {
|
|
|
211
235
|
`;
|
|
212
236
|
for (const [path, pathItem] of Object.entries(this.swaggerSpec.paths)) {
|
|
213
237
|
for (const [method, operation] of Object.entries(pathItem)) {
|
|
214
|
-
if (typeof operation !==
|
|
238
|
+
if (typeof operation !== "object" || !operation)
|
|
215
239
|
continue;
|
|
216
|
-
const operationId = operation.operationId ||
|
|
240
|
+
const operationId = operation.operationId ||
|
|
241
|
+
`${method}_${path.replace(/[^a-zA-Z0-9]/g, "_")}`;
|
|
217
242
|
const hasRequestBody = operation.requestBody !== undefined;
|
|
218
243
|
clientCode += `
|
|
219
244
|
async ${operationId}(params: Record<string, any> = {}): Promise<any> {
|
|
@@ -229,10 +254,12 @@ export class SwaggerClient {
|
|
|
229
254
|
}
|
|
230
255
|
}
|
|
231
256
|
|
|
232
|
-
${hasRequestBody
|
|
257
|
+
${hasRequestBody
|
|
258
|
+
? `
|
|
233
259
|
const requestBody = { ...queryParams };
|
|
234
260
|
const response = await this.api.${method}(path, requestBody);
|
|
235
|
-
`
|
|
261
|
+
`
|
|
262
|
+
: `
|
|
236
263
|
const response = await this.api.${method}(path, { params: queryParams });
|
|
237
264
|
`}
|
|
238
265
|
|
|
@@ -248,6 +275,8 @@ export class SwaggerClient {
|
|
|
248
275
|
}
|
|
249
276
|
generateMcpServer() {
|
|
250
277
|
const tools = this.generateTools();
|
|
278
|
+
const swaggerUrl = this.baseUrl;
|
|
279
|
+
const apiBaseUrl = this.getApiBaseUrl();
|
|
251
280
|
return `#!/usr/bin/env node
|
|
252
281
|
|
|
253
282
|
import { SwaggerClient } from './client';
|
|
@@ -256,7 +285,9 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
|
256
285
|
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
257
286
|
|
|
258
287
|
const server = new Server({
|
|
259
|
-
name: '${this.swaggerSpec.info.title
|
|
288
|
+
name: '${this.swaggerSpec.info.title
|
|
289
|
+
.toLowerCase()
|
|
290
|
+
.replace(/[^a-z0-9]/g, "-")}-mcp',
|
|
260
291
|
version: '${this.swaggerSpec.info.version}'
|
|
261
292
|
}, {
|
|
262
293
|
capabilities: {
|
|
@@ -273,14 +304,11 @@ for (const [key, value] of Object.entries(process.env)) {
|
|
|
273
304
|
}
|
|
274
305
|
}
|
|
275
306
|
|
|
276
|
-
const swaggerUrl =
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
307
|
+
const swaggerUrl = '${swaggerUrl}';
|
|
308
|
+
const apiBaseUrl = '${apiBaseUrl}';
|
|
309
|
+
const client = new SwaggerClient(apiBaseUrl, headers);
|
|
310
|
+
|
|
281
311
|
|
|
282
|
-
const baseUrl = swaggerUrl.replace(/\\/swagger\\.json$/, '').replace(/\\/docs$/, '');
|
|
283
|
-
const client = new SwaggerClient(baseUrl, headers);
|
|
284
312
|
|
|
285
313
|
// Helper function to format responses consistently
|
|
286
314
|
const formatResponse = async (methodName: string, args: any) => {
|
|
@@ -307,8 +335,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
307
335
|
const { name, arguments: args } = request.params as any;
|
|
308
336
|
|
|
309
337
|
switch (name) {
|
|
310
|
-
${tools
|
|
311
|
-
|
|
338
|
+
${tools
|
|
339
|
+
.map((tool) => ` case '${tool.name}':
|
|
340
|
+
return formatResponse('${tool.name}', args);`)
|
|
341
|
+
.join("\n")}
|
|
312
342
|
default:
|
|
313
343
|
throw new Error(\`Unknown tool: \${name}\`);
|
|
314
344
|
}
|
|
@@ -316,7 +346,15 @@ ${tools.map(tool => ` case '${tool.function.name}':
|
|
|
316
346
|
|
|
317
347
|
server.setRequestHandler(ListToolsRequestSchema, async (request) => {
|
|
318
348
|
return {
|
|
319
|
-
tools:
|
|
349
|
+
tools: [
|
|
350
|
+
${tools
|
|
351
|
+
.map((tool) => ` {
|
|
352
|
+
name: '${tool.name}',
|
|
353
|
+
description: '${tool.description}',
|
|
354
|
+
inputSchema: ${JSON.stringify(tool.inputSchema, null, 8)}
|
|
355
|
+
}`)
|
|
356
|
+
.join(",\n")}
|
|
357
|
+
]
|
|
320
358
|
};
|
|
321
359
|
});
|
|
322
360
|
|
|
@@ -329,13 +367,13 @@ async function main() {
|
|
|
329
367
|
main().catch(console.error);
|
|
330
368
|
`;
|
|
331
369
|
}
|
|
332
|
-
async saveGeneratedFiles(outputDir =
|
|
370
|
+
async saveGeneratedFiles(outputDir = "./generated") {
|
|
333
371
|
// Create output directory if it doesn't exist
|
|
334
372
|
if (!(0, fs_1.existsSync)(outputDir)) {
|
|
335
373
|
(0, fs_1.mkdirSync)(outputDir, { recursive: true });
|
|
336
374
|
}
|
|
337
375
|
// Create src directory
|
|
338
|
-
const srcDir = (0, path_1.join)(outputDir,
|
|
376
|
+
const srcDir = (0, path_1.join)(outputDir, "src");
|
|
339
377
|
if (!(0, fs_1.existsSync)(srcDir)) {
|
|
340
378
|
(0, fs_1.mkdirSync)(srcDir, { recursive: true });
|
|
341
379
|
}
|
|
@@ -344,43 +382,47 @@ main().catch(console.error);
|
|
|
344
382
|
const mcpServer = this.generateMcpServer();
|
|
345
383
|
// Generate package.json for the output
|
|
346
384
|
const packageJson = {
|
|
347
|
-
name: `${this.swaggerSpec.info.title
|
|
348
|
-
|
|
349
|
-
|
|
385
|
+
name: `${this.swaggerSpec.info.title
|
|
386
|
+
.toLowerCase()
|
|
387
|
+
.replace(/[^a-z0-9]/g, "-")}-mcp`,
|
|
388
|
+
version: "1.0.0",
|
|
389
|
+
main: "dist/mcp-server.js",
|
|
350
390
|
scripts: {
|
|
351
|
-
start:
|
|
352
|
-
build:
|
|
391
|
+
start: "node dist/mcp-server.js",
|
|
392
|
+
build: "tsc",
|
|
353
393
|
},
|
|
354
394
|
dependencies: {
|
|
355
|
-
|
|
356
|
-
|
|
395
|
+
"@modelcontextprotocol/sdk": "^1.13.3",
|
|
396
|
+
axios: "^1.5.0",
|
|
357
397
|
},
|
|
358
398
|
devDependencies: {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
}
|
|
399
|
+
"@types/node": "^20.6.3",
|
|
400
|
+
typescript: "^4.6.3",
|
|
401
|
+
},
|
|
362
402
|
};
|
|
363
403
|
// Generate TypeScript config
|
|
364
404
|
const tsConfig = {
|
|
365
405
|
compilerOptions: {
|
|
366
|
-
target:
|
|
367
|
-
module:
|
|
368
|
-
lib: [
|
|
369
|
-
outDir:
|
|
370
|
-
rootDir:
|
|
406
|
+
target: "es2020",
|
|
407
|
+
module: "commonjs",
|
|
408
|
+
lib: ["es2020"],
|
|
409
|
+
outDir: "./dist",
|
|
410
|
+
rootDir: "./src",
|
|
371
411
|
strict: true,
|
|
372
412
|
esModuleInterop: true,
|
|
373
413
|
skipLibCheck: true,
|
|
374
|
-
forceConsistentCasingInFileNames: true
|
|
414
|
+
forceConsistentCasingInFileNames: true,
|
|
375
415
|
},
|
|
376
|
-
include: [
|
|
377
|
-
exclude: [
|
|
416
|
+
include: ["src/**/*"],
|
|
417
|
+
exclude: ["node_modules", "dist"],
|
|
378
418
|
};
|
|
379
419
|
// Save all files
|
|
380
|
-
(0, fs_1.writeFileSync)((0, path_1.join)(outputDir,
|
|
381
|
-
(0, fs_1.writeFileSync)((0, path_1.join)(outputDir,
|
|
382
|
-
(0, fs_1.writeFileSync)((0, path_1.join)(srcDir,
|
|
383
|
-
(0, fs_1.writeFileSync)((0, path_1.join)(srcDir,
|
|
420
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(outputDir, "package.json"), JSON.stringify(packageJson, null, 2));
|
|
421
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(outputDir, "tsconfig.json"), JSON.stringify(tsConfig, null, 2));
|
|
422
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(srcDir, "client.ts"), clientCode);
|
|
423
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(srcDir, "mcp-server.ts"), mcpServer);
|
|
424
|
+
// Also write the root-level mcp-server.ts for convenience
|
|
425
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(outputDir, "mcp-server.ts"), mcpServer);
|
|
384
426
|
console.log(`Generated files saved to ${outputDir}/`);
|
|
385
427
|
console.log(`- package.json: Project configuration`);
|
|
386
428
|
console.log(`- tsconfig.json: TypeScript configuration`);
|
package/dist/generator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,2BAA0D;AAC1D,+BAA4B;AAG5B,MAAa,mBAAmB;IAK9B,YAAY,UAAkB;QAFtB,YAAO,GAA2B,EAAE,CAAC;QAG3C,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC;QAC1B,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAEO,YAAY;QAClB,gEAAgE;QAChE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,O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CAAC,UAAU,CAAC;YACrB,OAAO,EAAE,CAAC,cAAc,EAAE,MAAM,CAAC;SAClC,CAAC;QAEF,iBAAiB;QACjB,IAAA,kBAAa,EACX,IAAA,WAAI,EAAC,SAAS,EAAE,cAAc,CAAC,EAC/B,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CACrC,CAAC;QACF,IAAA,kBAAa,EACX,IAAA,WAAI,EAAC,SAAS,EAAE,eAAe,CAAC,EAChC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAClC,CAAC;QACF,IAAA,kBAAa,EAAC,IAAA,WAAI,EAAC,MAAM,EAAE,WAAW,CAAC,EAAE,UAAU,CAAC,CAAC;QACrD,IAAA,kBAAa,EAAC,IAAA,WAAI,EAAC,MAAM,EAAE,eAAe,CAAC,EAAE,SAAS,CAAC,CAAC;QAExD,0DAA0D;QAC1D,IAAA,kBAAa,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,eAAe,CAAC,EAAE,SAAS,CAAC,CAAC;QAE3D,OAAO,CAAC,GAAG,CAAC,4BAA4B,SAAS,GAAG,CAAC,CAAC;QACtD,OAAO,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;QACrD,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;QACzD,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;QACtD,OAAO,CAAC,GAAG,CAAC,yDAAyD,CAAC,CAAC;QACvE,OAAO,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;IACrE,CAAC;CACF;AA9eD,kDA8eC"}
|
package/dist/index.js
CHANGED
|
@@ -5,10 +5,27 @@ const child_process_1 = require("child_process");
|
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const fs_1 = require("fs");
|
|
7
7
|
const generator_1 = require("./generator");
|
|
8
|
+
function generateDomainBasedDir(swaggerUrl, packageDir) {
|
|
9
|
+
try {
|
|
10
|
+
const url = new URL(swaggerUrl);
|
|
11
|
+
// Extract hostname and convert to valid directory name
|
|
12
|
+
const hostname = url.hostname;
|
|
13
|
+
// Replace dots and other special characters with underscores
|
|
14
|
+
const sanitizedDomain = hostname.replace(/[^a-zA-Z0-9]/g, '_');
|
|
15
|
+
return (0, path_1.join)(packageDir, 'generated', sanitizedDomain);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
// If URL parsing fails, fall back to generic generated directory
|
|
19
|
+
console.warn('Failed to parse URL for domain-based directory, using generic "generated" directory');
|
|
20
|
+
return (0, path_1.join)(packageDir, 'generated');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
8
23
|
function parseArgs(args) {
|
|
24
|
+
// Get the directory where this package is installed
|
|
25
|
+
const packageDir = (0, path_1.dirname)((0, path_1.dirname)(__filename));
|
|
9
26
|
const parsed = {
|
|
10
27
|
swaggerUrl: '',
|
|
11
|
-
outputDir: '
|
|
28
|
+
outputDir: '',
|
|
12
29
|
startStdio: false
|
|
13
30
|
};
|
|
14
31
|
// Filter out the --start-stdio flag first
|
|
@@ -23,6 +40,10 @@ function parseArgs(args) {
|
|
|
23
40
|
for (let i = 0; i < filteredArgs.length; i++) {
|
|
24
41
|
if (!parsed.swaggerUrl) {
|
|
25
42
|
parsed.swaggerUrl = filteredArgs[i];
|
|
43
|
+
// Set default output directory based on the swagger URL
|
|
44
|
+
if (!parsed.outputDir) {
|
|
45
|
+
parsed.outputDir = generateDomainBasedDir(parsed.swaggerUrl, packageDir);
|
|
46
|
+
}
|
|
26
47
|
}
|
|
27
48
|
else {
|
|
28
49
|
// Second non-flag argument is the output directory
|
|
@@ -30,9 +51,10 @@ function parseArgs(args) {
|
|
|
30
51
|
break; // Only take the first two non-flag arguments
|
|
31
52
|
}
|
|
32
53
|
}
|
|
54
|
+
console.log(`Default output directory: ${parsed.outputDir}`);
|
|
33
55
|
return parsed;
|
|
34
56
|
}
|
|
35
|
-
async function buildAndRunServer(outputDir
|
|
57
|
+
async function buildAndRunServer(outputDir) {
|
|
36
58
|
console.log('\n🏗️ Building generated server...');
|
|
37
59
|
// Resolve the output directory to an absolute path to avoid duplication
|
|
38
60
|
const resolvedOutputDir = (0, path_1.resolve)(outputDir);
|
|
@@ -90,7 +112,7 @@ async function buildAndRunServer(outputDir, swaggerUrl) {
|
|
|
90
112
|
if (!(0, fs_1.existsSync)(serverPath)) {
|
|
91
113
|
throw new Error(`Built server not found at ${serverPath}`);
|
|
92
114
|
}
|
|
93
|
-
const serverProcess = (0, child_process_1.spawn)('node', [serverPath
|
|
115
|
+
const serverProcess = (0, child_process_1.spawn)('node', [serverPath], {
|
|
94
116
|
cwd: resolvedOutputDir,
|
|
95
117
|
stdio: 'inherit'
|
|
96
118
|
});
|
|
@@ -114,17 +136,17 @@ async function buildAndRunServer(outputDir, swaggerUrl) {
|
|
|
114
136
|
async function main() {
|
|
115
137
|
const args = process.argv.slice(2);
|
|
116
138
|
if (args.length === 0) {
|
|
117
|
-
console.error('Usage: npx swagger-mcp
|
|
139
|
+
console.error('Usage: npx @tyvm/swagger-mcp <swagger-url> [output-dir] [--start-stdio]');
|
|
118
140
|
console.error('');
|
|
119
141
|
console.error('Environment variables:');
|
|
120
142
|
console.error(' HEADER_AUTHORIZATION=Bearer <token> - Set Authorization header');
|
|
121
143
|
console.error(' HEADER_<NAME>=<value> - Set custom header');
|
|
122
144
|
console.error('');
|
|
123
145
|
console.error('Examples:');
|
|
124
|
-
console.error(' npx swagger-mcp
|
|
125
|
-
console.error(' npx swagger-mcp
|
|
126
|
-
console.error(' npx swagger-mcp
|
|
127
|
-
console.error(' HEADER_AUTHORIZATION="Bearer abc123" npx swagger-mcp
|
|
146
|
+
console.error(' npx @tyvm/swagger-mcp https://api.example.com/swagger.json');
|
|
147
|
+
console.error(' npx @tyvm/swagger-mcp https://api.example.com/swagger.json --start-stdio');
|
|
148
|
+
console.error(' npx @tyvm/swagger-mcp https://api.example.com/swagger.json ./my-output --start-stdio');
|
|
149
|
+
console.error(' HEADER_AUTHORIZATION="Bearer abc123" npx @tyvm/swagger-mcp https://api.example.com/swagger.json');
|
|
128
150
|
process.exit(1);
|
|
129
151
|
}
|
|
130
152
|
const { swaggerUrl, outputDir, startStdio } = parseArgs(args);
|
|
@@ -138,7 +160,7 @@ async function main() {
|
|
|
138
160
|
if (startStdio) {
|
|
139
161
|
console.log('Generation complete! Starting server...');
|
|
140
162
|
// Build and run the server
|
|
141
|
-
await buildAndRunServer(outputDir
|
|
163
|
+
await buildAndRunServer(outputDir);
|
|
142
164
|
}
|
|
143
165
|
else {
|
|
144
166
|
console.log('Generation complete!');
|
|
@@ -153,7 +175,7 @@ async function main() {
|
|
|
153
175
|
console.log(' "servers": {');
|
|
154
176
|
console.log(' "my-api": {');
|
|
155
177
|
console.log(' "command": "node",');
|
|
156
|
-
console.log(` "args": ["${outputDir}/dist/mcp-server.js"
|
|
178
|
+
console.log(` "args": ["${outputDir}/dist/mcp-server.js"],`);
|
|
157
179
|
console.log(' "env": {');
|
|
158
180
|
console.log(' "HEADER_AUTHORIZATION": "Bearer your-token-here"');
|
|
159
181
|
console.log(' }');
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,iDAAsC;AACtC,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAEA,iDAAsC;AACtC,+BAA8C;AAC9C,2BAAgC;AAChC,2CAAkD;AAQlD,SAAS,sBAAsB,CAAC,UAAkB,EAAE,UAAkB;IACpE,IAAI;QACF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;QAChC,uDAAuD;QACvD,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;QAC9B,6DAA6D;QAC7D,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,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ACR"}
|
package/dist/types.d.ts
CHANGED
|
@@ -13,17 +13,14 @@ export interface ToolProp {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
export interface Tool {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
properties: {
|
|
23
|
-
[key: string]: ToolProp;
|
|
24
|
-
};
|
|
25
|
-
required: string[];
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: 'object';
|
|
20
|
+
properties: {
|
|
21
|
+
[key: string]: ToolProp;
|
|
26
22
|
};
|
|
23
|
+
required: string[];
|
|
27
24
|
};
|
|
28
25
|
}
|
|
29
26
|
export interface SwaggerSpec {
|
|
@@ -32,6 +29,13 @@ export interface SwaggerSpec {
|
|
|
32
29
|
version: string;
|
|
33
30
|
description?: string;
|
|
34
31
|
};
|
|
32
|
+
servers?: Array<{
|
|
33
|
+
url: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
variables?: {
|
|
36
|
+
[key: string]: any;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
35
39
|
paths: {
|
|
36
40
|
[path: string]: {
|
|
37
41
|
[method: string]: {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,CAAC,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAA;SAAE,CAAC;KAC1C,CAAC;IACF,UAAU,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,Q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,CAAC,EAAE,MAAM,CAAC;gBACrB,OAAO,CAAC,EAAE,MAAM,CAAC;gBACjB,WAAW,CAAC,EAAE,MAAM,CAAC;gBACrB,UAAU,CAAC,EAAE,KAAK,CAAC;oBACjB,IAAI,EAAE,MAAM,CAAC;oBACb,EAAE,EAAE,MAAM,CAAC;oBACX,QAAQ,CAAC,EAAE,OAAO,CAAC;oBACnB,MAAM,CAAC,EAAE,GAAG,CAAC;oBACb,IAAI,CAAC,EAAE,MAAM,CAAC;oBACd,WAAW,CAAC,EAAE,MAAM,CAAC;iBACtB,CAAC,CAAC;gBACH,WAAW,CAAC,EAAE;oBACZ,OAAO,EAAE;wBACP,CAAC,SAAS,EAAE,MAAM,GAAG;4BACnB,MAAM,EAAE,GAAG,CAAC;yBACb,CAAC;qBACH,CAAC;iBACH,CAAC;aACH,CAAC;SACH,CAAC;KACH,CAAC;IACF,UAAU,CAAC,EAAE;QACX,OAAO,CAAC,EAAE;YACR,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;SACrB,CAAC;KACH,CAAC;IACF,WAAW,CAAC,EAAE;QACZ,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;KACrB,CAAC;CACH"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tyvm/swagger-mcp",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Generate MCP servers from Swagger/OpenAPI specifications",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
|
-
"swagger-mcp": "dist/index.js"
|
|
7
|
+
"@tyvm/swagger-mcp": "dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "tsc",
|