db-tools-mcp
An MCP server that exposes SQL Server and Snowflake schema metadata to AI coding agents, enabling schema exploration, join path discovery, stored procedure management, and database administration — primarily using a local cache to avoid live queries on every request.
Schema & Metadata Exploration
list_sources,list_schemas,list_tables,get_table,get_dialect,list_all_foreign_keys— browse database sources, schemas, tables, columns, FK relationships, and SQL dialect without live queries
Join Path Discovery
find_direct_joins— find FK-defined direct joins between two tablessuggest_joins— suggest multi-hop join paths using FK graph and heuristic column matching, ordered by confidence
Search
search_tables— search for tables by keywordsearch_columns— search for columns by name across a source or within a specific schema
Stored Procedure Tools
list_stored_procedures,get_stored_procedure,search_stored_procedures,search_stored_procedure_text— list, inspect, and search procedures by name or body textget_call_template— generate a ready-to-use SQLEXECor Pythonpyodbccall templateexport_stored_procedure— write a stored procedure's SQL definition to a file
Live (Uncached) Tools
get_live_stored_procedure— directly connect to any SQL Server via Windows auth to fetch a stored procedure's definition and metadata, bypassing the cache
Admin & Configuration
add_database— register a new SQL Server or Snowflake source with connection details and optional live connection testing (requires user confirmation before modifying config)refresh_metadata— re-scan live databases to update the local schema cache (throttled to once per 24 hours; supports forced refresh)
Provides connectivity to Snowflake databases through a SQL Server linked server, enabling schema exploration, table/column metadata retrieval, foreign key discovery, and stored procedure management without executing live queries on every request.
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., "@db-tools-mcp list tables in dbo schema"
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.
db-tools-mcp
MCP server that exposes SQL Server and Snowflake schema metadata to AI coding agents. It caches table/column/FK information locally and provides tools for searching schemas, finding join paths, and managing database connections — without running live queries on every request. A separate live-lookup tool is available for one-off stored procedure queries against a database directly.
Quick start
1. Install and run with uvx
uvx db-tools-mcpOr install with pip:
pip install db-tools-mcp
db-tools-mcpOr install locally for development:
git clone https://github.com/urjeetpatel/db-tools-mcp.git
cd db-tools-mcp
uv sync
uv run db-tools-mcp2. Register with your MCP client
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"db-tools": {
"command": "uvx",
"args": ["db-tools-mcp"]
}
}
}Claude Code (.mcp.json in your project root):
{
"mcpServers": {
"Db_Tools": {
"command": "uvx",
"args": ["db-tools-mcp"]
}
}
}3. Add your first database
Use the add_database tool through your MCP client:
add_database(
name="my_db",
db_type="sqlserver",
url="mssql+pyodbc:///?odbc_connect=DRIVER=ODBC Driver 17 for SQL Server;Server=myhost;Database=MyDB;Trusted_Connection=Yes;"
)Or copy the example config manually:
# Linux / macOS
mkdir -p ~/.config/db-tools
cp config.example.yaml ~/.config/db-tools/config.yaml
# Windows (PowerShell)
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.config\db-tools"
Copy-Item config.example.yaml "$env:USERPROFILE\.config\db-tools\config.yaml"Then edit ~/.config/db-tools/config.yaml with your connection details.
4. Populate the cache
refresh_metadata() # all sources
refresh_metadata(source="my_db") # one sourceOr from the command line:
uvx db-tools-refresh
db-tools-refresh --source my_db # if installed locallyRelated MCP server: snowflake-mcp
Tools
Read tools (safe, use cached data)
Tool | Description |
| List cached database sources |
| List schemas in a source |
| List tables in a schema |
| Get columns + FK relationships |
| SQL dialect ( |
| All FKs in a schema |
| FK joins between two tables |
| Multi-hop join path suggestions |
| Search table names |
| Search column names |
Stored procedure tools
Tool | Description |
| List stored procedure names in a schema |
| Get SP metadata: parameters, dates, and definition |
| Search SP names (case-insensitive, optional schema filter) |
| Search SP body text for a keyword; returns matching procedures with a one-line excerpt |
| Generate a SQL or Python call template for an SP |
| Write SP definition (SQL only) to a file; returns resolved path + line count |
export_stored_procedure writes the raw SQL definition only — no JSON wrapper. The output_file must be an absolute path to a writable location; writes to system directories, network paths, drive roots, and the db-tools config directory are blocked.
Live (uncached) tools
Tool | Description |
| Connect directly to a SQL Server (Windows auth) and return an SP's definition + metadata, bypassing the metadata cache entirely |
| Connect directly to a SQL Server and return a two-way dependency map (what an object references, and what references it), bypassing the metadata cache entirely |
Unlike the stored procedure tools above, get_live_stored_procedure and get_live_dependencies do not use source from config — they open an ad-hoc Trusted_Connection to any servername/database you specify. Useful for one-off lookups or impact analysis against a database that isn't (or isn't yet) registered as a source. For both, if schema is omitted and the name is ambiguous or resolves against the wrong default schema, pass schema explicitly.
Admin tools (require confirmation)
Tool | Description |
| Add a source to config + test connection |
| Re-scan live databases (throttled to 1/day) |
Configuration
Config and cache live in ~/.config/db-tools/ (XDG standard):
~/.config/db-tools/
config.yaml # database connections
metadata_cache/ # cached JSON per source
.refresh_state.json # last-refresh timestamps
server.log # MCP server logsOverride the location with DB_TOOLS_CONFIG_DIR or XDG_CONFIG_HOME:
DB_TOOLS_CONFIG_DIR=/custom/path db-tools-mcpSupported source types
SQL Server (direct ODBC):
my_db:
enabled: true
url: "mssql+pyodbc:///?odbc_connect=DRIVER=ODBC Driver 17 for SQL Server;Server=host;Database=db;Trusted_Connection=Yes;"
include_schemas: ["*"]
exclude_schemas: [INFORMATION_SCHEMA, sys, db_owner, ...]Snowflake (via SQL Server linked server / OPENQUERY):
my_snowflake:
enabled: true
sqlserver_url: "mssql+pyodbc:///?odbc_connect=..."
linked_server: "SNOWFLAKE"
database: "MY_SNOWFLAKE_DB"
include_schemas: ["*"]
exclude_schemas: [INFORMATION_SCHEMA]Snowflake (direct connection, no SQL Server hop — requires pip install "db-tools-mcp[snowflake]"):
my_snowflake_direct:
enabled: true
db_type: snowflake_direct
account: "<account_identifier>"
user: "<snowflake_username>"
password_env_var: "DB_TOOLS_SNOWFLAKE_PASSWORD" # password read from this env var, never stored in config
database: "MY_SNOWFLAKE_DB"
warehouse: "MY_WAREHOUSE" # optional
role: "MY_ROLE" # optional
include_schemas: ["*"]
exclude_schemas: [INFORMATION_SCHEMA]Both Snowflake modes are also available through the add_database tool (db_type='snowflake' or db_type='snowflake_direct').
Requirements
Python >= 3.11
ODBC Driver 17 for SQL Server (for SQL Server and Snowflake-via-linked-server connections)
snowflake-connector-python(only for direct Snowflake connections —pip install "db-tools-mcp[snowflake]")Network access to the target databases
License
MIT
Available Tools
18 toolsadd_databaseA
Add a new database source to config.yaml and optionally test the connection.
db_type='sqlserver': url (required) -- SQLAlchemy connection URL, e.g.: "mssql+pyodbc:///?odbc_connect=DRIVER=ODBC Driver 17 for SQL Server; Server=myserver;Database=MyDB;Trusted_Connection=Yes;"
db_type='snowflake' (via SQL Server linked server + OPENQUERY): sqlserver_url (required) -- SQLAlchemy URL for the gateway SQL Server linked_server (required) -- Linked server name (e.g. "SNOWFLAKE") snowflake_database (required) -- Snowflake database (e.g. "MY_DB")
Common: include_schemas -- ["*"] for all (default), or explicit list exclude_schemas -- defaults to system schemas for the db_type test_connection -- set False to skip the live connection test
After adding, call refresh_metadata(source='') to populate the cache.
Inputs: name (required), db_type (required), url, linked_server, +5 more. Returns: object
export_stored_procedureB
Write the stored procedure definition (SQL code only) to a file.
Inputs: name (required), schema (required), source (required), output_file (required). Returns: object
find_direct_joinsB
Return FK-defined direct joins between two tables (either direction). Provide table names as 'schema.table' (e.g. 'dbo.Orders').
Inputs: source (required), table_a (required), table_b (required). Returns: result
get_call_templateA
Generate a ready-to-use call template for a stored procedure.
style='sql' — EXEC statement with typed placeholders for each parameter. style='python' — pyodbc script that executes the SP and collects every result set returned by the server using cursor.nextset().
Inputs: name (required), schema (required), source (required), style. Returns: result
get_dialectC
Return the SQL dialect for a source (e.g. 'mssql', 'snowflake').
Inputs: source (required). Returns: result
get_stored_procedureA
Get full metadata for a stored procedure: parameters, create/modify dates, and definition.
Inputs: name (required), schema (required), source (required). Returns: object
get_tableC
Get columns and FK relationships (inbound + outbound) for a specific table.
Inputs: table (required), schema (required), source (required). Returns: object
list_all_foreign_keysC
Return every foreign key defined in a schema.
Inputs: schema (required), source (required). Returns: result
list_schemasC
List all schemas for a given source.
Inputs: source (required). Returns: result
list_sourcesA
List all database sources available in the local metadata cache.
Inputs: no named parameters. Returns: result
list_stored_proceduresC
List all stored procedure names in a given schema.
Inputs: schema (required), source (required). Returns: result
list_tablesB
List all tables in a given schema.
Inputs: schema (required), source (required). Returns: result
refresh_metadataA
Refresh the local schema metadata cache by querying live databases.
THIS IS AN EXPENSIVE OPERATION — each source may take several minutes. Do NOT call automatically before reads. The cache is designed to be long-lived. Only call when:
No cache exists yet for a source (first-time setup)
The user explicitly says a schema has changed
Each source is throttled to one refresh per 24 hours. Set force=True ONLY when the user has confirmed recent schema changes.
Inputs: force, source. Returns: object
search_columnsB
Search for columns whose names contain column_name (case-insensitive). Optionally restrict to a single schema.
Inputs: source (required), column_name (required), schema. Returns: result
search_stored_proceduresA
Search for stored procedures whose names contain keyword (case-insensitive). Optionally restrict to a single schema.
Inputs: source (required), keyword (required), schema. Returns: result
search_stored_procedure_textA
Search the body (definition) of stored procedures for keyword (case-insensitive). Returns each matching procedure with a short excerpt showing the first line that contains the keyword. Optionally restrict to a single schema.
Inputs: source (required), keyword (required), schema. Returns: result
search_tablesB
Search for tables whose names contain keyword (case-insensitive).
Inputs: source (required), keyword (required). Returns: result
suggest_joinsA
Suggest join paths between two tables using FK graph + heuristic column matching. Results ordered by descending confidence. Table names as 'schema.table'.
Inputs: source (required), table_a (required), table_b (required), max_hops. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 18 tools
Most tools have distinct targets (tables vs. stored procedures vs. schemas), and names clearly indicate the resource. However, there are multiple search tools for different entities and some overlap between list and get operations, but descriptions mitigate confusion.
All tool names follow a consistent verb_noun snake_case pattern (e.g., list_tables, search_columns). No mixed conventions or vague verbs, making the set predictable for an agent.
With 18 tools, the server covers a broad set of database metadata operations without unnecessary bloat. The count feels appropriate for a comprehensive metadata exploration tool.
The tool set covers source management, schema browsing, table/stored procedure inspection, search, and join discovery. All typical metadata exploration tasks are present, with no obvious gaps for the stated purpose.
Maintenance
Related MCP Connectors
Shared memory for coding agents. Stop re-explaining your codebase every session.
Provides metadata information to AI agents through the search API.
Work with your database from AI tools: ask, export, approved changes, and scheduled jobs.
Review your AI agent's database changes on your schema, with plain-language risk, before they run.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to understand and query your database safely by providing a semantic layer of metadata, with tools to search, explain, validate, and generate safe SQL.2MIT
- AlicenseAqualityDmaintenanceEnables AI agents to execute SQL queries and explore Snowflake databases using natural language, with schema discovery, table inspection, and readonly mode.11152 npmMIT
- FlicenseNot gradedqualityCmaintenanceExposes SQL Server stored procedures as tools for LLM clients (Claude Desktop, VS Code, Cursor, etc.) enabling direct database interaction through natural language.-
- AlicenseNot gradedqualityBmaintenanceProvides a semantic intelligence layer for SQL Server databases, enabling AI agents to understand schema structure, relationships, and safely interact through policy-gated tools.3MIT