Relational DB Seeder MCP Server
Provides tools for inspecting schemas, seeding relational data, and executing queries on PostgreSQL databases, with automatic foreign key resolution.
Provides tools for inspecting schemas, seeding relational data, and executing queries on SQLite databases, with automatic foreign key resolution.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Relational DB Seeder MCP Server seed the database with sample departments and employees"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Relational DB Seeder MCP Server
An intelligent, schema-aware, fully asynchronous Model Context Protocol (MCP) server that enables LLMs (like Claude) to inspect database structures and seed relational databases with custom, semantic data while preserving foreign key integrity in a single payload.
This is a developer tool designed to bridge the gap between AI reasoning and database populating. Instead of requiring the LLM to make multiple slow, sequential tool calls to resolve auto-generated IDs, the server parses constraints, sorts tables topologically, and maps generated IDs to foreign keys automatically.
๐ Key Features
Multi-Database Support: Out-of-the-box support for both SQLite (local files) and PostgreSQL databases, configured on startup via environment variables.
Automatic Relative Path Resolution: Any relative SQLite path (e.g.
sqlite:///employee.db) is automatically resolved relative to the server's project root directory, keeping database files in a predictable location regardless of where the client runs.Relational Graph Insertion: Seeds complex tables with relationships in one batch. LLMs can reference parent rows using labels like
ref:users:alice_tempand the engine automatically resolves them to real database-generated primary keys.Fully Asynchronous: High-performance database operations powered by
aiosqliteand the modernpsycopg(v3) async library.Schema Auto-Discovery: Queries database catalogs (
information_schemaand SQLite pragma lists) to dump tables, columns, constraints, and relationships for the LLM to reason about.Credential Masking: Built-in security that automatically hides database passwords and user credentials in server logs and returned status states.
Related MCP server: BigQuery MCP server
๐ ๏ธ Architecture
db_seeder/
โโโ adapters/
โ โโโ __init__.py
โ โโโ base.py # Base connection interface using abc.ABC
โ โโโ sqlite.py # SQLite async adapter using aiosqlite
โ โโโ postgres.py # PostgreSQL async adapter using psycopg
โโโ core/
โ โโโ __init__.py
โ โโโ graph.py # Topological sort & cycle detector
โ โโโ seeder.py # Relational graph insertion engine
โโโ tests/ # Unit & integration tests๐ฆ Installation & Setup
Ensure you have uv or standard Python 3.14+ installed.
1. Clone & Install Dependencies
git clone https://github.com/yourusername/DB_Seeder.git
cd DB_Seeder
uv sync2. Run the MCP Server Locally
You can run the server in development mode using fastmcp:
uv run fastmcp dev server.py3. Add to Claude Desktop Configuration
To connect this server to your Claude Desktop application, edit your claude_desktop_config.json:
MacOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
Add the server connection (defining the DATABASE_URL for your target SQLite or Postgres database):
{
"mcpServers": {
"db-seeder": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/DB_Seeder",
"run",
"server.py"
],
"env": {
"DATABASE_URL": "sqlite:///employee.db"
}
}
}
}๐ง Expose Tools
The server registers the following asynchronous MCP tools with the client:
Tool | Parameters | When to Use | Description |
| None | At the start of a session or when checking DB configuration. | Returns active database type, table list, and connection details (credentials masked). |
| None | Before writing queries or generating mock data payloads. | Dumps all columns, types, nullability, primary keys, and foreign keys. |
|
| Preferred tool for inserting records and database seeding. | Inserts a relational dataset, mapping and resolving parent keys. |
|
| For SELECT checks, DDL schemas (CREATE, ALTER), or updates. | Runs arbitrary SQL statements on the connected database. |
๐ Relational Graph Seeding Example
When seeding, the LLM agent sends a payload where parent tables have a __temp_id and child tables refer to them using the format ref:parent_table:temp_id.
Payload sent by LLM:
{
"departments": [
{
"__temp_id": "d1",
"dept_name": "Engineering"
},
{
"__temp_id": "d2",
"dept_name": "Sales"
}
],
"employees": [
{
"name": "Alice Smith",
"email": "alice@company.com",
"number": "555-1234",
"salary": 85000,
"dept_id": "ref:departments:d1"
},
{
"name": "Bob Johnson",
"email": "bob@company.com",
"number": "555-5678",
"salary": 72000,
"dept_id": "ref:departments:d2"
}
]
}Seeder Execution Steps:
Detects that
employeesdepends ondepartmentsvia the foreign key constraint ondept_id.Sorts the insertion order:
departmentsfirst, thenemployees.Inserts departments, capturing their database-generated primary keys (e.g.
Engineering -> 1,Sales -> 2).Replaces
"ref:departments:d1"with1and"ref:departments:d2"with2in the employees payload.Inserts employees, guaranteeing that no foreign key constraint violations occur.
๐งช Testing
The project has robust unit and integration tests written using pytest and pytest-asyncio. Run them with:
PYTHONPATH=. uv run pytestAvailable Tools
4 toolsexecute_queryA
Execute arbitrary SQL statements on the connected database.
When to use: Use this tool for read operations (e.g., SELECT queries to verify data), schema modification (e.g., CREATE TABLE, ALTER TABLE, DDL statements), or updates. DO NOT use this for inserting mock/seed records; use insert_graph instead.
Args: query: SQL string to execute.
Inputs: query (required). Returns: object
get_database_statusA
Check the connection status and details of the active database.
When to use: Use this tool at the start of a session or when you need to verify which database engine (SQLite or PostgreSQL) is connected and list the available tables.
Inputs: no named parameters. Returns: object
get_schemaA
Retrieve the complete schema layout of the active database.
When to use: Call this tool before writing queries or generating mock data payloads. It provides columns, data types, nullability, primary keys, and foreign key relationships for all tables, which is necessary to plan referential insert operations.
Inputs: no named parameters. Returns: object
insert_graphA
Seed mock, test, or relational data rows into the database. Supports inserting entries into multiple tables at the same time in a single payload.
When to use: This is the PREFERRED and recommended tool for inserting data records into the database. Use this instead of executing raw SQL INSERT statements. It handles table dependencies, resolves auto-generated parent IDs dynamically, and ensures safe transactions.
CRITICAL: The payload must map table names to a list of DICTIONARIES (not lists or arrays of values). Each dictionary must map column names to their values.
Example input payload: { "users": [ { "__temp_id": "u1", "name": "Alice Smith", "email": "alice@example.com" } ], "posts": [ { "title": "My First Post", "author_id": "ref:users:u1" } ] }
Args: payload: Dict mapping table name to a list of dict objects representing rows. Rows can specify "__temp_id" (e.g. "u1"). Foreign keys can refer to parents using "ref:parent_table:temp_id" (e.g. "ref:users:u1").
Inputs: payload (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
TDQS
Scored across 4 tools
Each tool serves a clearly distinct purpose: status check, schema retrieval, graph-based seeding, and arbitrary SQL execution. The descriptions explicitly distinguish insert_graph from execute_query, leaving no ambiguity about when to use which.
All tool names follow the same verb_noun pattern in snake_case: get_database_status, get_schema, insert_graph, execute_query. This consistent convention makes the toolset easy to learn and predict.
With only 4 tools, the server is tightly focused on its purpose of seeding relational databases. Each tool is necessary and none is redundant, making the scope well-calibrated.
The toolset covers the full workflow: inspecting database status, reading schema, inserting relational data with dependency handling, and executing arbitrary SQL for validation or modifications. No obvious gaps for the seeder domain.
Maintenance
Related MCP Connectors
Generate realistic, FK-consistent synthetic test data for your databases from your AI assistant.
Database for your AI agent. Turn its output into data, docs, skills, and apps you can actually use.
Store, query, and update structured data from any AI agent
Query Postgres, MySQL, SQL Server, Oracle, BigQuery, ClickHouse and Redshift from your AI client.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to generate realistic, relationship-preserving test data from Seedbase projects into databases.29 npmMIT
- FlicenseNot gradedqualityAmaintenanceEnables LLMs to inspect database schemas and execute SQL queries, list tables, and describe table schemas.-
- FlicenseNot gradedqualityAmaintenanceEnables LLMs to inspect database schemas and execute SQL queries, including listing tables and describing table schemas.-
- FlicenseNot gradedqualityAmaintenanceEnables LLMs to inspect database schemas and execute SQL queries, including listing tables and describing table schemas.-