--- title: Mock Api Mcp Server emoji: 🚀 colorFrom: blue colorTo: green sdk: docker app_port: 7860 --- # Production-Ready Mock API Service (MCP + FastAPI) A dynamic mock API generation service that uses Model Context Protocol (MCP) to allow AI agents to generate and host mock APIs for you. This version is production-ready with Postgres support and MCP-over-SSE. ## Features - **Database-Backed**: Uses SQLAlchemy for reliable persistence (supports SQLite and Neon Postgres). - **Remote MCP access**: AI agents can connect via SSE (Server-Sent Events) at `https://your-domain.com/sse`. - **Dynamic CRUD**: Automatically hosts generated endpoints on `localhost:8000` or your cloud domain. - **Contextual Data**: Generates realistic data for products, users, orders, and more. ## Setup & Deployment ### 1. Environment Variables Copy `.env.example` to `.env` and configure: ```bash HOST_URL=https://your-domain.com DATABASE_URL=postgresql://user:password@subdomain.neon.tech/neondb?sslmode=require ``` ### 2. Local Development (with uv) ```bash # Run the API server uv run uvicorn main:app --reload # Run the MCP Server via stdio (for local use) mcp dev main.py ``` ### 3. Production Deployment (Docker) This project includes a `Dockerfile`. You can deploy it to **Render**, **Railway**, or **DigitalOcean** by connecting your GitHub repo. - **Port**: 8000 - **Database**: Connect a Neon Postgres instance via the `DATABASE_URL` environment variable. ## Connecting AI Agents ### Option A: Local (Cursor, Claude Desktop) Add the MCP server to your settings as a **command**: ```bash uv run mcp run main.py ``` ### Option B: Remote (Publicly Hosted) If you have hosted the app, add it as an **SSE** server: - **URL**: `https://your-service-domain.com/sse` ## Testing the Tools Once connected, use the `generate_mock_api` tool: - `name`: "products" - `fields`: "id,name,price,image_url" The agent will return a URL like `https://your-service.com/mock/abc123/products`.