|
32 | 32 |
|
33 | 33 | ## ⚠️ Version Information & Breaking Changes
|
34 | 34 |
|
35 |
| -### v1.3.0 Changes (Current) |
| 35 | +### v1.4.0 Changes (Latest) 🚀 |
| 36 | + |
| 37 | +Version 1.4.0 introduces powerful automatic tool and resource generation from Swagger/OpenAPI specifications: |
| 38 | + |
| 39 | +**New Features:** |
| 40 | +- **Swagger/OpenAPI Tool & Resource Generator**: Automatically generate MCP tools or resources from any Swagger/OpenAPI specification |
| 41 | + - Supports both OpenAPI 3.x and Swagger 2.0 formats |
| 42 | + - **Choose generation type**: Generate as Tools (for actions) or Resources (for read-only data) |
| 43 | + - Interactive endpoint selection with grouping options |
| 44 | + - Automatic authentication logic generation (API Key, Bearer Token, OAuth2) |
| 45 | + - Smart naming for readable class names (handles hash-based operationIds) |
| 46 | + - Built-in API testing before generation |
| 47 | + - Complete Laravel HTTP client integration with retry logic |
| 48 | + |
| 49 | +**Example Usage:** |
| 50 | +```bash |
| 51 | +# Generate tools from OP.GG API |
| 52 | +php artisan make:swagger-mcp-tool https://api.op.gg/lol/swagger.json |
| 53 | + |
| 54 | +# With options |
| 55 | +php artisan make:swagger-mcp-tool ./api-spec.json --test-api --group-by=tag --prefix=MyApi |
| 56 | +``` |
| 57 | + |
| 58 | +This feature dramatically reduces the time needed to integrate external APIs into your MCP server! |
| 59 | + |
| 60 | +### v1.3.0 Changes |
36 | 61 |
|
37 | 62 | Version 1.3.0 introduces improvements to the `ToolInterface` for better communication control:
|
38 | 63 |
|
@@ -310,6 +335,104 @@ This command:
|
310 | 335 | - Creates a properly structured tool class in `app/MCP/Tools`
|
311 | 336 | - Offers to automatically register the tool in your configuration
|
312 | 337 |
|
| 338 | +#### Generate Tools from Swagger/OpenAPI Specifications (v1.4.0+) |
| 339 | + |
| 340 | +Automatically generate MCP tools from any Swagger/OpenAPI specification with a single command: |
| 341 | + |
| 342 | +```bash |
| 343 | +# From URL |
| 344 | +php artisan make:swagger-mcp-tool https://api.example.com/swagger.json |
| 345 | + |
| 346 | +# From local file |
| 347 | +php artisan make:swagger-mcp-tool ./specs/openapi.json |
| 348 | + |
| 349 | +# With options |
| 350 | +php artisan make:swagger-mcp-tool https://api.example.com/swagger.json \ |
| 351 | + --test-api \ |
| 352 | + --group-by=tag \ |
| 353 | + --prefix=MyApi |
| 354 | +``` |
| 355 | + |
| 356 | +**Real-world Example with OP.GG API:** |
| 357 | + |
| 358 | +```bash |
| 359 | +➜ php artisan make:swagger-mcp-tool https://api.op.gg/lol/swagger.json |
| 360 | + |
| 361 | +🚀 Swagger/OpenAPI to MCP Generator |
| 362 | +========================================= |
| 363 | +📄 Loading spec from: https://api.op.gg/lol/swagger.json |
| 364 | +✅ Spec loaded successfully! |
| 365 | ++-----------------+-------------------------+ |
| 366 | +| Property | Value | |
| 367 | ++-----------------+-------------------------+ |
| 368 | +| Title | OP.GG Api Documentation | |
| 369 | +| Version | openapi-3.0.0 | |
| 370 | +| Base URL | https://api.op.gg | |
| 371 | +| Total Endpoints | 6 | |
| 372 | +| Tags | Riot | |
| 373 | +| Security | | |
| 374 | ++-----------------+-------------------------+ |
| 375 | + |
| 376 | +🎯 What would you like to generate from this API? |
| 377 | + |
| 378 | +Tools: For operations that perform actions (create, update, delete, compute) |
| 379 | +Resources: For read-only data endpoints that provide information |
| 380 | + |
| 381 | +Generate as: |
| 382 | + [0] Tools (for actions) |
| 383 | + > 1 |
| 384 | + [1] Resources (for read-only data) |
| 385 | + > 1 |
| 386 | + |
| 387 | +✓ Will generate as MCP Resources |
| 388 | + |
| 389 | +Would you like to modify the base URL? Current: https://api.op.gg (yes/no) [no]: |
| 390 | +> no |
| 391 | + |
| 392 | +📋 Select endpoints to generate resources for: |
| 393 | +Note: Only GET endpoints can be converted to resources |
| 394 | +Include tag: Riot (6 endpoints)? (yes/no) [yes]: |
| 395 | +> yes |
| 396 | + |
| 397 | +Selected 6 endpoints. |
| 398 | +🛠️ Generating MCP resources... |
| 399 | +Note: operationId '5784a7dfd226e1621b0e6ee8c4f39407' looks like a hash, will use path-based naming |
| 400 | +Generating: LolRegionRankingsGameTypeResource |
| 401 | + ✅ Generated: LolRegionRankingsGameTypeResource |
| 402 | +Generating: LolRegionServerStatsResource |
| 403 | + ✅ Generated: LolRegionServerStatsResource |
| 404 | +... |
| 405 | + |
| 406 | +📦 Generated 6 MCP resources: |
| 407 | + - LolRegionRankingsGameTypeResource |
| 408 | + - LolRegionServerStatsResource |
| 409 | + - LolMetaChampionsResource |
| 410 | + ... |
| 411 | + |
| 412 | +✅ MCP resources generated successfully! |
| 413 | +``` |
| 414 | + |
| 415 | +**Key Features:** |
| 416 | +- **Automatic API parsing**: Supports OpenAPI 3.x and Swagger 2.0 specifications |
| 417 | +- **Dual generation modes**: |
| 418 | + - **Tools**: For operations that perform actions (POST, PUT, DELETE, etc.) |
| 419 | + - **Resources**: For read-only GET endpoints that provide data |
| 420 | +- **Smart naming**: Converts paths like `/lol/{region}/server-stats` to `LolRegionServerStatsTool` or `LolRegionServerStatsResource` |
| 421 | +- **Hash detection**: Automatically detects MD5-like operationIds and uses path-based naming instead |
| 422 | +- **Interactive mode**: Select which endpoints to convert |
| 423 | +- **API testing**: Test API connectivity before generating |
| 424 | +- **Authentication support**: Automatically generates authentication logic for API Key, Bearer Token, and OAuth2 |
| 425 | +- **Smart grouping**: Group endpoints by tags or path prefixes |
| 426 | +- **Code generation**: Creates ready-to-use classes with Laravel HTTP client integration |
| 427 | + |
| 428 | +The generated tools include: |
| 429 | +- Proper input validation based on API parameters |
| 430 | +- Authentication headers configuration |
| 431 | +- Error handling for API responses with JsonRpcErrorException |
| 432 | +- Request retry logic (3 retries with 100ms delay) |
| 433 | +- Query parameter, path parameter, and request body handling |
| 434 | +- Laravel HTTP client with timeout configuration |
| 435 | + |
313 | 436 | You can also manually create and register tools in `config/mcp-server.php`:
|
314 | 437 |
|
315 | 438 | ```php
|
|
0 commit comments