Connector guide2-minute readEN · DE · IT

How to Connect Databases to MCP Servers

Connect PostgreSQL, MySQL, MariaDB, MSSQL, Oracle, SQLite, and MongoDB databases directly to MCP. Let AI agents query data using natural language.

HCBy HelpCode teamUpdated 2 min read Open source on GitHub

No credit card · 7-day trial · Self-host alternative available

  • 7-day free trial
    No credit card required
  • GDPR & SOC 2 ready
    EU data residency, audit logs
  • Open-source on GitHub
    Source-available BSL-1.1
  • Works with ChatGPT, Claude, Gemini
    Any MCP-compatible client

Summary

Connect PostgreSQL, MySQL, MariaDB, MSSQL, Oracle, SQLite, and MongoDB databases directly to MCP. Let AI agents query data using natural language.

Direct Database Access for AI Agents

Instead of building REST APIs on top of your databases, AnythingMCP connects directly to your database and exposes it as MCP tools. AI agents can query data using natural language.

Supported Databases

DatabaseStatusAccess Mode
PostgreSQLSupportedRead-only
MySQLSupportedRead-only
MariaDBSupportedRead-only
Microsoft SQL ServerSupportedRead-only
OracleSupportedRead-only
SQLiteSupportedRead-only
MongoDBSupportedRead-only

Important: All database connectors in AnythingMCP are read-only by design. This ensures AI agents cannot accidentally modify or delete data.

Auto-Generated Tools

When you create a database connector, AnythingMCP automatically generates three tools:

ToolDescription
get_database_schemaReturns the database schema (tables, columns, types)
get_example_queriesSuggests example queries based on the schema
execute_queryExecutes a read-only query (SELECT/find only, max 1000 rows)

Step-by-Step Guide

Step 1: Deploy AnythingMCP

git clone https://github.com/HelpCode-ai/anythingmcp.git
cd anythingmcp && docker compose up -d

Step 2: Create a Database Connector

Open the AnythingMCP dashboard at http://localhost:3000 and create a new Database connector. Select your database type (PostgreSQL, MySQL, MariaDB, MSSQL, Oracle, SQLite, or MongoDB) and provide the connection details.

Step 3: Configure Connection

Enter your database host, port, credentials, and database name. For SQL databases (PostgreSQL, MySQL, MariaDB, MSSQL, Oracle, SQLite), the connector will use SQL SELECT queries only. For MongoDB, only find operations are allowed.

Step 4: Test the Connection

Use the dashboard to verify the connection and review the auto-discovered schema. The get_database_schema tool will show all available tables and columns.

Step 5: Connect to AI Agents

{
  "mcpServers": {
    "my-database": {
      "url": "http://localhost:4000/mcp"
    }
  }
}

Query Limits

  • SQL databases (PostgreSQL, MySQL, MariaDB, MSSQL, Oracle, SQLite): Only SELECT statements are allowed
  • MongoDB: Only find operations are allowed
  • Row limit: Maximum 1000 rows per query
  • No write operations: INSERT, UPDATE, DELETE, DROP are blocked

AI Agent Use Cases

  • "Show me all orders from last month with total over $500"
  • "What are the top 10 products by revenue?"
  • "How many new users signed up this week?"
  • "List all customers from Germany"

Security Best Practices

  1. Use a read-only database user — Create a dedicated user with SELECT-only permissions
  2. Restrict accessible tables — Only expose tables that are safe for AI access
  3. SSL connections — Always use encrypted connections in production
  4. Network restrictions — Limit database access to the AnythingMCP server IP

Next Steps

Was this guide helpful?

Ready to ship

Ship MCP to your stack in 60 seconds.

Spin up AnythingMCP on managed Cloud or self-host it on your infrastructure. Free for 7 days, no credit card.

Related guides