Elsai MCP#
The Elsai MCP package provides a powerful bridge that automatically converts any backend Swagger (OpenAPI) API into a Model Context Protocol (MCP) server. This allows LLMs to interact with your existing APIs as a set of tools with minimal configuration.
Prerequisites#
Python >= 3.10
A valid Swagger/OpenAPI specification URL (JSON or YAML)
mcp and fastmcp libraries
Installation#
To install the elsai-mcp package:
pip install --extra-index-url https://elsai-core-package.optisolbusiness.com/root/elsai-mcp/ elsai-mcp==0.1.1
Core Component#
MCPFlow#
The MCPFlow class is the central orchestrator of the package. It encapsulates the full process from parsing the Swagger specification to running the MCP server.
It automates: - Parsing: Fetches and interprets the OpenAPI definition. - Conversion: Transforms REST endpoints into MCP tools. - Server Setup: Configures execution and authentication. - Execution: Starts the MCP transport.
Initialization Arguments:
swagger_url: The URL to the JSON or YAML Swagger specification.base_url: The base URL of the API to which requests will be sent.auth_config: (Optional) Authentication configuration (e.g., token-based).transport: Transport type (e.g.,"sse"or"streamable-http").
Usage Example#
Server Implementation (server.py)
The following example demonstrates how to set up a unified MCP server using MCPFlow.
from elsai_mcp import MCPFlow
# Configuration
SWAGGER_URL = "https://petstore.swagger.io/v2/swagger.json"
BASE_URL = "https://petstore.swagger.io/v2"
# Optional auth configuration
AUTH_CONFIG = None
if __name__ == "__main__":
print("=== SwaggerToMCP Package — Unified Flow Server ===\n")
# Initialize and start the full MCP flow
mcp = MCPFlow(
swagger_url=SWAGGER_URL,
base_url=BASE_URL,
auth_config=AUTH_CONFIG,
transport="sse" # Use 'sse' for standard MCP clients
)
# Trigger everything: Parser -> Server -> Builder -> Run
mcp.start()
Integration with MCP Clients
Once the server is running with the sse transport, it can be added to standard MCP clients (like Claude Desktop) by configuring the server URL accordingly.