Spaces:
Sleeping
Sleeping
File size: 2,043 Bytes
738ece7 c640702 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | ---
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`.
|