# AI Agent Test Data Generation via MCP Server

> Source: <https://dev.to/matejstetiar/ai-agent-test-data-generation-via-mcp-server-10h0>
> Published: 2026-09-03 09:44:15+00:00

An AI coding agent working inside Claude Desktop or Cursor can read your

code, write new files, and run your test suite — but it can't open a

browser, log into a dashboard, and click "generate" to get a batch of

realistic test data. It has no hands for a UI. AI agent test data

generation only works if there's something the agent can *call*: a tool

with a defined schema it can invoke mid-session, the same way it calls a

file-write or a shell command. That's exactly what the Model Context

Protocol (MCP) is for, and it's why we shipped

`@jsonfabrica/mcp-server`

on npm.

MCP lets an AI client — Claude Desktop, Cursor, or anything else that

speaks the protocol — launch a small local server over stdio and treat

its exposed functions as tools it can call during a conversation. The

agent decides when to call `jsonfabrica_generate_from_template`

the same

way it decides when to call `read_file`

. For that to work, three things

have to exist: a server process the client can start, a set of tool

definitions with typed inputs and outputs, and — underneath all of it —

some actual operation the tool call triggers. MCP server test data

generation is that last piece: the tool call has to result in real,

schema-conformant data coming back, not a stub.

`@jsonfabrica/mcp-server`

, concretely
We published `@jsonfabrica/mcp-server`

v0.1.1 as a local MCP server: the

AI client launches it itself over stdio, no separate process to manage,

no port to open. It exposes the JsonFabrica gateway as a set of MCP

tools — `jsonfabrica_create_template`

, `jsonfabrica_generate_from_template`

,

`jsonfabrica_generate_adhoc`

, `jsonfabrica_create_batch`

,

`jsonfabrica_create_sequence`

, and more. Mid-session, an agent can create

a template matching the shape of your `User`

or `Order`

model, generate

a batch of realistic records against it, and drop the result straight

into a fixture file or a seed script — without you leaving the editor to

go configure anything by hand.

Here's the part worth being explicit about: every one of those MCP

tools is a thin, typed wrapper around an endpoint that already existed

in the JsonFabrica REST API. `jsonfabrica_generate_from_template`

calls

the same generation endpoint a CI pipeline or a seed script would call.

Writing the MCP server was a matter of describing existing requests and

responses as tool schemas — input validation, output shape, a short

description for the model to read — not building new generation logic,

new data models, or a new backend. The API was already the product; the

MCP server just gives it a second front door.

Contrast that with a tool where the primary interface is a dashboard:

form fields, dropdowns, a "generate" button wired to internal state that

was never meant to be called from outside a browser session. Exposing

that to an AI agent means building an API it never had — endpoints,

request validation, auth, versioned responses — essentially rebuilding

the product's backend to have something to wrap. AI agent test data

generation isn't a feature you bolt onto a UI-first product after the

fact; it's a natural consequence of the product being API-first from the

start. If the REST API is solid, wrapping it for MCP is a week of typed

schemas. If it isn't, MCP support means building the API you should have

had all along.

**How do I connect JsonFabrica to Claude Desktop or Cursor?**

Install `@jsonfabrica/mcp-server`

from npm and add it as an MCP server in

your client's config. The client launches the server itself over stdio, so

there's no separate process to run or port to open, and the agent can then

call its tools directly in a session.

**What is an MCP server, and why does it matter for AI coding agents?**

MCP, the Model Context Protocol, lets an AI client like Claude Desktop or

Cursor launch a small local server and treat its exposed functions as

tools it can call mid-conversation, the same way it calls a file-write or

a shell command. Without it, an agent has no way to invoke an external

service like a test data API, since it can't open a browser and click

through a UI.

**Can an AI agent generate relational or batch test data through MCP, not just single records?**

Yes — `jsonfabrica_create_batch`

wraps the same batch generation endpoint

the REST API and CI pipelines use, so an agent can generate a customer and

a set of linked orders in one call during a coding session, not just

isolated single documents.

**Does JsonFabrica's MCP server require a separate backend from the REST API?**

No. Every MCP tool, such as `jsonfabrica_generate_from_template`

or

`jsonfabrica_create_sequence`

, is a thin typed wrapper around an endpoint

that already exists in the JsonFabrica REST API — there's no separate

generation logic or data model behind the MCP server.

In practice, it collapses a context switch. Instead of stopping to write

a one-off fixture by hand, or tabbing to a dashboard to generate a CSV

and importing it back, an agent working on a PR can generate the test

data it needs — realistic, schema-conformant, matching the model it's

currently editing — as part of the same conversation that's writing the

tests. No manual step, no separate tool, no copy-pasting JSON between

windows. That's the practical payoff of MCP server test data generation:

not a new capability bolted onto the model, but an existing capability

finally reachable from where the work is actually happening.
