Skip to content

MCP (AI Agent Integration) ​

Let an AI agent explore and query a database through noorm, limited to the effective agent role on each config.

bash
noorm mcp init

This writes a Claude Code .mcp.json entry:

json
{
    "mcpServers": {
        "noorm": {
            "command": "noorm",
            "args": ["mcp", "serve"]
        }
    }
}

--agent cursor writes .cursor/mcp.json. Existing files keep their other server entries. Pair it with the agent skill: npx skills add noormdev/noorm/skills.

How does a request reach the database? ​

Each SQL call names its target. For a viewer on orders, the server permits a read and rejects a write before sending it to the database.

Protocol and request context ​

The stdio server speaks MCP 2026-07-28. The SDK rejects legacy initialization-based clients. Discovery uses server/discover; current requests carry io.modelcontextprotocol/protocolVersion and io.modelcontextprotocol/clientCapabilities in _meta. The stdio guard enforces the current version and metadata on requests.

Discover the 11 tools with tools/list. Call each by its own name, with flat arguments. list_configs takes {}; every other tool requires config.

ToolArguments besides configPurpose
list_configsnone; no configList visible configs and their dialects
overviewnoneSummarize database objects
listcategoryList objects in a category
detailcategory, name, optional schemaInspect one object
sqlqueryExecute SQL, subject to its classified permission
change_historyoptional limitList applied changes
change_runnameApply a named change
change_ffnoneApply pending changes in order
change_revertnameRevert a named change
run_buildoptional forceRun the configured build; force skips checksum checks
run_filepathExecute a project-relative SQL file

For example, a tools/call request's params can be:

json
{
    "name": "sql",
    "arguments": {
        "config": "orders",
        "query": "SELECT id FROM sales_order LIMIT 10"
    }
}

Choose SQL syntax for the target dialect and inspect the schema before querying; the example assumes a dialect supporting LIMIT and the named table and column. Unknown tools, invalid arguments, and a missing required config return JSON-RPC -32602; permission failures are tool results with isError: true.

Migration: Replace run_noorm_cmd calls with the command name as the tool name, move payload fields alongside config, and remove command and payload. Replace noorm_help with tools/list and its input schemas. Neither old tool is available.

There is no MCP connect, disconnect, or active-session status command. Each database request reloads encrypted state and project settings for its named config, then closes its connection when the request finishes. list_configs and resource discovery also load state per request. Existing clients must stop sending session commands and supply config on each database operation.

Prompt cookbooks ​

Use prompts/list to discover the following prompts and prompts/get to retrieve their user-role guidance. A user or application selects a prompt; it is not a tool for an agent to call. Retrieving one does not connect to or modify a database.

PromptArgumentsGuidance
noorm_getting_startedoptional configDiscover configs and select a target
noorm_explore_databaseconfigExplore objects and inspect details
noorm_query_databaseconfig, optional questionInspect schema and answer with dialect-aware SQL
noorm_apply_changeconfig, changeReview history and a named project change before applying it
noorm_build_databaseconfigReview project build inputs and run the build
noorm_run_sql_fileconfig, pathReview and run a project SQL file
noorm_automationtask, optional configWrite a headless script with explicit targets, JSON output, and failure handling
noorm_ciprovider, target (test or deploy), configSet up disposable test CI or a shared-database deployment pipeline

For example, prompts/get with {"name":"noorm_query_database","arguments":{"config":"orders","question":"Which orders are recent?"}} returns guidance to inspect the target and schema first. The client supplies the returned messages to the conversation. The agent then uses the actual tool results to choose a query; the prompt itself executes nothing.

For automation, pass the requested workflow as task, for example {"name":"noorm_automation","arguments":{"task":"Apply pending changes from a deployment script","config":"orders"}}. The cookbook covers headless commands, environment-only connections, exit codes, and the distinction between a script's confirmation flags and MCP human approval.

For CI, select the provider and pipeline shape: {"name":"noorm_ci","arguments":{"provider":"GitHub Actions","target":"test","config":"ci"}}. The config argument is required for both targets. Test guidance builds a disposable database and runs changes and tests, including stored test config bootstrap when the SDK requires it. Deployment guidance uses an enrolled CI identity and applies pending changes without rebuilding an existing database. config supplies the requested name when bootstrapping with ci init; an environment-only job must not pass a saved-config flag for a config that does not exist. See CI/CD Automation and Non-interactive operation for the underlying commands.

Permissions and human approval ​

The following table shows unmodified built-in roles. Project role overrides and custom roles can change these decisions.

CommandsPermissionViewerOperatorAdmin
list_configsnoneallowallowallow
overview, list, detail, change_historyexploreallowallowallow
Read-only SQLsql:readallowallowallow
DML, including INSERT, UPDATE, DELETEsql:writedenyallowallow
DDLsql:ddldenydenyallow
run_build, run_file, change_run, change_ff, change_revertcorresponding run:* or change:* permissiondenyconfirmallow

On a config with isTest: true, every role reads at least the Admin column; see access roles.

DML defaults are unchanged: operator and admin do not prompt. To let an operator request approval for DDL, override its permission in .noorm/settings.yml:

yaml
access:
    roles:
        operator:
            permissions:
                sql:ddl: confirm
        metadata-reader:
            permissions:
                explore: allow
                sql:read: allow

Built-in overrides retain unspecified default permissions. Custom roles may extends another role's effective definition; without a base, unspecified permissions are denied. Assign names through each config's access.user and access.agent. See Access roles.

Who approves a confirmed operation? ​

The client presents the operation to a human, then retries it with the response. Noorm validates the returned state and current policy before executing.

The client must advertise form elicitation support. A retry with valid state but no response reissues the same challenge without granting permission. A response consumes the approval once; the method, client identity metadata, operation arguments, target config, and current effective policy must still match. Approvals expire after five minutes and do not survive a server restart. Decline, cancel, missing support, modified state, changed target or policy, expiration, and replay prevent execution.

For confirmed file, build, and change operations, noorm reviews and executes a private snapshot of plain SQL and its execution plan. Confirmation rejects executable SQL templates before rendering, including templates selected by a build or referenced by change manifests. For change_ff, the preflight checks pending changes. With allow, executable project artifacts retain their usual trusted execution semantics. Review text redacts the connection password, SSL key, certificate and CA values, and known secrets, on a best-effort basis; transformed values may remain visible. The connection's user and database names stay visible so you can see the target you approve.

run_file requires a relative path whose canonical target remains inside the canonical project root, including through symlinks. This check applies to both allow and confirm; it is not a sandbox for trusted project code. MCP trusts the client to collect human consent; it cannot independently prove a human clicked approve. Role checks also do not replace database grants or protection of project files and credentials. Project template sidecars execute JavaScript and must be trusted.

An agent calling the CLI is still denied for every confirm permission, including with --yes or NOORM_YES. Human CLI/TUI confirmation remains available. deny never becomes executable through approval.

access.agent: false hides a config from discovery and direct requests. A config without an explicit access assignment defaults to user: admin, agent: viewer. Protected-stage ceilings cannot be relaxed by a role override.

Exploration resources ​

Clients can browse resource listings and URI templates, then read database metadata as application/json:

text
noorm://configs/{config}/overview
noorm://configs/{config}/objects/{category}
noorm://configs/{config}/objects/{category}/{name}
noorm://configs/{config}/objects/{category}/{name}?schema={schema}

Encode config, schema, and object names as URI components. List categories are tables, views, procedures, functions, types, indexes, foreignKeys, triggers, locks, and connections. Detail supports tables, views, procedures, functions, types, and triggers, subject to dialect support.

Every read enforces explore, including human elicitation when its effective decision is confirm. Resources reuse the same introspection operations as exploration tools; they do not execute caller-provided SQL or return table-row dumps. Results use private, immediately stale cache hints so clients do not reuse live schema/session metadata as a shared public result. A missing or hidden config or missing object returns -32602 with the requested URI in error.data.uri; malformed resource URIs also return -32602 as invalid parameters.

Troubleshooting ​

SymptomCauseAction
Unsupported protocol or rejected initializationClient only speaks a legacy MCP revisionUpgrade the client to support 2026-07-28
Explicit config requiredDatabase request omitted its targetAdd config to the tool arguments, or use a config-qualified resource URI
sql:ddl denied for operatorBuilt-in operator still denies DDLExplicitly configure sql:ddl: confirm if appropriate
Missing required client capabilityClient cannot collect form approvalUse a client with modern form elicitation support; noorm will not bypass confirmation
Approval no longer matchesIt expired, was consumed, or its target/policy changedMake a fresh request and review a new approval
Agent CLI denied even with --yesCLI agents cannot fulfill human confirmationUse MCP elicitation or have a human run the operation

Next ​