Relational DB Seeder MCP Server
Enables LLMs to inspect database schemas and seed relational databases with custom data while automatically resolving foreign key relationships.
README
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.
๐ ๏ธ 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 sync
2. Run the MCP Server Locally
You can run the server in development mode using fastmcp:
uv run fastmcp dev server.py
3. 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.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.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 |
|---|---|---|---|
get_database_status |
None | At the start of a session or when checking DB configuration. | Returns active database type, table list, and connection details (credentials masked). |
get_schema |
None | Before writing queries or generating mock data payloads. | Dumps all columns, types, nullability, primary keys, and foreign keys. |
insert_graph |
payload |
Preferred tool for inserting records and database seeding. | Inserts a relational dataset, mapping and resolving parent keys. |
execute_query |
query |
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 pytest
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.