MockLoop MCP server

Generates fully functional FastAPI mock servers from OpenAPI specifications with Docker support, authentication middleware, request logging, and admin interfaces for API testing and development workflows.
Back to servers
Setup instructions
Provider
Jascha Wanger
Release date
May 29, 2025
Stats
8 stars

MockLoop MCP is an AI-native testing platform powered by the Model Context Protocol (MCP). It revolutionizes API testing with comprehensive AI-driven scenario generation, automated test execution, and intelligent analysis capabilities.

Installation

Install from PyPI

# Install the latest stable version
pip install mockloop-mcp

# Verify installation
mockloop-mcp --version

Development Installation

# Clone the repository
git clone https://github.com/mockloop/mockloop-mcp.git
cd mockloop-mcp

# Create and activate virtual environment
python3 -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install in development mode
pip install -e ".[dev]"

Configuration

MCP Client Configuration

Cline (VS Code Extension)

Add to your Cline MCP settings file:

{
  "mcpServers": {
    "MockLoopLocal": {
      "autoApprove": [],
      "disabled": false,
      "timeout": 60,
      "command": "mockloop-mcp",
      "args": [],
      "transportType": "stdio"
    }
  }
}

Claude Desktop

Add to your Claude Desktop configuration:

{
  "mcpServers": {
    "mockloop": {
      "command": "mockloop-mcp",
      "args": []
    }
  }
}

Virtual Environment Installations

For virtual environment installations, use the full Python path:

{
  "mcpServers": {
    "MockLoopLocal": {
      "command": "/path/to/your/venv/bin/python",
      "args": ["-m", "mockloop_mcp"],
      "transportType": "stdio"
    }
  }
}

Available MCP Tools

Core Mock Generation

generate_mock_api

Generate sophisticated FastAPI mock servers with dual-port architecture.

Parameters:

  • spec_url_or_path (string, required): API specification URL or local file path
  • output_dir_name (string, optional): Output directory name
  • auth_enabled (boolean, optional): Enable authentication middleware (default: true)
  • webhooks_enabled (boolean, optional): Enable webhook support (default: true)
  • admin_ui_enabled (boolean, optional): Enable admin UI (default: true)
  • storage_enabled (boolean, optional): Enable storage functionality (default: true)

Advanced Analytics

query_mock_logs

Query and analyze request logs with AI-powered insights.

Parameters:

  • server_url (string, required): Mock server URL
  • limit (integer, optional): Maximum logs to return (default: 100)
  • offset (integer, optional): Pagination offset (default: 0)
  • method (string, optional): Filter by HTTP method
  • path_pattern (string, optional): Regex pattern for path filtering
  • time_from (string, optional): Start time filter (ISO format)
  • time_to (string, optional): End time filter (ISO format)
  • include_admin (boolean, optional): Include admin requests (default: false)
  • analyze (boolean, optional): Perform AI analysis (default: true)

discover_mock_servers

Intelligent server discovery with dual-port architecture support.

Parameters:

  • ports (array, optional): Ports to scan (default: common ports)
  • check_health (boolean, optional): Perform health checks (default: true)
  • include_generated (boolean, optional): Include generated mocks (default: true)

manage_mock_data

Dynamic response management without server restart.

Parameters:

  • server_url (string, required): Mock server URL
  • operation (string, required): Operation type ("update_response", "create_scenario", "switch_scenario", "list_scenarios")
  • endpoint_path (string, optional): API endpoint path
  • response_data (object, optional): New response data
  • scenario_name (string, optional): Scenario name
  • scenario_config (object, optional): Scenario configuration

MCP Proxy Functionality

MockLoop MCP includes revolutionary proxy capabilities that enable seamless switching between mock and live API environments:

Core Proxy Capabilities

  • Seamless mode switching between mock, proxy, and hybrid modes
  • Intelligent routing based on configurable rules
  • Universal authentication support (API Key, Bearer Token, Basic Auth, OAuth2)
  • Response comparison between mock and live API responses
  • Zero-downtime switching

Operational Modes

  • Mock Mode (MOCK): All requests handled by generated mock responses
  • Proxy Mode (PROXY): All requests forwarded to live API endpoints
  • Hybrid Mode (HYBRID): Intelligent routing between mock and proxy based on rules

Quick Start Example

from mockloop_mcp.mcp_tools import create_mcp_plugin

# Create a proxy-enabled plugin
plugin_result = await create_mcp_plugin(
    spec_url_or_path="https://api.example.com/openapi.json",
    mode="hybrid",  # Start with hybrid mode
    plugin_name="example_api",
    target_url="https://api.example.com",
    auth_config={
        "auth_type": "bearer_token",
        "credentials": {"token": "your-token"}
    },
    routing_rules=[
        {
            "pattern": "/api/critical/*",
            "mode": "proxy",  # Critical endpoints use live API
            "priority": 10
        },
        {
            "pattern": "/api/dev/*",
            "mode": "mock",   # Development endpoints use mocks
            "priority": 5
        }
    ]
)

Dual-Port Architecture

MockLoop MCP introduces a dual-port architecture that eliminates common conflicts and enhances security:

Architecture Benefits

  • Enhanced security through separation of mocked API and admin functionality
  • Zero conflicts by eliminating /admin path conflicts in OpenAPI specifications
  • Clean analytics as admin calls don't appear in mocked API metrics
  • Independent scaling of mocked API and admin services
  • Port-based access control

Port Configuration

# Generate mock with dual-port architecture
result = mockloop.generate_mock_api(
    spec_url_or_path="https://api.example.com/openapi.json",
    business_port=8000,  # Mocked API port
    admin_port=8001,     # Admin UI port
    admin_ui_enabled=True
)

Access Points

  • Mocked API: http://localhost:8000 - Your API endpoints
  • Admin UI: http://localhost:8001 - Management interface
  • API Documentation: http://localhost:8000/docs - Interactive Swagger UI
  • Health Check: http://localhost:8000/health - Server status

Running Generated Mock Servers

Using Docker Compose (Recommended)

# Navigate to generated mock directory
cd generated_mocks/your_api_mock

# Start with dual-port architecture
docker-compose up --build

# Access points:
# Mocked API: http://localhost:8000
# Admin UI: http://localhost:8001

Using Uvicorn Directly

# Install dependencies
pip install -r requirements_mock.txt

# Start the mock server
uvicorn main:app --reload --port 8000

Enhanced Features Access

  • Admin UI: http://localhost:8001 - Enhanced management interface
  • API Documentation: http://localhost:8000/docs - Interactive Swagger UI
  • Health Check: http://localhost:8000/health - Server status and metrics
  • Log Analytics: http://localhost:8001/api/logs/search - Advanced log querying
  • Performance Metrics: http://localhost:8001/api/logs/analyze - AI-powered insights
  • Scenario Management: http://localhost:8001/api/mock-data/scenarios - Dynamic testing

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "mockloop" '{"command":"mockloop-mcp","args":[]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "mockloop": {
            "command": "mockloop-mcp",
            "args": []
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "mockloop": {
            "command": "mockloop-mcp",
            "args": []
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later