auto-mcp-python

jratna/auto-mcp-python

3.1

If you are the rightful owner of auto-mcp-python and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

This document provides a comprehensive overview of the Auto-MCP server with OpenAPI integration, detailing its features, tools, resources, usage, and more.

Auto-MCP with OpenAPI Integration

This is a custom Auto-MCP server in Python that:

  • Dynamically creates MCP tools from an OpenAPI specification
  • Handles SSL verification disabling for internal API requests
  • Provides smart default values for required parameters
  • Exposes tools to MCP-compatible IDEs like Windsurf via HTTP

Features

  • Dynamic Tool Registration: Automatically creates MCP tools from OpenAPI endpoints
  • Smart Default Values: Generates appropriate default values for required parameters
  • SSL Verification Control: Disables SSL verification for internal API requests
  • Enhanced Error Handling: Provides structured error responses
  • Detailed Logging: Logs API requests and responses for debugging
  • Flexible Configuration: Supports environment variables and command-line arguments

Project Structure

├── main.py                 # Main entry point
├── resources/              # Resource files
│   └── ted-spec.json       # Default OpenAPI specification
├── src/                    # Source code
│   ├── core/               # Core functionality
│   │   └── server.py       # Server implementation
│   ├── config/             # Configuration
│   │   └── openapi_config.py # OpenAPI configuration
│   ├── tools/              # MCP tools
│   │   ├── health_check.py # Health check tool
│   │   └── openapi_loader.py # OpenAPI tools loader
│   ├── utils/              # Utility functions
│   │   └── spec_parser.py  # OpenAPI spec parser
│   └── tests/              # Test scripts
│       └── test_openapi_loader.py # Test for OpenAPI loader
└── requirements.txt        # Dependencies

Usage

Configuration Priority

The server determines the OpenAPI specification URL in the following order of priority:

  1. Command-line argument (--spec)
  2. Environment variable (OPENAPI_SPEC_URL)

Note: You must provide an OpenAPI specification URL using one of the above methods.

Basic Usage

  1. Install requirements:
pip install -r requirements.txt

Running the Server

  1. Run the server with an OpenAPI spec URL:
python main.py --spec https://example.com/api-spec.json
  1. Run with custom settings:
python main.py --spec https://example.com/api-spec.json --base-url https://api.example.com --host localhost --port 8084 --path /mcp
  1. You can specify additional options:
python main.py --spec path/to/spec.json --base-url https://api.example.com

Development

  1. Run tests:
python -m src.tests.test_openapi_loader
  1. Modify configuration in src/config/openapi_config.py to customize:

    • Default headers
    • Authentication methods
    • Logging behavior
    • Default parameter values
    • Tool naming conventions
    • Endpoint filtering
  2. Configure in your IDE's MCP settings:

{
  "mcpServers": {
    "auto-mcp-python": {
      "url": "http://localhost:8083/mcp"
    }
  }
}

Docker Deployment

You can easily deploy the Auto-MCP server using Docker:

Using Docker Compose (Recommended)

  1. Build and start the container:
docker-compose up -d
  1. View logs:
docker-compose logs -f
  1. Stop the container:
docker-compose down

Using Docker Directly

  1. Build the Docker image:
docker build -t auto-mcp-python .
  1. Run the container with an OpenAPI spec URL:
docker run -p 8083:8083 -e OPENAPI_SPEC_URL=https://example.com/openapi.json auto-mcp-python
  1. Run with additional configuration options:
docker run -p 8083:8083 -e OPENAPI_SPEC_URL=https://your-api-domain.com/openapi.json -e OPENAPI_BASE_URL=https://api.example.com auto-mcp-python

Note: The environment variable OPENAPI_SPEC_URL is required unless you provide a spec URL via command-line arguments.

  1. Configure in your IDE's MCP settings to connect to the Docker container:
{
  "mcpServers": {
    "auto-mcp": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "http://localhost:8083/mcp",
        "--transport",
        "http-only"
      ],
      "env": {
        "OPENAPI_SPEC_URL": "https://your-api-domain.com/openapi.json"
      }
    }
  }
}

Note: The env section in the IDE configuration passes environment variables to the MCP server, allowing you to specify the OpenAPI specification URL without modifying the server code or container.