AI

Using MCP Server to Generate Test Data in AI Coding Agents

The Problem

AI coding agents are getting smarter, but they still struggle with test data. When you ask an agent to scaffold a project or write tests, it typically hardcodes a handful of records with names like "John Doe" and emails like "test@test.com". The data is unrealistic, there are no relationships between tables, and the same five records get copy-pasted everywhere.

Even when agents try to use Faker.js, they have to generate the code, install dependencies, run it, and parse the output. It is a multi-step process that breaks the flow of AI-assisted development.

The Solution: MockHero MCP Server

The Model Context Protocol (MCP) is an open standard that lets AI agents call external tools directly. MockHero provides an MCP server that any compatible agent can use to generate realistic, relational test data without leaving the IDE. The agent describes the schema, MockHero returns the data, and the agent inserts it into your code or database.

No npm installs. No seed scripts. The agent handles everything through a single tool call.

Quick Setup

Add MockHero's MCP server to your agent's configuration:

{
  "mcpServers": {
    "mockhero": {
      "command": "npx",
      "args": ["-y", "@mockhero/mcp-server"],
      "env": {
        "MOCKHERO_API_KEY": "mh_your_api_key"
      }
    }
  }
}

Once configured, your AI agent can call MockHero directly. For example, tell the agent:

"Generate 20 users and 50 orders with realistic data for my e-commerce project"

The agent translates this into a MockHero API call behind the scenes and gives you production-quality data instantly.

Step-by-Step Guide

1. Install the MCP server

The MockHero MCP server runs via npx, so there is nothing to install globally. Just add the configuration block above to your AI agent's MCP settings file.

2. Get your API key

Sign up at mockhero.dev/sign-up and copy your API key from the dashboard.

3. Configure your agent

Each agent stores MCP configuration differently. For Cursor, add it to .cursor/mcp.json. For Claude Code, add it to .claude/mcp.json. For Windsurf, add it to your MCP settings. The server configuration is identical across all agents.

4. Ask the agent to generate data

Use natural language. The agent will automatically use the MockHero MCP tool when it recognizes a test data request. Examples:

  • "Seed my database with 100 users and their related posts"
  • "Generate test data for my healthcare scheduling app"
  • "Create realistic e-commerce data with products, customers, and orders"

5. Use the generated data

The agent will insert the data directly into your seed files, test fixtures, or database migration scripts. No manual copy-pasting required.

Why MockHero MCP vs Manual Data Generation

  • Zero friction — the agent generates data in-context, without leaving your IDE or switching tools.
  • Schema-aware — 156+ field types mean the agent can request exactly the right data shape for your use case.
  • Relational integrity — foreign keys just work. No manual ID wiring needed.
  • Agent-native — MCP is the standard protocol for tool use in AI agents. MockHero speaks it natively.

Get Started

Add MockHero's MCP server to your AI coding agent in under a minute. Sign up free and give your agent the power to generate realistic test data on demand.

M

MockHero Team

Guides and tutorials for generating realistic test data with the MockHero API.

Start generating test data for free

1,000 rows/month on the free tier. No credit card required.

Get Your API Key

Related Articles