Test Data Generation with Claude Code and MockHero
The Problem
Claude Code is a powerful terminal-based AI agent that can navigate codebases, edit files, and run commands. But when it needs to generate test data, it typically writes inline JSON or uses Faker.js snippets. The results are functional but shallow: a handful of flat records with no relationships and generic-looking values.
For any real project, you need hundreds or thousands of records across multiple tables with valid foreign keys. Asking Claude Code to generate all that data inline leads to bloated responses, token waste, and inconsistent results between sessions.
The Solution: MockHero MCP in Claude Code
Claude Code supports MCP servers as external tools. By registering MockHero's MCP server, Claude Code can generate arbitrarily large datasets with relational integrity in a single tool call. You describe what you need, and Claude Code calls MockHero, gets the data, and writes it wherever you need it.
Quick Setup
Add MockHero to your Claude Code MCP configuration. Create or edit .claude/mcp.json in your project root:
{
"mcpServers": {
"mockhero": {
"command": "npx",
"args": ["-y", "@mockhero/mcp-server"],
"env": {
"MOCKHERO_API_KEY": "mh_your_api_key"
}
}
}
}
Next time you start a Claude Code session in that project, it will automatically load the MockHero tool.
Step-by-Step Guide
1. Get your MockHero API key
Sign up at mockhero.dev/sign-up and copy your API key.
2. Add the MCP configuration
Place .claude/mcp.json in your project root with the configuration above. You can also add it to ~/.claude/mcp.json for global access across all projects.
3. Start a Claude Code session
Run claude in your project directory. Claude Code will detect the MCP server and load it automatically.
4. Request test data
Ask Claude Code to generate data naturally:
"Create a seed script for my Next.js app with Drizzle ORM. I need
50 organizations, 200 users belonging to those orgs, and 500 tasks
assigned to users. Make the data realistic."
Claude Code will call MockHero's MCP server, receive the generated data, and write a complete seed script for your project.
5. Run and verify
Claude Code can run the seed script directly in the terminal. Verify the data in your database to confirm foreign keys are correct and the data looks realistic.
Why MockHero MCP in Claude Code vs Inline Generation
- Token-efficient — instead of generating data inline (burning thousands of tokens), Claude Code makes a single MCP call.
- Scalable — generate 10 rows or 10,000 rows with the same call. Inline generation tops out at a few dozen.
- Consistent — MockHero returns the same structure every time. No hallucinated field names or broken relationships.
- Terminal-native — works seamlessly in Claude Code's terminal workflow. No browser or GUI needed.
Get Started
Give Claude Code the superpower of realistic test data. Sign up free at mockhero.dev, add the MCP config, and start generating production-quality data from your terminal.
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