Skip to main content
Glama
NamanT98

Relational DB Seeder MCP Server

by NamanT98

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_temp and the engine automatically resolves them to real database-generated primary keys.

  • Fully Asynchronous: High-performance database operations powered by aiosqlite and the modern psycopg (v3) async library.

  • Schema Auto-Discovery: Queries database catalogs (information_schema and 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: database-explorer-mcp

๐Ÿ› ๏ธ 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:

  1. Detects that employees depends on departments via the foreign key constraint on dept_id.

  2. Sorts the insertion order: departments first, then employees.

  3. Inserts departments, capturing their database-generated primary keys (e.g. Engineering -> 1, Sales -> 2).

  4. Replaces "ref:departments:d1" with 1 and "ref:departments:d2" with 2 in the employees payload.

  5. 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

Available Tools

4 tools
execute_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.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of disclosure. It mentions 'arbitrary SQL' and schema modification, implying destructive potential, but does not explicitly state risks like irreversible data loss, required permissions, transaction behavior, or side effects. The agent is left unaware of important consequences beyond the basic fact that it executes SQL.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded, starting with the core purpose then providing usage guidance and arguments. It has no filler and is logically structured with clear sections, making it easy to scan.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Although output schema exists, this tool executes arbitrary SQL, so high-impact context is needed. The description omits security/safety warnings, error behavior, transactional guarantees, and any limits on query complexity or resource usage. It also only disambiguates from insert_graph, not from get_schema or get_database_status, leaving part of the sibling context incomplete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. The only parameter info is 'query: SQL string to execute,' which adds minimal meaning over the schema's 'query' string type. It does not explain whether multiple statements are allowed, expected SQL dialect, or any format/escaping requirements, leaving significant ambiguity.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states 'Execute arbitrary SQL statements on the connected database' with specific examples (SELECT, CREATE TABLE, ALTER TABLE, updates), clearly defining the tool's scope. It explicitly distinguishes from sibling insert_graph by warning not to use it for mock/seed records, thus differentiating itself from the primary alternative.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The 'When to use' section explicitly lists valid use cases (read operations, schema modification, updates) and provides an explicit exclusion ('DO NOT use this for inserting mock/seed records') with a named alternative tool (insert_graph). This is exactly the kind of when/when-not guidance expected.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.7/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It clearly indicates this is a read-only status operation ('Check', 'list'), and it specifies what information is available (engine and tables). It does not mention potential errors or permission requirements, but for a simple status tool this is adequate.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, front-loaded with the main action, and directly followed by applicable usage context. Every sentence earns its place; there is no redundant detail.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple status-checking tool with no parameters and an output schema, this description is complete. It covers purpose, the engine types, the available tables, and when to invoke it. The output schema may provide additional return details, so the description does not need to enumerate them.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, so the baseline is 4. The description adds no parameter-specific semantics, but none are needed since the schema is empty and the tool's behavior is fully described without parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Check') and a clear resource ('the active database'), and it explicitly distinguishes this tool from siblings by focusing on connection status and the database engine (SQLite or PostgreSQL). This is not a tautology and is clearly distinct from get_schema, execute_query, and insert_graph.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance: 'Use this tool at the start of a session or when you need to verify which database engine is connected and list the available tables.' This tells the agent exactly when to use it, though it does not name alternatives directly. The context is clear and actionable.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the burden of behavioral disclosure. It explains that the tool returns columns, data types, nullability, primary keys, and foreign keys for all tables, and scopes to the active database. It implies a read-only operation via 'Retrieve'. It lacks explicit side-effect or rate-limit notes, but for a retrieval tool this is sufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise: two sentences. The first states the action and scope, the second supplies usage context. Every word earns its place with no filler or redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given zero parameters, an existing output schema, and no nested objects, the description fully covers the tool's purpose and usage. It explains what data is returned and when to use it, making it complete for an AI agent to invoke correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, so the baseline is 4. The schema description coverage is 100% with an empty schema, and no parameter details are needed. The description adds no parameter semantics, but none are required.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states a specific action ('Retrieve') and resource ('complete schema layout of the active database'). It distinguishes itself from sibling tools by focusing on schema structure rather than database status, graph insertion, or query execution.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly provides when-to-use guidance: 'Call this tool before writing queries or generating mock data payloads'. It also explains why it's necessary for referential insert operations. While it doesn't mention when not to use it or name alternatives, the context is clear and actionable.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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").

ParametersJSON Schema
NameRequiredDescriptionDefault
payloadYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.8/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so the description carries the burden. It discloses transaction safety, dynamic parent-ID resolution, and table-dependency handling. It also warns about payload format. Missing details like auth requirements are not relevant here, and the mutation nature is self-evident.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Although lengthy, the description is well-structured: a one-sentence summary, a 'When to use' paragraph, a 'CRITICAL' note, an example, and an args section. Every sentence adds value; no filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the output schema exists, the description doesn't need to detail returns. It covers when to use, payload format, and example, leaving no critical gaps. The tool's complexity is fully addressed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, but the description compensates with a detailed explanation of the payload structure, including required dictionary mapping, __temp_id and ref syntax, and a concrete example. This is exemplary parameter documentation.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb+resource: 'Seed mock, test, or relational data rows into the database.' It also explicitly contrasts with the sibling 'execute_query' by stating it should be used instead of raw SQL INSERT, making its purpose distinct.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

States 'When to use' and explicitly says 'PREFERRED and recommended tool for inserting data records' and 'Use this instead of executing raw SQL INSERT statements.' It also gives reasons: handles dependencies, resolves IDs, ensures safe transactions. This clearly differentiates from siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A4.4/5.0
Disambiguation5/5

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.

Naming Consistency5/5

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.

Tool Count5/5

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.

Completeness5/5

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

ActivityMaintained
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables LLM agents to perform complete database operations on SQLite databases, including creating tables, executing queries, and managing data through CRUD operations with schema inspection capabilities.
    32
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to connect to and interact with PostgreSQL, MySQL, SQLite, and MongoDB databases through natural language, supporting schema exploration, query execution, data export, and more.
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Generates realistic, referentially-coherent test data (SQL INSERTs, JSON, or CSV) from your database schema, resolving foreign keys and respecting constraints. Paste CREATE TABLE DDL or a JSON schema and get ready-to-run seed data with valid relationships.
    2
    87
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/NamanT98/DB-Seeder'

If you have feedback or need assistance with the MCP directory API, please join our Discord server