Repository navigation
Description
Problem
Developers want an agent in Claude Code to query SQL Server family databases: their own local
instance or container, and shared remote ones (development, test, staging, production, often Azure
SQL Database). The agent is most useful when it can write free-form read queries against whatever
database is relevant, and occasionally make a change. Today that is unsafe or impractical:
- Writes and harm are too easy. A server that runs arbitrary SQL lets an agent, or a prompt
injected through data it reads, change or destroy data. Hiding write tools is not enough: in at
least one server examined, hidden tools were still callable by name. A read can also harm without
writing: take locks that block an application, hold a transaction open, run a parallel scan that
starves a shared elastic pool, or leave session state on a pooled connection that the next query
inherits. - Per-call write gating is awkward. Claude Code permission rules match tool names, not tool
arguments, so one "execute SQL" tool cannot be allowed for SELECT and asked for UPDATE by rule
alone. Per-call human approval has to be expressed at tool granularity or by the server. - Many databases, many registrations. Teams register one server per environment (the reporter
had seven, plus a separate local one in another language), each with its own secrets, permission
rules and agent tool lists. Switching, adding, or scoping an automated agent to one environment
is manual and error-prone. - Secrets leak. Connection strings end up literal in config files agents can read or that get
committed. - Nothing fits (see Evidence).
- Machine- and org-specific assumptions. Servers assume one OS, one auth method, one config
location, or bake in names that fit one team.
No plugin on origin/main ships a database MCP server (at 0c5fd2898, the only plugin .mcp.json
files are plugins/dometrain-mcp/.mcp.json and plugins/miro/.mcp.json, and no plugin manifest
declares mcpServers). No existing issue covers it.
Goal
A Claude Code plugin in this repository, shipping its own MCP server(s), that lets an agent query
SQL Server family databases safely by default and flexibly by configuration, for any user, machine,
organization, company, project, folder or repository.
This issue deliberately prescribes no design. Tool set, configuration shape, language, driver,
validation technique and enforcement layers are open. Prior art below is evidence, not a spec.
Requirements
Safety (non-negotiable)
- S1. Read-only unless explicitly opted in, enforced by the server on every call, not by which tools
happen to be listed. - S2. No way to change data, schema, or server/session state through the read path.
- S3. No harm through reads: no lock contention or blocking, no transaction or session state left
behind, no runaway resource use on shared databases. Controls chosen for this must themselves be
proven not to cause locking or performance problems; research and test them locally before they
become defaults. - S4. Writes, where enabled, are human-approved per call by default, in a way Claude Code enforces
regardless of permission mode; a no-prompt mode exists only as an explicit opt-in for environments
the user deems safe (for example a disposable local database). - S5. Automated agents can be confined to specific databases/environments and cannot widen their
own scope at runtime. - S6. Secrets never appear in plugin or registration config; connections come by reference.
- S7. The set of tools a registration exposes never changes as a side effect of a tool call.
Flexibility
- F1. Agnostic: Windows, macOS, Linux (incl. WSL); SQL Server (any supported version), Azure SQL
Database, Azure SQL Managed Instance, containers; TCP; the auth methods those support (SQL login,
Entra ID variants, integrated where the platform allows). - F2. Many databases and environments from one installation; adding or switching one is config.
- F3. Every behavior a team might want differently is a customization point with a safe default:
which databases, read/write posture, approval mode, validation strictness, resource and session
limits, logging/audit, config locations at user, project and repository levels with documented
precedence. Extension points where teams need their own logic. - F4. Nothing organization-specific ships; the consumer supplies all names and values.
- F5. Client-agnostic: usable from Claude Code, Cursor and other MCP clients. Safety guarantees must
not depend on one client's features (auto mode, permission rules, hooks); client-specific gating
may be offered as optional adapters. - F6. Works across many git worktrees, cloud or remote environments and concurrent sessions: several
sessions each starting their own server process against the same local database must not contend
for connections, locks or shared state. - F7. Stable, consumer-chosen registration and tool names, so permission rules and agent tool lists
survive upgrades. Note: MCP servers shipped inside a plugin are exposed as
mcp__plugin_<plugin>_<server>__*, which renames every tool relative to a user-scope registration. - F8. Deterministic validation is a known weak spot (false positives and misses), and the reporter
is skeptical of relying on it. State what the real guarantee is; label anything heuristic. - F9. An open contract every client can adhere to: a published, versioned configuration schema and a
tool surface in MCP-standard terms only; client-specific gating documented as optional adapters.
Consumers define their own environments; nothing about environments is built in. - F10. Measure before choosing process topology: per-session processes isolate sessions best, only
a shared process can cap total load across sessions; decide with data.
Product
- P1. Ships in the marketplace as its own MCP server(s) with setup guidance (a setup skill or
equivalent), tests, and documentation that states the safety guarantees and their limits honestly. - P2. Maintainable long term: the plugin owns its code. Microsoft's MIT-licensed MssqlMcp sample,
removed upstream by Azure-Samples/SQL-AI-samples PR chore(conventions): add ecosystem-commands contract; record concern-named config seam #96 (merged 2026-06-03), is available as prior
art in that repository's history; using it is optional.
Evidence
Carried from research the reporter ran on 2026-09-28 (fresh-context verifier: PASS-WITH-NOTES). This
pass read the four index summaries and the Claude Code mechanics section only, not every sidecar.
Ratings are the research's; recommendations in it were framed around a different project and are
deliberately not carried.
Claude Code mechanics (HIGH, Claude Code 2.1.283, code.claude.com/docs/en/permissions,
/permission-modes, /mcp, /hooks):
- Permission rules address MCP tools as
mcp__<server>ormcp__<server>__<tool>; settings-file
mcp__rules with parentheses are skipped, so settings cannot match tool arguments. Order is
deny, then ask, then allow. - An explicit
askrule prompts in manual, auto and bypassPermissions modes; indontAskthe call
is denied. APermissionRequesthook can answer it. _meta["anthropic/requiresUserInteraction"]: trueon a tool (2.1.199+, JSONtrueonly) forces a
prompt on every call in every mode, offers no "don't ask again" (fixed in 2.1.246), is denied in
dontAsk, and a--permission-prompt-toolallow becomes a deny. Consequence: a flagged tool is
unusable in headless ordontAsksessions.- Elicitation (2.1.76+; URL mode 2.1.281+) can ask for typed confirmation mid-call, but an
Elicitationhook can auto-answer it, so it is a weaker gate. - A PreToolUse hook can match
mcp__server__.*and readtool_inputto gate on an argument; hook
allownever skips ask/deny rules orrequiresUserInteraction. ${VAR}and${VAR:-default}expand incommand,args,env,url,headersfor local,
project and user scopes; display surfaces show the placeholder, not the value.- Tool annotations (
readOnlyHint,destructiveHint) are display-only and untrusted, not a gate. - MCP spec revision 2026-07-28 (modelcontextprotocol.io/specification/2026-07-28/server/tools): a
server'stools/listMUST NOT vary per connection or as a side effect of other requests (it MAY
vary by authorization). A "switch profile" call that adds or removes tools is non-conformant.
Landscape (HIGH unless noted):
- Microsoft ships no free-form SQL Server MCP. Data API builder SQL MCP Server (GA 2.0.12) exposes
entity DML and stored-procedure tools and excludes NL2SQL by design. Azure MCP Server
3.0.0-beta.47 has 13 Azure SQL control-plane tools and none that runs T-SQL. - alyiox/mcp-mssql 1.6.1 (.NET): ScriptDom parser validates one batch with one SELECT and rejects
SELECT INTO, variable assignment, OPENROWSET/OPENQUERY; a separate write tool stays registered
and refuses on read-only profiles; per-call profile argument; no_metaflag; one maintainer. - bytebase/dbhub 1.3.1 (Node, MIT): SQL Server reads use a regex keyword classifier plus an
always-rolled-back transaction;execute_sqlis writable unless configuredreadonly; one tool
pair per source (execute_sql_<source>), bare names for a single source;tools/listfixed per
stdio connection while a config watcher changes behavior live;${VAR}secrets; SQL login, NTLM,
and a one-shotDefaultAzureCredentialtoken with no refresh;sslmode=requiredoes no
certificate verification. Three read-only bypasses were fixed in 2026. Its own docs call a
read-only database login the real boundary. - ConnorBritain servers: regex blocklist plus SELECT-prefix check, no parser, no transaction.
- Google MCP Toolbox
mssql-execute-sql: no read-only enforcement. - 60+ other community projects fail server-enforced reads, a separate write path, or stable tools,
or are stale (MEDIUM: not re-derived one by one).
Read safety (Microsoft Learn, MS-TDS, node-mssql 12.7.2 and tedious 20.3.3 source; HIGH unless
noted):
- RCSI is on by default in Azure SQL Database and off in SQL Server (including the Linux container),
so plain reads take shared locks on SQL Server. - An open transaction costs round trips and holds back version-store cleanup; sequences, identity
values and table variable changes survive a rollback. Linked-server and extended-procedure side
effects surviving rollback are MEDIUM and unverified. - node-mssql never resets session state on pooled reuse:
SEToptions carry over, and an orphaned
transaction is inherited by the next borrower. Pool validation runsSELECT 1per acquire unless
validateConnection: 'socket'. SET XACT_ABORT ONrolls back an open transaction on a client attention (timeout); OFF leaves it
open (Sommarskog, Error Handling Part 2).- Only a least-privilege database principal guarantees no data change. Other controls ranked by the
research: request timeout with explicit rollback or connection discard,LOCK_TIMEOUT, a
statement reject list (single statement, noUSE,EXECUTE AS/REVERT, cursors,RECEIVE, user
OPTION (...),CHECKPOINT/SHUTDOWN/RECONFIGURE), a streaming row cap that cancels promptly
(a paused partial read holds locks and a worker), pinned isolation, a small pool,MAXDOP 1and a
memory-grant cap where Resource Governor is unavailable,appNamefor identifying agent sessions. - Controls can harm: an always-rolled-back wrapper widens the orphaned-transaction window on
timeout unless XACT_ABORT is on and every batch starts with a rollback guard. - Write-tier controls: separate write principal; no transaction held open across human approval;
one guarded batch with a row-count check; preview should list triggers and cascading foreign keys,
since@@ROWCOUNTsees only the target table. - Azure SQL elastic pools are often shared by many databases across environments, so a heavy
non-production query can starve others. Read scale-out exists only on Premium, Business Critical
and Hyperscale tiers. - Gaps: several control claims rest on Microsoft-only sources; the T-SQL bypass list is inference,
not tested; Entra token refresh for long-lived pools is unresearched.
Proposed approach
Process, not design: run it through this repo's pipeline under its own interview.
/planning:interviewwith the reporter to lock goals, environments in scope for a first release,
and which requirements are first-release versus later./planning:designfor the open questions below, then/discovery:researchon the gaps.- Measure process topology locally (F10) and test read-safety controls against a local SQL Server
container (S3) before choosing defaults. /planning:plan, then implement with tests and/mcp-tools:auditon the tool surface.
Open design questions:
- What is the real guarantee for S1/S2: a read-only principal, a parser, a rollback wrapper, or a
combination; which parts are labeled heuristic (F8)? - How S4 is met per client (F5):
requiresUserInteractiononly on write tools, elicitation, separate
write registrations, or adapters; and how headless agents that must never write are served. - How S5 and S7 coexist with F2: profiles fixed per registration, a constant tool set that refuses,
or per-authorization tool lists. - F7 versus plugin-scoped tool naming (
mcp__plugin_<plugin>_<server>__*): plugin-shipped server,
a setup skill that registers user-scope servers, or both. - Language and driver, auth coverage (F1), and the published config schema (F9).
Acceptance criteria
- Interview and design artifacts record a decision for each open question above.
- A first release ships as a plugin with its MCP server(s), a setup skill, and docs stating
every safety guarantee and its limits. - Tests prove: a write attempt through the read path is refused on every call (S1/S2); tools/list
is identical before and after any tool call (S7); no secret appears in plugin or registration
config (S6); a confined registration cannot reach another database (S5). - Read-safety defaults are backed by a recorded local measurement showing they cause no
blocking (S3). - Config schema is published and versioned (F9); nothing organization-specific ships (F4).
Constraints and gotchas
- Clean-room: do not base the design on any private fork, its patches, configuration, or internal
names. The evidence above is public-source findings only. - A
requiresUserInteractiontool is denied indontAskand headless sessions; never flag a read
tool. - Plugin MCP tool names carry the plugin prefix; consumers' permission rules must be written against
the shipped names. - Never put a live connection string in a test or fixture.
Context
Source: local handoff item 20260928-sql-server-mcp-plugin.md (retired into this issue). It supersedes
candidate 6 of the guard-generalization epic in this repository. The reporter asks to be told when a
first release is installable, so the local setup can move to it one environment at a time.
Sub-issues
Collapse Sub-issuesSub-issues
Metadata
Metadata
Assignees
Labels
Type
Fields
Work status
Activity
kyle-sexton commentedon Oct 24, 2026
Decision recorded. Owner, Backlog HITL session, 2026-10-24. Q96: "Should the first release of the SQL Server MCP plugin be read-only (a local container and Azure SQL Database), with write access filed as a later sub-issue?" Answer: "go w/ recommendations" (yes).
kyle-sexton commentedon Oct 25, 2026
This was generated by AI.
Releasing the hold. This issue is a split parent: its work lives in its sub-issues. The hold was kept until admission refused a parent with open sub-issues, and that guard is now on main:
.github/scripts/intake-triage/admit.mjs:438-441("A split issue's work is its sub-issues' (owner Q93)"), so admission waits while any sub-issue is open.refine.mjs:292also declines to split an issue that already has sub-issues.needs-humancomes off. Nothing is re-queued: the parent stays open as the tracker until its sub-issues close.This split was filed by hand, so it has no lanes App split record, and work-unblock's
closeSplitParentwill not close it on its own when the last sub-issue closes. That gap is reported to the coordinator.19 remaining items
test(sql-server): ground the blocking measurement in the research
docs(sql-server): restore the bounded-blocking paragraph lost to the …
fix(sql-server): report waits on agent sessions with and without queu…
kyle-sexton commentedon Nov 6, 2026
Close audit: every done-when item met on
origin/mainat7c173b7; all 7 sub-issues closed COMPLETED.Sub-issues (R233), each
state_reason: completed: #9805 (ADR), #9849 (server and config schema), #9878 (local container proof), #9892 (read-safety measurement), #9898 (setup skill and Azure docs), #9905 (Azure SQL Database verification), #9909 (write tier).plugins/sql-server0.6.0: stdio server (src/server.mjs,src/main.mjs), setup skill (skills/setup/SKILL.mdwithcheck-setup.mjsandinstall-server.mjs), andREADME.md, whose guarantee table labels each control guarantee or heuristic and whose limits section now states the read path as bounded blocking with its preconditions.npm test, 218 of 218 at the merge head):test/server.test.mjs"the reject list on query" (S1/S2), "tools/list ... returns the same list on repeated calls, before and after a tool call" (S7), "the database allow-list ... refuses a database outside the list" (S5);test/config.test.mjs"loadConfig refuses a literal password / connection string" (S6). Integration (integration/read-path.mjs): passed against a local container (test: prove the SQL Server MCP read path against a local SQL Server container #9878) and against Azure SQL Database, where every S1/S2, S5, S6 and S7 line read PASS (run record).reference/read-safety-measurement.md, regenerated by test(sql-server): attribute read-safety blocking by waiter and blocker #13761 against SQL Server 2025 CU10 over 3 topology runs: "Bounded-blocking check: PASS". Every call returned; the longest agent lock wait was 66 ms againstlockTimeoutMs5000; the longest wait on an agent session not itself waiting was 16 ms againstrequestTimeoutMs30000; the writer never waited on an agent session; no transaction was left open after a topology run or a forced timeout (request timeout after 30150 ms, 0 open). The worst case over the runs is stated, andtest/measure-read-safety.test.mjsfails if the committed record loses the passing check.schemas/config.v1.schema.json($idat its raw URL;schemaVersionrequired, "a breaking change raises it"). A grep ofplugins/sql-serverfor organization names finds only the publisher identity inplugin.json, the marketplace install line, the schema$idand doc links, and Microsoft'scontoso.complaceholder; every environment, server and credential name comes from the consumer's config.Closing as completed.
fix(sql-server): say the lock timeout bounds each lock wait, not a call
kyle-sexton commentedon Nov 6, 2026
Decision recorded.
Owner, session "Feature: SQL Server MCP", 2026-11-06.
Why: a call that reaches
lockTimeoutMsorrequestTimeoutMsfails its query, and the measurement'sserverProcessthrows, so the run ends before any result is written. A written result therefore can never show either clause failing. The measured writer-on-agent wait was 0 ms in all 12 runs, and no source read sets an acceptable writer delay, so no writer-wait limit is set.This narrows the criterion 4 wording recorded in the 16:52Z decision. Criterion 4 now reads:
lockTimeoutMsandrequestTimeoutMs(a call that does not ends the run), no transaction is left open after a call, and the worst case over the runs, including how long any session waited on an agent session, is stated. No writer-wait limit is set or checked.The wording change is in #13791; the measured values from #13761 are unchanged.