@tyvm/swagger-mcp 0.0.13 → 0.0.15

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.
Files changed (44) hide show
  1. package/README.md +7 -0
  2. package/dist/core/cache.d.ts +50 -0
  3. package/dist/core/cache.d.ts.map +1 -0
  4. package/dist/core/cache.js +104 -0
  5. package/dist/core/cache.js.map +1 -0
  6. package/dist/core/core.d.ts +11 -0
  7. package/dist/core/core.d.ts.map +1 -0
  8. package/dist/core/core.js +55 -0
  9. package/dist/core/core.js.map +1 -0
  10. package/dist/core/execute.d.ts +28 -0
  11. package/dist/core/execute.d.ts.map +1 -0
  12. package/dist/core/execute.js +158 -0
  13. package/dist/core/execute.js.map +1 -0
  14. package/dist/core/index.d.ts +30 -0
  15. package/dist/core/index.d.ts.map +1 -0
  16. package/dist/core/index.js +149 -0
  17. package/dist/core/index.js.map +1 -0
  18. package/dist/core/jsonrpc.d.ts +74 -0
  19. package/dist/core/jsonrpc.d.ts.map +1 -0
  20. package/dist/core/jsonrpc.js +148 -0
  21. package/dist/core/jsonrpc.js.map +1 -0
  22. package/dist/core/openapi.d.ts +20 -0
  23. package/dist/core/openapi.d.ts.map +1 -0
  24. package/dist/core/openapi.js +175 -0
  25. package/dist/core/openapi.js.map +1 -0
  26. package/dist/core/types.d.ts +126 -0
  27. package/dist/core/types.d.ts.map +1 -0
  28. package/dist/core/types.js +7 -0
  29. package/dist/core/types.js.map +1 -0
  30. package/dist/generator.d.ts +1 -3
  31. package/dist/generator.d.ts.map +1 -1
  32. package/dist/generator.js +8 -204
  33. package/dist/generator.js.map +1 -1
  34. package/dist/index.d.ts +4 -1
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +34 -0
  37. package/dist/index.js.map +1 -1
  38. package/dist/proxy-runtime.d.ts +27 -0
  39. package/dist/proxy-runtime.d.ts.map +1 -0
  40. package/dist/proxy-runtime.js +383 -0
  41. package/dist/proxy-runtime.js.map +1 -0
  42. package/dist/types.d.ts +6 -0
  43. package/dist/types.d.ts.map +1 -1
  44. package/package.json +1 -1
@@ -0,0 +1,74 @@
1
+ /**
2
+ * MCP JSON-RPC 2.0 protocol helpers
3
+ * Handles request/response formatting for the Model Context Protocol
4
+ */
5
+ import { Tool, SwaggerSpec } from './types';
6
+ import { DynamicSwaggerClient } from './execute';
7
+ /**
8
+ * JSON-RPC 2.0 request structure
9
+ */
10
+ export interface JsonRpcRequest {
11
+ jsonrpc: '2.0';
12
+ id?: string | number | null;
13
+ method: string;
14
+ params?: any;
15
+ }
16
+ /**
17
+ * JSON-RPC 2.0 response structure
18
+ * Note: MCP protocol requires id to be string | number, NOT null
19
+ */
20
+ export interface JsonRpcResponse {
21
+ jsonrpc: '2.0';
22
+ id: string | number;
23
+ result?: any;
24
+ error?: JsonRpcError;
25
+ }
26
+ /**
27
+ * JSON-RPC 2.0 error structure
28
+ */
29
+ export interface JsonRpcError {
30
+ code: number;
31
+ message: string;
32
+ data?: any;
33
+ }
34
+ /**
35
+ * Standard JSON-RPC error codes
36
+ */
37
+ export declare const JsonRpcErrorCodes: {
38
+ readonly PARSE_ERROR: -32700;
39
+ readonly INVALID_REQUEST: -32600;
40
+ readonly METHOD_NOT_FOUND: -32601;
41
+ readonly INVALID_PARAMS: -32602;
42
+ readonly INTERNAL_ERROR: -32603;
43
+ };
44
+ /**
45
+ * Create a JSON-RPC error response
46
+ * Note: If id is null/undefined, we use -1 as per MCP spec requirement
47
+ */
48
+ export declare function createErrorResponse(id: string | number | null | undefined, code: number, message: string, data?: any): JsonRpcResponse;
49
+ /**
50
+ * Create a JSON-RPC success response
51
+ * Note: If id is null/undefined, we use -1 as per MCP spec requirement
52
+ */
53
+ export declare function createSuccessResponse(id: string | number | null | undefined, result: any): JsonRpcResponse;
54
+ /**
55
+ * Validate a JSON-RPC request
56
+ */
57
+ export declare function validateJsonRpcRequest(request: any): JsonRpcError | null;
58
+ /**
59
+ * Handle MCP initialize request
60
+ */
61
+ export declare function handleInitialize(swaggerSpec: SwaggerSpec, requestId: string | number | null | undefined): JsonRpcResponse;
62
+ /**
63
+ * Handle MCP tools/list request
64
+ */
65
+ export declare function handleToolsList(tools: Tool[], requestId: string | number | null | undefined): JsonRpcResponse;
66
+ /**
67
+ * Handle MCP tools/call request
68
+ */
69
+ export declare function handleToolsCall(client: DynamicSwaggerClient, params: any, requestId: string | number | null | undefined): Promise<JsonRpcResponse>;
70
+ /**
71
+ * Route a JSON-RPC request to the appropriate handler
72
+ */
73
+ export declare function routeJsonRpcRequest(request: JsonRpcRequest, swaggerSpec: SwaggerSpec, tools: Tool[], client: DynamicSwaggerClient): Promise<JsonRpcResponse>;
74
+ //# sourceMappingURL=jsonrpc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonrpc.d.ts","sourceRoot":"","sources":["../../src/core/jsonrpc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,GAAG,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;CAMpB,CAAC;AAEX;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,GAAG,GACT,eAAe,CAUjB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,MAAM,EAAE,GAAG,GAAG,eAAe,CAM1G;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,GAAG,GAAG,YAAY,GAAG,IAAI,CAuBxE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,eAAe,CAWzH;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,eAAe,CAQ7G;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,GAAG,EACX,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAC5C,OAAO,CAAC,eAAe,CAAC,CAgC1B;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,cAAc,EACvB,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,IAAI,EAAE,EACb,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,eAAe,CAAC,CAoB1B"}
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ /**
3
+ * MCP JSON-RPC 2.0 protocol helpers
4
+ * Handles request/response formatting for the Model Context Protocol
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.routeJsonRpcRequest = exports.handleToolsCall = exports.handleToolsList = exports.handleInitialize = exports.validateJsonRpcRequest = exports.createSuccessResponse = exports.createErrorResponse = exports.JsonRpcErrorCodes = void 0;
8
+ /**
9
+ * Standard JSON-RPC error codes
10
+ */
11
+ exports.JsonRpcErrorCodes = {
12
+ PARSE_ERROR: -32700,
13
+ INVALID_REQUEST: -32600,
14
+ METHOD_NOT_FOUND: -32601,
15
+ INVALID_PARAMS: -32602,
16
+ INTERNAL_ERROR: -32603,
17
+ };
18
+ /**
19
+ * Create a JSON-RPC error response
20
+ * Note: If id is null/undefined, we use -1 as per MCP spec requirement
21
+ */
22
+ function createErrorResponse(id, code, message, data) {
23
+ return {
24
+ jsonrpc: '2.0',
25
+ id: id ?? -1,
26
+ error: {
27
+ code,
28
+ message,
29
+ data,
30
+ },
31
+ };
32
+ }
33
+ exports.createErrorResponse = createErrorResponse;
34
+ /**
35
+ * Create a JSON-RPC success response
36
+ * Note: If id is null/undefined, we use -1 as per MCP spec requirement
37
+ */
38
+ function createSuccessResponse(id, result) {
39
+ return {
40
+ jsonrpc: '2.0',
41
+ id: id ?? -1,
42
+ result,
43
+ };
44
+ }
45
+ exports.createSuccessResponse = createSuccessResponse;
46
+ /**
47
+ * Validate a JSON-RPC request
48
+ */
49
+ function validateJsonRpcRequest(request) {
50
+ if (!request || typeof request !== 'object') {
51
+ return {
52
+ code: exports.JsonRpcErrorCodes.INVALID_REQUEST,
53
+ message: 'Invalid Request: must be a JSON object',
54
+ };
55
+ }
56
+ if (!request.jsonrpc || request.jsonrpc !== '2.0') {
57
+ return {
58
+ code: exports.JsonRpcErrorCodes.INVALID_REQUEST,
59
+ message: 'Invalid Request: missing or invalid jsonrpc version',
60
+ };
61
+ }
62
+ if (!request.method || typeof request.method !== 'string') {
63
+ return {
64
+ code: exports.JsonRpcErrorCodes.INVALID_REQUEST,
65
+ message: 'Invalid Request: missing or invalid method',
66
+ };
67
+ }
68
+ return null;
69
+ }
70
+ exports.validateJsonRpcRequest = validateJsonRpcRequest;
71
+ /**
72
+ * Handle MCP initialize request
73
+ */
74
+ function handleInitialize(swaggerSpec, requestId) {
75
+ return createSuccessResponse(requestId, {
76
+ protocolVersion: '2024-11-05',
77
+ capabilities: {
78
+ tools: {},
79
+ },
80
+ serverInfo: {
81
+ name: `${swaggerSpec.info.title.toLowerCase().replace(/[^a-z0-9]/g, '-')}-mcp-proxy`,
82
+ version: swaggerSpec.info.version,
83
+ },
84
+ });
85
+ }
86
+ exports.handleInitialize = handleInitialize;
87
+ /**
88
+ * Handle MCP tools/list request
89
+ */
90
+ function handleToolsList(tools, requestId) {
91
+ return createSuccessResponse(requestId, {
92
+ tools: tools.map((tool) => ({
93
+ name: tool.name,
94
+ description: tool.description,
95
+ inputSchema: tool.inputSchema,
96
+ })),
97
+ });
98
+ }
99
+ exports.handleToolsList = handleToolsList;
100
+ /**
101
+ * Handle MCP tools/call request
102
+ */
103
+ async function handleToolsCall(client, params, requestId) {
104
+ const { name, arguments: args } = params || {};
105
+ if (!name) {
106
+ return createErrorResponse(requestId, exports.JsonRpcErrorCodes.INVALID_PARAMS, 'Invalid params: missing tool name');
107
+ }
108
+ try {
109
+ const result = await client.callOperation(name, args || {});
110
+ return createSuccessResponse(requestId, {
111
+ content: [
112
+ {
113
+ type: 'text',
114
+ text: typeof result === 'string' ? result : JSON.stringify(result, null, 2),
115
+ },
116
+ ],
117
+ });
118
+ }
119
+ catch (error) {
120
+ return createSuccessResponse(requestId, {
121
+ content: [
122
+ {
123
+ type: 'text',
124
+ text: error.message || 'Unknown error',
125
+ },
126
+ ],
127
+ });
128
+ }
129
+ }
130
+ exports.handleToolsCall = handleToolsCall;
131
+ /**
132
+ * Route a JSON-RPC request to the appropriate handler
133
+ */
134
+ async function routeJsonRpcRequest(request, swaggerSpec, tools, client) {
135
+ const requestId = request.id;
136
+ switch (request.method) {
137
+ case 'initialize':
138
+ return handleInitialize(swaggerSpec, requestId);
139
+ case 'tools/list':
140
+ return handleToolsList(tools, requestId);
141
+ case 'tools/call':
142
+ return await handleToolsCall(client, request.params, requestId);
143
+ default:
144
+ return createErrorResponse(requestId, exports.JsonRpcErrorCodes.METHOD_NOT_FOUND, `Method not found: ${request.method}`);
145
+ }
146
+ }
147
+ exports.routeJsonRpcRequest = routeJsonRpcRequest;
148
+ //# sourceMappingURL=jsonrpc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonrpc.js","sourceRoot":"","sources":["../../src/core/jsonrpc.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAmCH;;GAEG;AACU,QAAA,iBAAiB,GAAG;IAC/B,WAAW,EAAE,CAAC,KAAK;IACnB,eAAe,EAAE,CAAC,KAAK;IACvB,gBAAgB,EAAE,CAAC,KAAK;IACxB,cAAc,EAAE,CAAC,KAAK;IACtB,cAAc,EAAE,CAAC,KAAK;CACd,CAAC;AAEX;;;GAGG;AACH,SAAgB,mBAAmB,CACjC,EAAsC,EACtC,IAAY,EACZ,OAAe,EACf,IAAU;IAEV,OAAO;QACL,OAAO,EAAE,KAAK;QACd,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;QACZ,KAAK,EAAE;YACL,IAAI;YACJ,OAAO;YACP,IAAI;SACL;KACF,CAAC;AACJ,CAAC;AAfD,kDAeC;AAED;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,EAAsC,EAAE,MAAW;IACvF,OAAO;QACL,OAAO,EAAE,KAAK;QACd,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;QACZ,MAAM;KACP,CAAC;AACJ,CAAC;AAND,sDAMC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CAAC,OAAY;IACjD,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC3C,OAAO;YACL,IAAI,EAAE,yBAAiB,CAAC,eAAe;YACvC,OAAO,EAAE,wCAAwC;SAClD,CAAC;KACH;IAED,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,KAAK,KAAK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,EAAE,CACtC,CAAC;KACL;AACH,CAAC;AAzBD,kDAyBC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * OpenAPI/Swagger schema resolution and type conversion utilities
3
+ */
4
+ import { SwaggerSpec, ToolProp } from './types';
5
+ /**
6
+ * Resolve a JSON schema $ref to its actual schema definition
7
+ * Supports recursive refs and allOf merging
8
+ */
9
+ export declare function resolveSchemaRef(ref: string, swaggerSpec: SwaggerSpec): any;
10
+ /**
11
+ * Convert an OpenAPI/Swagger schema to MCP tool property format
12
+ * Handles refs, anyOf, oneOf, allOf, arrays, objects, and enums
13
+ */
14
+ export declare function convertSwaggerTypeToToolProp(swaggerType: any, swaggerSpec: SwaggerSpec): ToolProp;
15
+ /**
16
+ * Validate that a baseUrl is safe and matches the swagger spec servers
17
+ * Prevents SSRF attacks by ensuring the URL is in the spec and not a private IP
18
+ */
19
+ export declare function validateBaseUrl(baseUrl: string, swaggerSpec: SwaggerSpec): string | null;
20
+ //# sourceMappingURL=openapi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../src/core/openapi.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,GAAG,CAyD3E;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,GAAG,EAChB,WAAW,EAAE,WAAW,GACvB,QAAQ,CAsDV;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CA2DxF"}
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ /**
3
+ * OpenAPI/Swagger schema resolution and type conversion utilities
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.validateBaseUrl = exports.convertSwaggerTypeToToolProp = exports.resolveSchemaRef = void 0;
7
+ /**
8
+ * Resolve a JSON schema $ref to its actual schema definition
9
+ * Supports recursive refs and allOf merging
10
+ */
11
+ function resolveSchemaRef(ref, swaggerSpec) {
12
+ if (!ref.startsWith('#/')) {
13
+ return {};
14
+ }
15
+ const path = ref.substring(2).split('/');
16
+ let current = swaggerSpec;
17
+ for (const segment of path) {
18
+ if (!current || typeof current !== 'object') {
19
+ return {};
20
+ }
21
+ current = current[segment];
22
+ }
23
+ if (!current) {
24
+ return {};
25
+ }
26
+ // Handle allOf composition
27
+ if (current.allOf) {
28
+ const merged = {
29
+ type: 'object',
30
+ properties: {},
31
+ required: [],
32
+ };
33
+ for (const item of current.allOf) {
34
+ let resolvedItem;
35
+ if (item.$ref) {
36
+ resolvedItem = resolveSchemaRef(item.$ref, swaggerSpec);
37
+ }
38
+ else {
39
+ resolvedItem = item;
40
+ }
41
+ if (resolvedItem.properties) {
42
+ Object.assign(merged.properties, resolvedItem.properties);
43
+ }
44
+ if (resolvedItem.required) {
45
+ merged.required = [...merged.required, ...resolvedItem.required];
46
+ }
47
+ if (resolvedItem.type && resolvedItem.type !== 'object') {
48
+ merged.type = resolvedItem.type;
49
+ }
50
+ }
51
+ return merged;
52
+ }
53
+ // Handle nested $ref
54
+ if (current.$ref) {
55
+ return resolveSchemaRef(current.$ref, swaggerSpec);
56
+ }
57
+ return current;
58
+ }
59
+ exports.resolveSchemaRef = resolveSchemaRef;
60
+ /**
61
+ * Convert an OpenAPI/Swagger schema to MCP tool property format
62
+ * Handles refs, anyOf, oneOf, allOf, arrays, objects, and enums
63
+ */
64
+ function convertSwaggerTypeToToolProp(swaggerType, swaggerSpec) {
65
+ if (!swaggerType) {
66
+ return { type: 'string' };
67
+ }
68
+ // Resolve $ref if present
69
+ if (swaggerType.$ref) {
70
+ const resolvedSchema = resolveSchemaRef(swaggerType.$ref, swaggerSpec);
71
+ return convertSwaggerTypeToToolProp(resolvedSchema, swaggerSpec);
72
+ }
73
+ // Handle anyOf/oneOf/allOf by taking the first schema
74
+ if (swaggerType.anyOf || swaggerType.oneOf || swaggerType.allOf) {
75
+ const schemas = swaggerType.anyOf || swaggerType.oneOf || swaggerType.allOf;
76
+ if (schemas.length > 0) {
77
+ return convertSwaggerTypeToToolProp(schemas[0], swaggerSpec);
78
+ }
79
+ }
80
+ const toolProp = {
81
+ type: swaggerType.type || 'string',
82
+ description: swaggerType.description,
83
+ };
84
+ // Handle enum values
85
+ if (swaggerType.enum) {
86
+ toolProp.enum = swaggerType.enum;
87
+ }
88
+ // Handle array types
89
+ if (swaggerType.type === 'array' && swaggerType.items) {
90
+ toolProp.items = {
91
+ type: swaggerType.items.type || 'string',
92
+ };
93
+ if (swaggerType.items.properties) {
94
+ toolProp.items.properties = {};
95
+ for (const [key, value] of Object.entries(swaggerType.items.properties)) {
96
+ toolProp.items.properties[key] = convertSwaggerTypeToToolProp(value, swaggerSpec);
97
+ }
98
+ }
99
+ else if (swaggerType.items.$ref) {
100
+ toolProp.items = convertSwaggerTypeToToolProp(swaggerType.items, swaggerSpec);
101
+ }
102
+ }
103
+ // Handle object types with properties
104
+ if (swaggerType.type === 'object' && swaggerType.properties) {
105
+ toolProp.properties = {};
106
+ for (const [key, value] of Object.entries(swaggerType.properties)) {
107
+ toolProp.properties[key] = convertSwaggerTypeToToolProp(value, swaggerSpec);
108
+ }
109
+ }
110
+ return toolProp;
111
+ }
112
+ exports.convertSwaggerTypeToToolProp = convertSwaggerTypeToToolProp;
113
+ /**
114
+ * Validate that a baseUrl is safe and matches the swagger spec servers
115
+ * Prevents SSRF attacks by ensuring the URL is in the spec and not a private IP
116
+ */
117
+ function validateBaseUrl(baseUrl, swaggerSpec) {
118
+ try {
119
+ const url = new URL(baseUrl);
120
+ // Only allow https or http schemes
121
+ if (url.protocol !== 'https:' && url.protocol !== 'http:') {
122
+ return 'Invalid URL scheme: only http or https is allowed';
123
+ }
124
+ // Block localhost and private IP ranges
125
+ const hostname = url.hostname;
126
+ // Block localhost
127
+ if (hostname === 'localhost' ||
128
+ hostname === '127.0.0.1' ||
129
+ hostname === '::1' ||
130
+ hostname === '[::1]') {
131
+ return 'Invalid URL: localhost and loopback addresses are not allowed';
132
+ }
133
+ // Block private IP ranges (RFC1918)
134
+ const ipv4Pattern = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;
135
+ const match = hostname.match(ipv4Pattern);
136
+ if (match) {
137
+ const [, a, b, c, d] = match.map(Number);
138
+ // 10.0.0.0/8
139
+ if (a === 10)
140
+ return 'Invalid URL: private IP range not allowed';
141
+ // 172.16.0.0/12
142
+ if (a === 172 && b >= 16 && b <= 31)
143
+ return 'Invalid URL: private IP range not allowed';
144
+ // 192.168.0.0/16
145
+ if (a === 192 && b === 168)
146
+ return 'Invalid URL: private IP range not allowed';
147
+ // 169.254.0.0/16 (link-local)
148
+ if (a === 169 && b === 254)
149
+ return 'Invalid URL: private IP range not allowed';
150
+ }
151
+ // Check if baseUrl matches one of the servers in the swagger spec
152
+ if (!swaggerSpec.servers || swaggerSpec.servers.length === 0) {
153
+ return null; // No servers defined, allow any URL
154
+ }
155
+ const allowedUrls = swaggerSpec.servers
156
+ .map((s) => {
157
+ try {
158
+ return new URL(s.url).origin;
159
+ }
160
+ catch {
161
+ return null;
162
+ }
163
+ })
164
+ .filter(Boolean);
165
+ if (!allowedUrls.includes(url.origin)) {
166
+ return `Invalid baseUrl: must match one of the swagger spec servers: ${allowedUrls.join(', ')}`;
167
+ }
168
+ return null;
169
+ }
170
+ catch {
171
+ return 'Invalid URL format';
172
+ }
173
+ }
174
+ exports.validateBaseUrl = validateBaseUrl;
175
+ //# sourceMappingURL=openapi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi.js","sourceRoot":"","sources":["../../src/core/openapi.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAIH;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,GAAW,EAAE,WAA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AC9B;YAAC,MAAM;gBACN,OAAO,IAAI,CAAC;aACb;QACH,CAAC,CAAC;aACD,MAAM,CAAC,OAAO,CAAC,CAAC;QAEnB,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;YACrC,OAAO,gEAAgE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SACjG;QACD,OAAO,IAAI,CAAC;KACb;IAAC,MAAM;QACN,OAAO,oBAAoB,CAAC;KAC7B;AACH,CAAC;AA3DD,0CA2DC"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Core types for the swagger-mcp runtime
3
+ * These types are framework-agnostic and can be reused across projects
4
+ */
5
+ export interface ToolProp {
6
+ type: string;
7
+ description?: string;
8
+ enum?: string[];
9
+ items?: {
10
+ type: string;
11
+ properties?: {
12
+ [key: string]: ToolProp;
13
+ };
14
+ };
15
+ properties?: {
16
+ [key: string]: ToolProp;
17
+ };
18
+ }
19
+ export interface Tool {
20
+ name: string;
21
+ description: string;
22
+ inputSchema: {
23
+ type: 'object';
24
+ properties: {
25
+ [key: string]: ToolProp;
26
+ };
27
+ required: string[];
28
+ };
29
+ }
30
+ export interface SwaggerSpec {
31
+ swagger?: string;
32
+ openapi?: string;
33
+ host?: string;
34
+ basePath?: string;
35
+ schemes?: string[];
36
+ info: {
37
+ title: string;
38
+ version: string;
39
+ description?: string;
40
+ };
41
+ servers?: Array<{
42
+ url: string;
43
+ description?: string;
44
+ variables?: {
45
+ [key: string]: any;
46
+ };
47
+ }>;
48
+ paths: {
49
+ [path: string]: {
50
+ [method: string]: {
51
+ operationId?: string;
52
+ summary?: string;
53
+ description?: string;
54
+ parameters?: Array<{
55
+ name: string;
56
+ in: string;
57
+ required?: boolean;
58
+ schema?: any;
59
+ type?: string;
60
+ description?: string;
61
+ }>;
62
+ requestBody?: {
63
+ content: {
64
+ [mediaType: string]: {
65
+ schema: any;
66
+ };
67
+ };
68
+ };
69
+ responses?: any;
70
+ };
71
+ };
72
+ };
73
+ components?: {
74
+ schemas?: {
75
+ [name: string]: any;
76
+ };
77
+ };
78
+ definitions?: {
79
+ [name: string]: any;
80
+ };
81
+ }
82
+ /**
83
+ * Operation index entry for fast lookup
84
+ */
85
+ export interface OperationIndex {
86
+ operationId: string;
87
+ path: string;
88
+ method: string;
89
+ operation: any;
90
+ summary: string;
91
+ description: string;
92
+ }
93
+ /**
94
+ * Options for executing an HTTP operation
95
+ */
96
+ export interface ExecuteOptions {
97
+ baseUrl: string;
98
+ operationId: string;
99
+ parameters: Record<string, any>;
100
+ headers?: Record<string, string>;
101
+ }
102
+ /**
103
+ * Result of executing an HTTP operation
104
+ */
105
+ export interface ExecuteResult {
106
+ success: boolean;
107
+ data?: any;
108
+ error?: string;
109
+ }
110
+ /**
111
+ * Configuration for the swagger MCP runtime
112
+ */
113
+ export interface SwaggerMcpConfig {
114
+ swaggerSpec: SwaggerSpec;
115
+ baseUrl: string;
116
+ headers?: Record<string, string>;
117
+ allowedOperations?: string[];
118
+ }
119
+ /**
120
+ * Interface for swagger storage (must be implemented by consuming application)
121
+ */
122
+ export interface SwaggerStorage {
123
+ registerSwagger(swaggerDef: SwaggerSpec): Promise<string>;
124
+ getSwagger(swaggerHash: string): Promise<SwaggerSpec | null>;
125
+ }
126
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,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,EAA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AE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,eAAe,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1D,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;CAC9D"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Core types for the swagger-mcp runtime
4
+ * These types are framework-agnostic and can be reused across projects
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
@@ -11,14 +11,12 @@ export declare class SwaggerMcpGenerator {
11
11
  getApiBaseUrlPublic(): string;
12
12
  getSwaggerSpec(): SwaggerSpec;
13
13
  private getApiBaseUrl;
14
- private convertSwaggerTypeToToolProp;
15
- private resolveSchemaRef;
16
- private resolveSchemaRefOnce;
17
14
  generateTools(): Tool[];
18
15
  generateClientFunctions(): string;
19
16
  generateExpressComposition(): string;
20
17
  generateServerFactory(): string;
21
18
  generateMcpServer(): string;
22
19
  saveGeneratedFiles(outputDir?: string): Promise<void>;
20
+ generateProxyComposition(): string;
23
21
  }
24
22
  //# sourceMappingURL=generator.d.ts.map
@@ -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;AAItD,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,WAAW,CAAe;IAClC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAA8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