Categories

API Mock Server

Generate a runnable Redis-backed mock API server with 1-hour TTL, hot updates, and dynamic templated responses

Create a temporary mock server for frontend and API testing.

  • Input endpoint description as JSON
  • Generate a unique mock server ID
  • Store mock definition in Redis for 1 hour
  • Test immediately through /mock/{id}
  • Re-run with the same ID to hot-update responses without restarting

Example Results

1 examples

Create a runnable mock API session

Generate a temporary mock server in Redis and test endpoints for one hour

{
  "mockId": "abc123...",
  "baseUrl": "http://localhost:3000/mock/abc123/api"
}
View input parameters
{ "mockDefinitionJson": "{\n \"name\": \"User Service Mock\",\n \"basePath\": \"/api\",\n \"endpoints\": [\n {\n \"method\": \"GET\",\n \"path\": \"/users/:id\",\n \"status\": 200,\n \"responseType\": \"json\",\n \"dynamicResponse\": true,\n \"responseBody\": {\n \"id\": \"{{params.id}}\",\n \"name\": \"Mock User\",\n \"trace\": \"{{query.trace}}\",\n \"requestedAt\": \"{{now}}\"\n }\n }\n ]\n}" }

Key Facts

Category
Development
Input Types
textarea, text
Output Type
json
Sample Coverage
4
API Ready
Yes

Overview

The API Mock Server is a developer-focused utility that generates temporary, Redis-backed mock endpoints to streamline frontend development and API testing. By defining your API structure in JSON, you can instantly deploy a live server that supports dynamic templated responses and hot-updates for rapid iteration.

When to Use

  • When backend development is delayed and you need to unblock frontend integration.
  • When you need to test how your application handles specific API responses or dynamic data.
  • When you want to quickly prototype an API contract without setting up a full local server environment.

How It Works

  • Input your API endpoint definitions, including methods, paths, and response bodies, using the Mock Definition JSON format.
  • Generate a unique mock server ID that hosts your endpoints at a temporary URL.
  • Access your mock API immediately via the provided base URL.
  • Re-run the tool with the same mock ID to apply hot updates to your endpoints without downtime.

Use Cases

Simulating user authentication flows by mocking login POST requests.
Testing frontend data binding with dynamic GET requests that include URL parameters.
Rapidly iterating on API response structures during the design phase of a new feature.

Examples

1. Mocking a User Profile Service

Frontend Developer
Background
The backend team is still building the user profile service, but the frontend needs to implement the user dashboard.
Problem
Need a live endpoint that returns user data based on a dynamic ID from the URL.
How to Use
Input the endpoint definition with dynamic parameters and retrieve the mock URL.
Example Config
{"name": "User Service", "basePath": "/api", "endpoints": [{"method": "GET", "path": "/users/:id", "status": 200, "dynamicResponse": true, "responseBody": {"id": "{{params.id}}", "name": "John Doe"}}]}
Outcome
A temporary URL is generated, allowing the frontend to fetch user data by calling /api/users/123.

2. Hot-Updating Mock Responses

Full-Stack Developer
Background
Testing how the UI handles different error states from a login endpoint.
Problem
Need to change the mock response from success to unauthorized without restarting the entire testing environment.
How to Use
Re-run the tool with the existing mockId and a modified JSON definition.
Example Config
{"name": "Auth Service", "basePath": "/api", "endpoints": [{"method": "POST", "path": "/login", "status": 401, "responseBody": {"error": "Invalid credentials"}}]}
Outcome
The mock server updates instantly, and the frontend receives the 401 error response on the next request.

Try with Samples

json

Related Hubs

FAQ

How long does the mock server stay active?

Each mock server instance is stored in Redis and remains active for 1 hour after creation or last update.

Can I update my mock responses after creating the server?

Yes, simply re-run the tool using the same mockId to hot-update your endpoint definitions instantly.

Does the server support dynamic responses?

Yes, you can use template tags like {{params.id}}, {{body.username}}, or {{now}} within your response body to generate dynamic data.

Is there a limit to the number of endpoints I can define?

You can define multiple endpoints within a single JSON configuration to simulate a complete API service.

What happens after the 1-hour TTL expires?

The mock server and its data are automatically removed from Redis once the 1-hour TTL is reached.

API Documentation

Request Endpoint

POST /en/api/tools/api-mock-server

Request Parameters

Parameter Name Type Required Description
mockDefinitionJson textarea Yes -
mockId text No -

Response Format

{
  "key": {...},
  "metadata": {
    "key": "value"
  },
  "error": "Error message (optional)",
  "message": "Notification message (optional)"
}
JSON Data: JSON Data

AI MCP Documentation

Add this tool to your MCP server configuration:

{
  "mcpServers": {
    "elysiatools-api-mock-server": {
      "name": "api-mock-server",
      "description": "Generate a runnable Redis-backed mock API server with 1-hour TTL, hot updates, and dynamic templated responses",
      "baseUrl": "https://elysiatools.com/mcp/sse?toolId=api-mock-server",
      "command": "",
      "args": [],
      "env": {},
      "isActive": true,
      "type": "sse"
    }
  }
}

You can chain multiple tools, e.g.: `https://elysiatools.com/mcp/sse?toolId=png-to-webp,jpg-to-webp,gif-to-webp`, max 20 tools.

If you encounter any issues, please contact us at [email protected]