diff --git a/package.json b/package.json index ab67acc..68edd75 100644 --- a/package.json +++ b/package.json @@ -1,67 +1,67 @@ { - "name": "openapi-mcp-generator", - "version": "3.1.3", - "description": "Generates MCP server code from OpenAPI specifications", - "license": "MIT", - "author": "Harsha", - "type": "module", - "engines": { - "node": ">=20.0.0" - }, - "bin": { - "openapi-mcp-generator": "./bin/openapi-mcp-generator.js" - }, - "main": "dist/index.js", - "files": [ - "dist", - "bin", - "README.md", - "LICENSE" - ], - "types": "./dist/index.d.ts", - "scripts": { - "start": "node dist/index.js", - "clean": "rimraf dist", - "typecheck": "tsc --noEmit", - "build": "tsc && chmod 755 dist/index.js && chmod 755 bin/openapi-mcp-generator.js", - "version:patch": "npm version patch", - "version:minor": "npm version minor", - "version:major": "npm version major" - }, - "keywords": [ - "openapi", - "mcp", - "model-context-protocol", - "generator", - "llm", - "ai", - "api" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/harsha-iiiv/openapi-mcp-generator.git" - }, - "bugs": { - "url": "https://github.com/harsha-iiiv/openapi-mcp-generator/issues" - }, - "homepage": "https://github.com/harsha-iiiv/openapi-mcp-generator#readme", - "dependencies": { - "@apidevtools/swagger-parser": "^10.1.1", - "commander": "^13.1.0", - "openapi-types": "^12.1.3" - }, - "devDependencies": { - "@types/node": "^22.15.2", - "@typescript-eslint/eslint-plugin": "^8.31.0", - "@typescript-eslint/parser": "^8.31.0", - "eslint": "^9.25.1", - "prettier": "^3.5.3", - "rimraf": "^6.0.1", - "typescript": "^5.8.3" - }, - "peerDependencies": { - "@modelcontextprotocol/sdk": "^1.10.0", - "json-schema-to-zod": "^2.6.1", - "zod": "^3.24.3" - } + "name": "openapi-mcp-generator", + "version": "3.1.4", + "description": "Generates MCP server code from OpenAPI specifications", + "license": "MIT", + "author": "Harsha", + "type": "module", + "engines": { + "node": ">=20.0.0" + }, + "bin": { + "openapi-mcp-generator": "./bin/openapi-mcp-generator.js" + }, + "main": "dist/index.js", + "files": [ + "dist", + "bin", + "README.md", + "LICENSE" + ], + "types": "./dist/index.d.ts", + "scripts": { + "start": "node dist/index.js", + "clean": "rimraf dist", + "typecheck": "tsc --noEmit", + "build": "tsc && chmod 755 dist/index.js && chmod 755 bin/openapi-mcp-generator.js", + "version:patch": "npm version patch", + "version:minor": "npm version minor", + "version:major": "npm version major" + }, + "keywords": [ + "openapi", + "mcp", + "model-context-protocol", + "generator", + "llm", + "ai", + "api" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/harsha-iiiv/openapi-mcp-generator.git" + }, + "bugs": { + "url": "https://github.com/harsha-iiiv/openapi-mcp-generator/issues" + }, + "homepage": "https://github.com/harsha-iiiv/openapi-mcp-generator#readme", + "dependencies": { + "@apidevtools/swagger-parser": "^10.1.1", + "commander": "^13.1.0", + "openapi-types": "^12.1.3" + }, + "devDependencies": { + "@types/node": "^22.15.2", + "@typescript-eslint/eslint-plugin": "^8.31.0", + "@typescript-eslint/parser": "^8.31.0", + "eslint": "^9.25.1", + "prettier": "^3.5.3", + "rimraf": "^6.0.1", + "typescript": "^5.8.3" + }, + "peerDependencies": { + "@modelcontextprotocol/sdk": "^1.10.0", + "json-schema-to-zod": "^2.6.1", + "zod": "^3.24.3" + } } diff --git a/src/parser/extract-tools.ts b/src/parser/extract-tools.ts index 3b3e597..f50232e 100644 --- a/src/parser/extract-tools.ts +++ b/src/parser/extract-tools.ts @@ -31,10 +31,7 @@ export function extractToolsFromApi(api: OpenAPIV3.Document): McpToolDefinition[ if (!baseName) continue; // Sanitize the name to be MCP-compatible (only a-z, 0-9, _, -) - baseName = baseName - .replace(/\./g, '_') - .replace(/[^a-z0-9_-]/gi, '_') - .toLowerCase(); + baseName = baseName.replace(/\./g, '_').replace(/[^a-z0-9_-]/gi, '_'); let finalToolName = baseName; let counter = 1; @@ -174,7 +171,9 @@ export function mapOpenApiSchemaToJsonSchema( // Detect cycles if (seen.has(schema)) { - console.warn(`Cycle detected in schema${schema.title ? ` "${schema.title}"` : ''}, returning generic object to break recursion.`); + console.warn( + `Cycle detected in schema${schema.title ? ` "${schema.title}"` : ''}, returning generic object to break recursion.` + ); return { type: 'object' }; } seen.add(schema); @@ -212,7 +211,10 @@ export function mapOpenApiSchemaToJsonSchema( for (const [key, propSchema] of Object.entries(jsonSchema.properties)) { if (typeof propSchema === 'object' && propSchema !== null) { - mappedProps[key] = mapOpenApiSchemaToJsonSchema(propSchema as OpenAPIV3.SchemaObject, seen); + mappedProps[key] = mapOpenApiSchemaToJsonSchema( + propSchema as OpenAPIV3.SchemaObject, + seen + ); } else if (typeof propSchema === 'boolean') { mappedProps[key] = propSchema; }