Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

You can let Claude Code and Cursor query a database through a Model Context Protocol (MCP) server without giving the AI client unrestricted database access. The key is to limit permissions at the database itself, enable the server’s read-only protections where available, and check the server’s provenance and data access before connecting it.

Claude Code and Cursor use separate MCP configuration locations. The right configuration depends on the chosen server and database; there is no universal database command or configuration that is safe to copy unchanged.

How do I let Claude Code and Cursor query my database?

MCP is the connection layer between an AI client and external tools or data sources. An MCP server is a separate component that exposes tools to the client; what those tools can do depends on the server and the credentials and permissions it uses. Connecting an MCP server does not automatically make database access read-only.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Choose an MCP server. Check that it supports your database engine and the operations you need. Review its source, maintenance provenance, installation requirements, and the data or network access it requests.
  2. Create a dedicated database identity. Grant it only the read permissions required for the intended queries. Do not reuse an administrator or application account.
  3. Enable read-only controls in the server, if available. Treat this as an additional safeguard, not a replacement for database permissions. MongoDB’s security guidance recommends both read-only MCP mode and a read-only database user: MongoDB MCP security guidance.
  4. Configure each client separately. Use the Cursor configuration locations for Cursor and Claude Code’s configuration locations for Claude Code; Claude Desktop chat has a different file.
  5. Start or reload the client as the server documentation directs. Confirm the server and expected tools are available, then independently verify the database identity’s grants and review what data the server can expose.

The database permission boundary is the more dependable control if the server’s read-only option is missing or misconfigured. A read-only account can still expose sensitive data it is allowed to read, so limit access to the necessary databases, schemas, collections, and records where your database supports that level of control.

#1 Best Overall
Yubico - Security Key C NFC - Basic Compatibility - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-C or NFC, FIDO Certified
  • POWERFUL SECURITY KEY: The Security Key C NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
  • WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key C NFC secures 100 of your favorite accounts, including email, password managers, and more.
  • FAST & CONVENIENT LOGIN: Plug in your Security Key C NFC via USB-C and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
  • TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
  • BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.

Configure MCP in Cursor

Cursor’s current documentation uses mcp.json for custom MCP servers. Put project-level configuration in .cursor/mcp.json; use ~/.cursor/mcp.json for user-level or global configuration. Cursor supports local command-based servers using stdio and remote server configurations. Its documented environment-variable interpolation covers configuration values including command, args, env, url, and headers. See the Cursor MCP configuration documentation.

For example, this shows the general shape of a local server entry, not a working database configuration:

Rank #2
Thetis FIDO2 Security Key (USB-A, 2-Pack) - Hardware MFA & Passkey Access for Business, School ERP & Employee Accounts | Compatible with Windows, Google Workspace, Apple ID, Coinbase, Salesforce
  • FIDO2 & Passkey Ready: Business-ready and FIDO2 L1 certified. This key is supported by major management suites and is ideal for both individual and enterprise deployment. Works seamlessly with Gmail, Facebook, GitHub, Dropbox, Coinbase, and more.
  • Universal Connectivity (USB-A ): Features a built-in USB-A connector—simply unfold the key and plug it into your compatible PC or laptop for seamless authentication on the go.
  • Dedicated Manager App: Use the Thetis Manager App for the initial hardware PIN setup. Setting the PIN on the device first ensures a smooth registration process. Once the PIN is configured, you can begin registering the key across your favorite FIDO2-compatible online services.
  • Ultra-Durable & Portable: Featuring a rotating metal cover, this key is water, crush, and tamper-resistant. It fits easily on a keychain and requires no batteries or network connectivity.
  • Check FIDO2 compatibility before purchase - Known limitations: ID Austria is not supported (requires FIDO2 Level 2). Windows Hello login only works with Windows Enterprise editions that support Entra ID, and NFC is NOT supported.
{
  "mcpServers": {
    "database": {
      "command": "<server executable>",
      "args": ["<server arguments>"],
      "env": {
        "DATABASE_URL": "${env:DATABASE_URL}"
      }
    }
  }
}

Replace the illustrative values with the chosen server’s documented settings. Executable names, arguments, connection-string formats, and read-only flags vary by implementation. Prefer environment references for secrets instead of putting literal credentials in a project file that may be checked into version control. Cursor enterprise administrators can separately manage server and tool allowlists and network policies; approval or distribution by an administrator is not the same as installation for every user.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Configure MCP in Claude Code

Claude Code’s MCP configuration is separate from Claude Desktop chat’s. Claude Code uses ~/.claude.json or a project-level .mcp.json; do not edit claude_desktop_config.json to configure Claude Code. Anthropic documents the Claude Code MCP setup and the claude mcp add command. Servers added through the CLI are local to the machine.

Rank #3
FIDO2 Security Key [Folding Design] Thetis Universal Two Factor Authentication USB (Type A) for Multi-Layered Protection (HOTP) in Windows/Linux/Mac OS,Gmail,Facebook,Dropbox,SalesForce,GitHub
  • Passwordless World - A revolutionary new way to protect your account info. By being FIDO2 certified by the world’s largest ecosystem for standard-based, interoperable authentication, FIDO2 makes everyday log-in experience effortless and passwordless yet more secure than generic password style security. **Note: FIDO2 does NOT support Mac log-in.
  • Online Account Protection - FIDO2 key is backward compatible with U2F protocol and works with the newest Chrome browser with operating systems such as: Windows, macOS, or Linux. U2F can be supported and protected on all websites that follow U2F protocols.
  • Multi-factored Authentication - Built-in, advanced HOTP (One Time Password) technology that completes the unique multi-factored authentication process. Eliminate worry and help prevent losing your account info to theft, phishing, hacking, or other online scams. Note: Only Enterprise Users using Azure Active Directory can access Windows Hello log-in via Thetis FIDO2 Security Key.
  • Compact And Durable - 360° design with rotating aluminum alloy cover that shields the USB connector when not in use. Tough and durable alloy protects FIDO2 key from daily wear-and-tear, accidental drops, and scratches.
  • Portable Design - ultra-portable design allows you to take your FIDO key anywhere you need it.

Use the selected server’s current instructions for its command, arguments, environment variables, and credential format. Do not treat a generic command as portable across database engines or server implementations. In an active Claude Code session, run /mcp to check whether the server is connected and see its available tools. This confirms host discovery, not that the database account has the intended grants.

What makes database access safer?

Keep permissions narrow at the database

Use a dedicated identity that can read only the data needed for the task. Verify its effective grants directly in the database or through your normal administrative controls. Database-specific grant syntax and scope differ, so use the current documentation for your engine rather than copying permissions from an example for another database.

Rank #4
Sale
Thetis Nano-A FIDO2 Security Key Hardware Passkey Device with USB Type A, TOTP/HOTP, FIDO2.0 Two Factor Authentication 2FA MFA, Works with Windows/mac/iOS/Android/Linux/Gmail/Facebook/GitHub/Coinbase
  • Ultra-Compact FIDO2 Security Key - Plug-and-stay or carry on a keychain. This USB-A hardware security key offers portable, always-on protection for desktop and mobile use. (Item Size: 0.75 X 0.74 IN x 0.25 IN)
  • USB-A Hardware Key for All Devices - Works with USB-A ports on PC, Mac, Android, and other laptop/notebook device. Enables secure, cross-platform login with FIDO2.0 passkey support.
  • FIDO Certified Security Key - Meets FIDO and FIDO2 standards. Works with Google, Microsoft, GitHub, Dropbox, and more. Please check service compatibility before purchase.
  • Passwordless Login with Passkey - Supports passkey login via WebAuthn and CTAP2. Enjoy password-free sign-ins where supported. Not all websites or services currently support passkeys.
  • Advanced Multi-Factor Authentication - Offers 200 FIDO2 passkey slots and 50 OATH-TOTP slots. Strong, flexible 2FA/MFA support across various apps and authentication platforms.

Limit what the MCP server can do

Check which tools the server exposes, whether it accepts arbitrary queries, how it handles credentials, and whether a read-only mode is enforced. A server may have access to external services or execute code on the user’s behalf. Cursor advises users to verify MCP server sources and audit code for high-impact integrations; see its MCP security guidance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Protect credentials and review exposure

Use credentials scoped to the minimum necessary permissions and keep secrets out of checked-in configuration. Review the server’s network access and what data it sends to external services. Running a server locally describes where its process runs; it does not establish what information reaches an AI service or how a provider handles that information. Those details depend on the specific client, server, database, and applicable provider policies.

Best Value
SecuX PUFido USB-C Security Key with PUF Technology, FIDO2/U2F Certified, Hardware-Rooted Unclonable Security for Passwordless Login and 2FA Authentication
  • A FIDO security key with PUF technology provides a unique, hardware-rooted trust anchor that resists tampering and cyber attacks, offering stronger security than conventional designs.
  • FIDO2 Certified Protection – Enjoy phishing-resistant security with FIDO2 certification, ensuring top-tier account safety across Windows, macOS, Linux, iOS iOS, Android and more.
  • Easy to use & Portable – Designed with a compact USB-C interface, Clife key fits easily on your keychain for secure access anywhere. Simply plug in and authenticate with ease.
  • Universal Compatibility – Works seamlessly with hundreds of FIDO2/U2F compliant services, including popular cloud, email, and social platforms.
  • Backup recommended – To ensure continuous access, register a backup Clife security key as a spare in case your primary key is lost.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How to verify the setup

  • Check client discovery. Confirm that the MCP server appears in the client and that the expected tools are listed. In Claude Code, use /mcp.
  • Check effective database permissions independently. Verify that the configured identity can perform the intended reads and cannot write, alter, or delete data beyond its granted role.
  • Check the server boundary. Review its code or trusted source, credentials handling, query behavior, network access, and any read-only enforcement.
  • Check data exposure. Ensure the role cannot read records or fields the user should not expose to the AI workflow.

A visible connection and a list of tools are useful setup checks, but they do not prove safe query behavior, read-only database grants, or a particular data-retention policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.