Standalone OpenAPI MCP Server Binary

Overview

Create a standalone binary that uses the rmcp-openapi library to run an OpenAPI MCP server with CLI interface.

Scope

This issue focuses on the executable binary that provides a command-line interface for running OpenAPI MCP servers. The core library functionality is implemented in issue #1 (closed).

Requirements

Binary Features

  • CLI argument parsing for OpenAPI spec location (now positional)
  • Support for local files and remote URLs
  • MCP stdio transport integration (moved to issue #11)
  • Server lifecycle management
  • Configuration options (base URL, port, bind address)
  • Graceful shutdown handling

CLI Interface

# OpenAPI spec as required positional argument
rmcp-openapi-server <SPEC>

# With OpenAPI spec URL
rmcp-openapi-server https://petstore.swagger.io/v2/swagger.json

# Local file
rmcp-openapi-server ./api-spec.yaml

# With base URL override
rmcp-openapi-server ./spec.json --base-url https://api.example.com

# With custom port and bind address
rmcp-openapi-server ./spec.json --port 9000 --bind-address 0.0.0.0

Configuration

  • Required positional argument: OpenAPI specification must be provided as first argument
  • Transport: SSE (Server-Sent Events)
  • Error handling: Comprehensive startup validation
  • Logging: Structured logging with configurable levels

Architecture

rmcp-openapi-cli/
├── Cargo.toml          # Binary crate
├── src/
│   ├── main.rs         # CLI entry point with SSE transport
│   ├── cli.rs          # Argument parsing (clap) - positional spec
│   ├── config.rs       # Configuration management
│   └── spec_location.rs # Type-safe spec location handling
└── examples/
    └── petstore.sh     # Petstore demo script

Dependencies on Issue #1 (closed)

  • Requires rmcp-openapi library crate to be complete
  • Uses library's OpenApiServer and related types
  • Builds on tested Petstore integration

Acceptance Criteria

  • Binary can start MCP server from CLI with positional spec argument
  • Supports both local and remote OpenAPI specs via positional argument
  • Integrates with MCP clients via SSE transport
  • Proper error handling and user feedback
  • Documentation with usage examples
  • Clear CLI interface requiring explicit specification

Implementation Highlights

  • Type-Safe Spec Handling: OpenApiSpecLocation enum with File(PathBuf) and Url(Url) variants
  • Seamless CLI Integration: Custom FromStr implementation works automatically with clap
  • No Unnecessary Conversions: Direct file/URL handling without complex conversions
  • Production Ready: Comprehensive error handling, graceful shutdown, configurable options
  • Explicit Interface: Positional argument eliminates ambiguity about which spec to use

Testing Strategy

  • Integration tests with real MCP clients (via existing test suite)
  • CLI argument validation tests (via clap validation)
  • Server startup/shutdown tests (via SSE transport)
  • Multiple OpenAPI spec verification (flexible specification support)

Status: COMPLETE - All requirements implemented and tested
Latest Update: Changed OpenAPI spec from --spec flag to required positional argument for improved CLI clarity
Note: This issue depended on completion of issue #1 (closed) (core library implementation) DONE

Edited by Wally The Wobot