@ivotoby/openapi-mcp-server 1.12.0 → 1.12.2

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![smithery badge](https://smithery.ai/badge/@ivo-toby/mcp-openapi-server)](https://smithery.ai/server/@ivo-toby/mcp-openapi-server)
4
4
 
5
- A Model Context Protocol (MCP) server that exposes OpenAPI endpoints as MCP resources. This server allows Large Language Models to discover and interact with REST APIs defined by OpenAPI specifications through the MCP protocol.
5
+ A Model Context Protocol (MCP) server that exposes OpenAPI endpoints as MCP tools, along with optional support for MCP prompts and resources. This server allows Large Language Models to discover and interact with REST APIs defined by OpenAPI specifications through the MCP protocol.
6
6
 
7
7
  ## 📖 Documentation
8
8
 
@@ -128,6 +128,10 @@ The server can be configured through environment variables or command line argum
128
128
  - `ENDPOINT_PATH` - Endpoint path for HTTP transport (default: "/mcp")
129
129
  - `TOOLS_MODE` - Tools loading mode: "all" (load all endpoint-based tools), "dynamic" (load only meta-tools), or "explicit" (load only tools specified in includeTools) (default: "all")
130
130
  - `DISABLE_ABBREVIATION` - Disable name optimization (this could throw errors when name is > 64 chars)
131
+ - `PROMPTS_PATH` - Path or URL to prompts JSON/YAML file
132
+ - `PROMPTS_INLINE` - Provide prompts directly as JSON string
133
+ - `RESOURCES_PATH` - Path or URL to resources JSON/YAML file
134
+ - `RESOURCES_INLINE` - Provide resources directly as JSON string
131
135
 
132
136
  ### Command Line Arguments
133
137
 
@@ -276,6 +280,122 @@ npx @ivotoby/openapi-mcp-server --api-base-url https://api.example.com --openapi
276
280
  npx @ivotoby/openapi-mcp-server --api-base-url https://api.example.com --openapi-spec https://api.example.com/openapi.json --operation post
277
281
  ```
278
282
 
283
+ ## Prompts and Resources
284
+
285
+ In addition to exposing OpenAPI endpoints as **tools**, this server can expose **prompts** (reusable templates) and **resources** (static content) via the MCP protocol.
286
+
287
+ ### What Are Prompts and Resources?
288
+
289
+ | Feature | Purpose | Use Case |
290
+ |---------|---------|----------|
291
+ | **Tools** | API endpoints for the AI to execute | Making API calls |
292
+ | **Prompts** | Templated messages with argument substitution | Reusable workflow templates |
293
+ | **Resources** | Read-only content for context | API documentation, schemas |
294
+
295
+ ### Loading Prompts
296
+
297
+ Prompts can be loaded from files, URLs, or inline JSON:
298
+
299
+ ```bash
300
+ # Load from local file
301
+ npx @ivotoby/openapi-mcp-server \
302
+ --api-base-url https://api.example.com \
303
+ --openapi-spec https://api.example.com/openapi.json \
304
+ --prompts ./prompts.json
305
+
306
+ # Load from URL
307
+ npx @ivotoby/openapi-mcp-server \
308
+ --api-base-url https://api.example.com \
309
+ --openapi-spec https://api.example.com/openapi.json \
310
+ --prompts https://example.com/mcp/prompts.json
311
+
312
+ # Inline JSON
313
+ npx @ivotoby/openapi-mcp-server \
314
+ --api-base-url https://api.example.com \
315
+ --openapi-spec https://api.example.com/openapi.json \
316
+ --prompts-inline '[{"name":"greet","title":"Greeting","template":"Hello {{name}}!"}]'
317
+ ```
318
+
319
+ **Prompts File Format (JSON):**
320
+
321
+ ```json
322
+ [
323
+ {
324
+ "name": "api_request",
325
+ "title": "API Request Helper",
326
+ "description": "Helps generate API request templates",
327
+ "arguments": [
328
+ { "name": "endpoint", "description": "API endpoint path", "required": true },
329
+ { "name": "method", "description": "HTTP method", "required": false }
330
+ ],
331
+ "template": "Create a {{method}} request to {{endpoint}} with proper parameters."
332
+ }
333
+ ]
334
+ ```
335
+
336
+ ### Loading Resources
337
+
338
+ Resources can be loaded from files, URLs, or inline JSON:
339
+
340
+ ```bash
341
+ # Load from local file
342
+ npx @ivotoby/openapi-mcp-server \
343
+ --api-base-url https://api.example.com \
344
+ --openapi-spec https://api.example.com/openapi.json \
345
+ --mcp-resources ./resources.json
346
+
347
+ # Load from URL
348
+ npx @ivotoby/openapi-mcp-server \
349
+ --api-base-url https://api.example.com \
350
+ --openapi-spec https://api.example.com/openapi.json \
351
+ --mcp-resources https://example.com/mcp/resources.json
352
+
353
+ # Inline JSON
354
+ npx @ivotoby/openapi-mcp-server \
355
+ --api-base-url https://api.example.com \
356
+ --openapi-spec https://api.example.com/openapi.json \
357
+ --mcp-resources-inline '[{"uri":"docs://readme","name":"readme","text":"# Welcome"}]'
358
+ ```
359
+
360
+ **Resources File Format (JSON):**
361
+
362
+ ```json
363
+ [
364
+ {
365
+ "uri": "docs://api/overview",
366
+ "name": "api-overview",
367
+ "title": "API Overview",
368
+ "description": "Overview of the API",
369
+ "mimeType": "text/markdown",
370
+ "text": "# API Overview\n\nThis API provides..."
371
+ }
372
+ ]
373
+ ```
374
+
375
+ ### Combining Tools, Prompts, and Resources
376
+
377
+ ```bash
378
+ npx @ivotoby/openapi-mcp-server \
379
+ --api-base-url https://api.example.com \
380
+ --openapi-spec https://api.example.com/openapi.json \
381
+ --prompts ./prompts.json \
382
+ --mcp-resources ./resources.json \
383
+ --transport http \
384
+ --port 3000
385
+ ```
386
+
387
+ With this configuration, the server advertises capabilities for all three:
388
+
389
+ ```json
390
+ {
391
+ "capabilities": {
392
+ "tools": { "list": true, "execute": true },
393
+ "prompts": {},
394
+ "resources": {}
395
+ }
396
+ }
397
+ ```
398
+
279
399
  ## Transport Types
280
400
 
281
401
  ### Stdio Transport (Default)
@@ -430,6 +550,113 @@ const config = {
430
550
  }
431
551
  ```
432
552
 
553
+ ### Configuring Prompts and Resources
554
+
555
+ Expose reusable prompts and static resources alongside your API tools:
556
+
557
+ ```typescript
558
+ import { OpenAPIServer } from "@ivotoby/openapi-mcp-server"
559
+
560
+ const config = {
561
+ name: "my-api-server",
562
+ version: "1.0.0",
563
+ apiBaseUrl: "https://api.example.com",
564
+ openApiSpec: "https://api.example.com/openapi.json",
565
+ specInputMethod: "url" as const,
566
+ transportType: "stdio" as const,
567
+ toolsMode: "all" as const,
568
+
569
+ // Define prompts with argument templates
570
+ prompts: [
571
+ {
572
+ name: "api_request",
573
+ title: "API Request Helper",
574
+ description: "Helps generate API request templates",
575
+ arguments: [
576
+ { name: "endpoint", description: "API endpoint path", required: true },
577
+ { name: "method", description: "HTTP method", required: false },
578
+ ],
579
+ template: "Create a {{method}} request to {{endpoint}} with proper parameters.",
580
+ },
581
+ ],
582
+
583
+ // Define resources with static content
584
+ resources: [
585
+ {
586
+ uri: "docs://api/overview",
587
+ name: "api-overview",
588
+ title: "API Overview",
589
+ description: "Overview of the API capabilities",
590
+ mimeType: "text/markdown",
591
+ text: "# API Overview\n\nThis API provides...",
592
+ },
593
+ ],
594
+ }
595
+
596
+ const server = new OpenAPIServer(config)
597
+ ```
598
+
599
+ #### Dynamic Prompt and Resource Management
600
+
601
+ You can also add prompts and resources dynamically after server creation:
602
+
603
+ ```typescript
604
+ const server = new OpenAPIServer(config)
605
+
606
+ // Add prompts dynamically
607
+ const promptsManager = server.getPromptsManager()
608
+ if (promptsManager) {
609
+ promptsManager.addPrompt({
610
+ name: "debug_error",
611
+ title: "Error Debugger",
612
+ template: "Debug this API error: {{error_message}}",
613
+ })
614
+ }
615
+
616
+ // Add resources dynamically
617
+ const resourcesManager = server.getResourcesManager()
618
+ if (resourcesManager) {
619
+ resourcesManager.addResource({
620
+ uri: "docs://changelog",
621
+ name: "changelog",
622
+ title: "API Changelog",
623
+ mimeType: "text/markdown",
624
+ text: "# Changelog\n\n## v1.0.0\n- Initial release",
625
+ })
626
+ }
627
+ ```
628
+
629
+ #### Prompt Definition Format
630
+
631
+ ```typescript
632
+ interface PromptDefinition {
633
+ name: string // Unique identifier
634
+ title?: string // Human-readable display title
635
+ description?: string // Description of the prompt
636
+ arguments?: { // Template arguments
637
+ name: string
638
+ description?: string
639
+ required?: boolean
640
+ }[]
641
+ template: string // Template with {{argName}} placeholders
642
+ }
643
+ ```
644
+
645
+ #### Resource Definition Format
646
+
647
+ ```typescript
648
+ interface ResourceDefinition {
649
+ uri: string // Unique URI identifier
650
+ name: string // Resource name
651
+ title?: string // Human-readable display title
652
+ description?: string // Description of the resource
653
+ mimeType?: string // Content MIME type
654
+ text?: string // Static text content
655
+ blob?: string // Static binary content (base64)
656
+ contentProvider?: () => Promise<string | { blob: string }> // Dynamic content
657
+ }
658
+ ```
659
+
433
660
  ### Advanced Authentication with AuthProvider
434
661
 
435
662
  For APIs with token expiration, refresh requirements, or complex authentication:
@@ -653,6 +880,12 @@ A: Use the `--tool`, `--tag`, `--resource`, and `--operation` flags with `--tool
653
880
  **Q: When should I use dynamic mode?**
654
881
  A: Dynamic mode provides meta-tools (`list-api-endpoints`, `get-api-endpoint-schema`, `invoke-api-endpoint`) to inspect and interact with endpoints without preloading all operations, which is useful for large or changing APIs.
655
882
 
883
+ **Q: What are prompts and resources?**
884
+ A: **Prompts** are reusable message templates with argument placeholders (e.g., `{{name}}`) that can be retrieved via the MCP `prompts/get` method. **Resources** are static or dynamic content (text or binary) that can be read via the MCP `resources/read` method. Both are optional capabilities you can configure alongside tools.
885
+
886
+ **Q: How do I expose prompts and resources from the CLI?**
887
+ A: Use `--prompts <path|url>` for prompts and `--resources <path|url>` for resources. You can also use `--prompts-inline` and `--resources-inline` for inline JSON. See the "Prompts and Resources" section in the User Guide for details.
888
+
656
889
  **Q: How do I specify custom headers for API requests?**
657
890
  A: Use the `--headers` flag or `API_HEADERS` environment variable with `key:value` pairs separated by commas for CLI usage. For library usage, use the `headers` config option or implement an `AuthProvider` for dynamic headers.
658
891