Skip to main content
Glama
Elekto MCP for SQL Server

Elekto MCP for SQL Server

Official

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
MCP_SQL_CONNECTIONSNoFallback environment variable containing the JSON connections configuration directly. Used if --connections is not supplied. Provided for backward compatibility; the file-based approach is recommended.

Instructions

Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.

No database connection is configured: none of the places this server reads holds a connection string. Until that is fixed, every tool of this server answers with ok: false and the steps to fix it. Call list_databases for those steps, the file to create (/app/.elekto.mcp.sql.local.json) and an example of its content. The server looks again on every call, so once the file is in place no restart is needed.

Read-only access to the SQL Server databases configured for this server. Start with list_databases: every other tool takes one of its names as 'database'. Then get_database_overview to size a database up; list_tables, list_views, list_procedures, list_functions and find_columns to locate objects; get_table_schema and the get_*_definition tools for their structure and code; get_table_usage and get_dependency_graph for impact analysis; query_table and get_data_profile to read data. When a query is slow or its plan changed, list_query_store_regressions, find_query_store_queries, get_query_store_history and get_query_plan_summary read the Query Store's history of queries and plans; find_cached_queries reads SQL Server's plan cache, the source left where the Query Store is off, as it is by default before SQL Server 2022; and get_active_requests shows what runs now and who blocks it. get_table_statistics and get_optimizer_settings show what the optimizer was told, and get_estimated_plan compiles a procedure for given values, or a SELECT, to show the plan it would get now. SQL Server leaves out, without any error, objects the login has no permission on, so when a result looks short call check_permissions. A failure comes back as content with ok: false, an error, a hint and usually an example; correct the call from them rather than retrying it unchanged, unless the hint says that nothing in the call is wrong, as when the connection to SQL Server failed.

Capabilities

Features and capabilities supported by this server

Protocol revision2025-11-25

CapabilityDetails
tools
{
  "listChanged": true
}
logging
{}

Tools

Functions exposed to the LLM to take actions

NameDescription
list_databasesA

Lists the logical database names this server is configured to reach, with each one's row limit and command timeout. Call it first: every other tool, starting with get_database_overview, takes one of these names as its 'database' argument. It reads only the server's configuration and never connects to SQL Server; when nothing is configured it answers ok: false with the file to create, where the server looked and an example.

get_database_overviewA

Summarizes one database: real name, server and instance, connected login, counts of tables, views, procedures, functions and schemas, and allocated size in MB. Use it after list_databases to size up a database before exploring it; for the same figures per schema use get_schema_summary. Counts cover only what the login can see: 'visibility.complete' is false when SQL Server hides objects, and check_permissions then says which GRANT is missing.

check_permissionsA

Reports what the connected login can and cannot see in a database: identity, roles, effective permissions, server version and, for each group of tools, whether it sees everything ('complete'), only part ('partial') or nothing ('unavailable'), with the missing permission and the GRANT that adds it in this server version's syntax. Also reports 'write_access', so an account meant to be read-only can be verified rather than assumed. Call it when a listing looks short, a definition comes back hidden, get_database_overview reports incomplete visibility, or a tool fails with a permission error: SQL Server leaves out what a login cannot see without raising any error.

list_schemasA

Lists the user schemas of a database with their owners, leaving out system schemas. Use it to learn the names the 'schema' filter of the other tools accepts; for object counts and sizes per schema use get_schema_summary instead.

list_tablesA

Lists user tables with schema, approximate row count, data and index size in MB, and creation and modification dates. Use it to find tables by name or schema and to spot the large ones; to find tables by a column they hold use find_columns, and for one table's columns and keys use get_table_schema. Narrow large databases with schema and name_pattern.

get_table_schemaA

Returns the full structure of one table or view: columns with an unambiguous type_declaration (such as 'nvarchar(250)'), max_length_chars, every extended property, computed-column definitions and whether they are persisted; plus primary key, foreign keys, check and unique constraints, and indexes with key column order and declared key width, leaving hypothetical ones to get_index_health. Call it before query_table to learn exact column names and types; for a view's SQL text use get_view_definition. max_length is the raw sys.columns value in BYTES, so reason about text length with type_declaration or max_length_chars.

find_columnsA

Finds every table and, by default, every view holding a column whose name matches a pattern, with each column's type_declaration and nullability. Use it to answer 'which objects have this column?' before a rename, a widening or an impact review; to find objects by their own name use list_tables or list_views.

list_viewsA

Lists user views with their schema. Use it to find views by name or schema; for a view's columns and SQL text use get_view_definition, and for tables use list_tables. Narrow large databases with schema and name_pattern.

get_view_definitionA

Returns the CREATE VIEW text of one view together with its columns, in the same detail as get_table_schema. Use it to see how a view derives its data; for the objects it reads from use get_dependency_graph. A view the login can see but not read comes back with definition null and definition_visible false, which check_permissions explains.

list_proceduresA

Lists the user stored procedures the login can see, with line count, join count and number of referenced objects as rough complexity metrics. Use it to find procedures and pick the complex ones; for one procedure's text use get_procedure_definition. definition_visible is false, and the metrics null, for a procedure whose text is hidden from the login; referenced_object_count is null when the login cannot read dependencies. SQL Server leaves out procedures the login has no permission on without an error: get_database_overview says whether that happens, check_permissions why.

get_procedure_definitionA

Returns the CREATE PROCEDURE text of one stored procedure. Use it to read or review a procedure found with list_procedures; this server never executes procedures. A procedure the login can see but not read comes back with definition null and definition_visible false.

list_functionsA

Lists the user-defined functions the login can see (scalar, inline table-valued and multi-statement table-valued), with the same complexity metrics and visibility flags as list_procedures. Use it to find functions; for one function's text use get_function_definition. SQL Server leaves out functions the login has no permission on without an error: get_database_overview says whether that happens, check_permissions why.

get_function_definitionA

Returns the CREATE FUNCTION text of one user-defined function. Use it to read or review a function found with list_functions; this server never executes functions. A function the login can see but not read comes back with definition null and definition_visible false.

query_tableA

Runs a SELECT on one table or view, with optional column list, filter, ordering, grouping, aggregates (COUNT, SUM, AVG, MIN, MAX), pagination and random sampling, and returns the rows in an object with row_count and a measured 'truncated' flag, so a short result is never mistaken for a complete one. Rows are capped by the database's max_query_rows. Call get_table_schema first for exact column names; for null ratios, distinct counts and frequent values use get_data_profile instead of paging through rows. Reads actual data; never runs INSERT, UPDATE, DELETE or procedures.

get_schema_summaryA

Summarizes each schema of a database: counts of tables, views, procedures and functions, approximate rows and estimated data and index size. Use it to see where a database's weight lies before exploring or planning a refactoring; for whole-database totals use get_database_overview, and for the tables of one schema use list_tables.

get_dependency_graphA

Returns the dependency edges between database objects as data: foreign keys between tables, and references among views, procedures and functions. Use it to analyze dependencies programmatically; for a diagram use generate_dependency_dot, and for what references one table use get_table_usage. Fails, saying so, when the login cannot read sys.sql_expression_dependencies; without VIEW DEFINITION the module edges cover only modules the login can read.

get_table_usageA

Lists everything that references one table: foreign keys to and from it, and the views, procedures and functions whose code uses it. Use it for impact analysis before changing a table; for the dependency graph of the whole database use get_dependency_graph. sql_module_usage is null when the login cannot read dependencies, and 'visibility' says when the list may be incomplete.

get_data_profileA

Profiles the columns of one table or view: null ratio, distinct count, minimum, maximum and most frequent values. Use it to learn how data is distributed without paging through rows with query_table. It reads actual row values and scans the table, so on a large table it can take a while; limit it to the columns you need.

get_index_healthA

Reports index health by schema: duplicate index candidates, unused indexes, missing-index suggestions, and hypothetical indexes, which the Database Engine Tuning Advisor leaves behind and no query uses. Two B-tree indexes are duplicates with the same keys in the same order, in the same directions or all reversed, the same included columns in any order and the same filter; each pair says whether each index is unique and whether it is clustered, and indexes behind primary keys and unique constraints are not compared. Use it when reviewing indexing or slow queries; for one table's indexes use get_table_schema. Unused and missing indexes come from server DMVs, which reset when SQL Server restarts; without VIEW SERVER STATE they come back null and 'visibility.unavailable' says why, while duplicates and hypothetical indexes are still reported.

get_table_statisticsA

Lists the optimizer statistics of one table or indexed view: for each, its columns, when it was last updated, rows and rows sampled, modifications since then and how many remain before an automatic update (null for NORECOMPUTE, with automatic updates off, for hypothetical indexes, and for incremental or never-built statistics). With 'statistic', also that statistic's histogram and density vector; with 'value', where that value falls in the histogram, and only the steps around it. Use it when an estimate looks wrong or a plan changed, to see what the optimizer was told about the data without reading it; for the real distribution use get_data_profile, which scans the table, and for the settings that decide automatic updates use get_optimizer_settings. The contents need SELECT on the table; each statistic says whether the login could read them.

get_optimizer_settingsA

Reports the settings that change how SQL Server compiles queries in one database: the compatibility level and the cardinality estimator it implies, automatic and asynchronous statistics updates, forced parameterization, every database scoped configuration (MAXDOP, LEGACY_CARDINALITY_ESTIMATION, PARAMETER_SNIFFING and the rest) with whether it is the default, the Query Store state, and on the server max degree of parallelism, cost threshold for parallelism and the global trace flags. Use it when a plan changed, or differs between two servers; for one table's statistics use get_table_statistics. A section that cannot be read comes back null, and 'visibility' says why.

list_query_store_regressionsA

Finds the queries that got slower or heavier, vary the most or changed plan, from the Query Store: it compares each query's recent window with the days before it, as SSMS's Regressed Queries and Queries With High Variation reports do, and returns per query the executions and the average and maximum of the metric in each window, their ratio, the plans used in each window, whether the dominant plan changed, the plans compiled in the recent window and the aborted or failed executions in it. The variants of a parameter-sensitive query (SQL Server 2022+) count under it. Use it first when a query or a process got slow; for one query's full history use get_query_store_history, and to find a query by its text or procedure use find_query_store_queries. Needs VIEW DATABASE STATE (2022+: VIEW DATABASE PERFORMANCE STATE), which VIEW SERVER STATE implies.

find_query_store_queriesA

Finds Query Store queries by part of their text or by the procedure, function or trigger that runs them; with neither, the ones that took the most time in the window. Returns each one's query_id, the first 300 characters of its text, its number of plans, its executions in the window with their total and average duration, CPU and logical reads, maximum duration and failed executions, and its last execution. The variants of a parameter-sensitive query (SQL Server 2022+) count under it. Use it to get the query_id that get_query_store_history takes; to find what got slower use list_query_store_regressions. Needs VIEW DATABASE STATE (2022+: VIEW DATABASE PERFORMANCE STATE), which VIEW SERVER STATE implies.

get_query_store_historyA

Returns the Query Store history of one query: its text (the first 4000 characters); the SET options it compiled with, such as ARITHABORT, which explain a query fast in SSMS and slow in the application; its plans (the 20 that ran most in the window, when it has more) with when each was first and last compiled and whether it is forced; and, per plan and per day, hour or Query Store interval, the executions (aborted and failed ones included, and also counted apart), average and maximum duration, average CPU, logical and physical reads, average and maximum DOP, and average rows, memory and tempdb, plus each plan's waits by category over the whole window. Use it with a query_id from list_query_store_regressions or find_query_store_queries; to see what a plan does use get_query_plan_summary with its plan_id. The Query Store keeps each plan's first and last compile time, not every recompilation.

find_cached_queriesA

Lists this database's statements in SQL Server's plan cache, leaving out the queries this server sends to read the cache and the sessions, with what their runs cost since each plan was cached: per statement, when its plan was compiled and how many times (plan_generation_num), its last run, executions, total, average, maximum and last duration, CPU and logical reads, physical reads, rows, degree of parallelism, memory grant and spills, the query and plan hashes, the first 300 characters of the statement, and the plan_handle with the statement's offsets, which get_query_plan_summary takes. With object_name, the statements of that procedure, function or trigger, the variants SQL Server 2022+ keeps of a parameter-sensitive one included, and the totals SQL Server keeps for a procedure, scalar function or trigger. Use it when a query is slow and the Query Store is off, as it is by default before SQL Server 2022, or to see the plan in use now. The cache keeps no history: a plan evicted, recompiled or lost to a restart takes its figures with it, so where the Query Store is on use find_query_store_queries and get_query_store_history for what changed over days. Needs VIEW SERVER STATE (2022+: VIEW SERVER PERFORMANCE STATE).

get_active_requestsA

Shows what runs in this database now: each request of a user session but this tool's own, with its status, command, start and elapsed time, CPU and reads, the current wait and the resource it waits on (for a parallel request, the blocked worker's), with the table and index where the catalog names them, the session blocking it, open transactions and when the oldest began, degree of parallelism, memory grant, the procedure and the current statement (300 characters), query_hash, and the plan_handle with the statement's offsets for get_query_plan_summary; plus each chain of blocking up to its head, the session that blocks without being blocked, which can be idle with a transaction left open, or in another database, with the last batch it sent. Use it when something is slow or stuck right now; for what ran before use find_cached_queries or the Query Store tools, such as find_query_store_queries. It shows other sessions' login, host name, program and SQL text, which can carry literal values. Needs VIEW SERVER STATE (2022+: VIEW SERVER PERFORMANCE STATE): without it SQL Server shows a login its own session alone, so the call fails, naming the GRANT that adds it or the DENY that refuses it, rather than report nothing running.

get_query_plan_summaryA

Summarizes one execution plan instead of returning its XML, which can run to hundreds of thousands of characters: a Query Store plan by plan_id, or a plan in the plan cache by plan_handle, whole or the one statement its offsets pick out. Per statement (an IF or WHILE condition and each cursor operation count as one): estimated rows and cost, cardinality estimator version, whether the plan is parallel and why not when it is serial, memory grant, the parameter values the plan was compiled for, the statistics the optimizer used with their last update and modifications, the warnings, each with the operator it is on (implicit conversions, missing statistics or join predicates), missing-index suggestions, and the operators as a compact tree with object, index, seek, scan or lookup, predicates and join keys, estimated rows and share of the cost. Query Store and cached plans are estimated plans, so nothing measured at run time, such as spills, is in them. Use it with a plan_id from get_query_store_history or list_query_store_regressions, or a plan_handle from find_cached_queries or get_active_requests, and compare two plans of a query by summarizing each; for the statistics themselves use get_table_statistics. A plan_handle needs VIEW SERVER STATE (2022+: VIEW SERVER PERFORMANCE STATE).

get_estimated_planA

Compiles a stored procedure for the parameter values given, or one SELECT, under SET SHOWPLAN_XML ON, and summarizes the plan SQL Server would use now, as get_query_plan_summary does for a Query Store plan: per statement the estimated rows, cost and share of the whole, parallelism, the compiled parameter values, the statistics used, warnings, missing indexes and the costliest operators. Nothing runs (but for a deterministic CLR function with constant arguments, which SQL Server evaluates while compiling), and the plan is neither cached nor recorded by the Query Store; but compiling creates missing statistics and updates stale ones, as running would (with AUTO_UPDATE_STATISTICS_ASYNC the update is queued), and the answer names any it changed. When the procedure already has a plan in the plan cache, SQL Server returns that plan, compiled for the values of the run that cached it, and the answer says so (plan_from_cache). Use it to see the plan a procedure gets for given values, or how a rewrite or a hint changes a statement; for the plans that actually ran use get_query_store_history and get_query_plan_summary. A procedure that fills a temporary table with SELECT ... INTO and then reads it cannot be compiled without running: pass its statements in 'query' instead. Statements reading a temporary table or table variable are estimated as if it were empty, dynamic SQL is not compiled, and a CLR procedure has no plan to compile. Needs SHOWPLAN on the database, plus EXECUTE on the procedure or SELECT on what the query reads.

compare_schemasA

Compares the table and column structure of two configured databases, such as development and production: tables present in only one, columns present in only one, and columns whose type or nullability differ, each with its type_declaration so a difference reads as 'nvarchar(250) vs nvarchar(50)'. Use it to check a migration or detect drift. It compares tables and columns only, not views, code, indexes or data; to see one differing table in full, call get_table_schema on each database.

generate_dependency_dotA

Generates a Graphviz DOT diagram of the dependencies between database objects: an arrow runs from each table, view, procedure or function to the object it depends on, through a foreign key or a reference in its code. Returns the DOT text in 'dot', ready for 'dot -Tsvg', and the same graph as 'nodes' (with node_kind) and 'edges' (with dependency_kind). Use it to draw the graph; for the edges alone use get_dependency_graph, and for what references a single table use get_table_usage. A whole database makes an unreadable diagram, so narrow it with schema. 'visibility' says when references from code are missing for lack of permission.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

TDQS

A4.4/5.0

Scored across 30 tools

Disambiguation5/5

Despite 30 tools, each has a sharply distinct target/action pair, and descriptions explicitly route between near-neighbours (get_query_plan_summary vs get_estimated_plan, find_query_store_queries vs list_query_store_regressions, get_table_statistics vs get_data_profile, get_dependency_graph vs generate_dependency_dot vs get_table_usage). An agent can reliably pick the right tool from the guidance alone.

Naming Consistency5/5

Every name is snake_case verb_noun with a small, predictable verb vocabulary (list_, get_, find_, query_, check_, compare_, generate_) plus a resource noun. No mixed conventions or camelCase anywhere.

Tool Count3/5

The domain is genuinely broad (catalog exploration, statistics, Query Store, plan cache, plans, dependencies, comparison), so most tools earn their place, but 30 exceeds the well-scoped range and there is type-driven repetition (list_/get_definition for tables, views, procedures and functions separately). It feels heavy even if defensible.

Completeness4/5

Coverage is strong for a read-only inspection server: exploration, data reads, profiling, stats, index health, Query Store, plan cache, live requests, plan summaries and dependency analysis are all present, with permission fallbacks documented. Minor gaps remain (triggers cannot be listed or defined, no server-wide wait/CPU view, no index-definition or synonym/sequence tools).

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues