SecurityMay 20, 2026 · 7 min read

Scoped credentials for MCP database servers: do not give the agent your admin key

The fastest way to make an AI database agent dangerous is to connect it with the same credential a senior engineer uses in production.

The model does not need your admin key. It needs a narrow, explicit operating lane.

Scoped credentials are one of the simplest ways to turn MCP database access from a trust exercise into a controllable system.

Start with the job, not the database

A common mistake is to expose a database connection first and decide policy later.

That reverses the order. The safer question is: what job should this MCP server perform?

  • Answer product analytics questions?
  • Inspect support tickets?
  • Summarize operational metrics?
  • Prepare a write action for human approval?

Each job deserves its own credential scope, not one shared connection that can see everything.

Related: Secure AI database access checklist.

Read-only should be the default

Most AI database workflows start as question-answering workflows. They should use read-only database roles by default.

That role should usually be limited to approved views, not raw application tables. Views let teams encode joins, redactions, row filters, and business definitions below the model.

If the agent only needs revenue by region, it does not need direct access to every customer, invoice, payment method, and internal note.

Related: Result redaction for AI database agents.

Writes need a different lane

Write-capable tools should not be hidden behind the same credential and tool name as read queries.

Use separate roles, separate tools, and separate approval paths for write operations. A good write workflow includes:

  • a dry-run preview,
  • the exact rows or objects affected,
  • an idempotency key,
  • a human approval requirement when risk is non-trivial,
  • an audit receipt after execution.

Related: Approval gates for AI database writes.

Scope is more than read vs write

Useful credential design also includes tenant, environment, and output boundaries.

  • Tenant scope: which customer or workspace can the query touch?
  • Environment scope: production, staging, or analytics replica?
  • Time scope: how expensive or long-running can a query be?
  • Output scope: how many rows and which fields can leave the tool?

Those controls should be enforced by the execution layer, not remembered by the model.

Related: AI database query budgets.

Return the scope with the answer

Every database answer should carry evidence about the scope used to produce it.

At minimum, return the connection alias, database role, tenant scope, approved view or template, freshness window, row limits, and audit ID.

That gives humans a way to debug the answer without reverse-engineering the agent session.

Related: Query provenance for AI database agents.

Where Conexor fits

Conexor is MCP infrastructure for AI-ready engineering teams. It connects databases and APIs to clients like Claude, ChatGPT, Cursor, n8n, and Continue through controlled access patterns.

The goal is not to give the model a master key. It is to expose useful database capabilities through scoped credentials, approved actions, and auditable results.

Explore secure AI database access →

Relay

Quick questions

Relay

Quick questions

Ask me