Universal DB MCP logo

Universal DB MCP

Community
Anarkh-Lee

通用数据库 MCP 连接器:支持 MySQL、PostgreSQL、Oracle、MongoDB 等 17 种数据库,支持 Claude Desktop、Cursor、Windsurf、VS Code、ChatGPT 等 50+ 平台,用自然语言查询和分析数据

PublisherAnarkh-Lee
Repositoryuniversal-db-mcp
LanguageTypeScript
Forks
91
Stars
936
Available tools
0
Transport typestdio, streamable-http
Categories
LicenseMIT
Links
  • Connect tools to AI workflows

    Universal DB MCP exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    936 stars and 91 forks from the linked repository.


Why Universal DB MCP?

Imagine asking your AI assistant: "Show me the top 10 customers by order value this month" and getting instant results from your database - no SQL writing required. Universal DB MCP makes this possible by bridging AI assistants with your databases through the Model Context Protocol (MCP) and HTTP API.

You: "What's the average order value for users who signed up in the last 30 days?"

AI: Let me query that for you...

┌─────────────────────────────────────┐
│ Average Order Value: $127.45        │
│ Total New Users: 1,247              │
│ Users with Orders: 892 (71.5%)      │
└─────────────────────────────────────┘

✨ Features

  • 17 Database Support - MySQL, PostgreSQL, Redis, Oracle, SQL Server, MongoDB, SQLite, and 10 Chinese domestic databases
  • 55+ Platform Integrations - Works with Claude Desktop, Cursor, VS Code, ChatGPT, Dify, and 50+ other platforms
  • Flexible Architecture - 2 startup modes (stdio/http) with 4 access methods: MCP stdio, MCP SSE, MCP Streamable HTTP, and REST API
  • Security First - Read-only mode by default prevents accidental data modifications
  • Intelligent Caching - Schema caching with configurable TTL for blazing-fast performance
  • Batch Query Optimization - Up to 100x faster schema retrieval for large databases
  • Schema Enhancement - Table comments, implicit relationship inference for better Text2SQL accuracy
  • Multi-Schema Support - Automatic discovery of all user schemas (PostgreSQL, SQL Server, Oracle, DM, and more)
  • Data Masking - Automatic sensitive data protection (phone, email, ID card, bank card, etc.)
  • Connection Stability - Connection pooling, TCP Keep-Alive, and automatic reconnection for long-running sessions

Performance Improvements

TablesBeforeAfterImprovement
50 tables~5s~200ms25x faster
100 tables~10s~300ms33x faster
500 tables~50s~500ms100x faster

🚀 Quick Start

Installation

bash
npm install -g universal-db-mcp

MCP Mode (Claude Desktop)

Add to your Claude Desktop configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
json
{
  "mcpServers": {
    "my-database": {
      "command": "npx",
      "args": [
        "universal-db-mcp",
        "--type", "mysql",
        "--host", "localhost",
        "--port", "3306",
        "--user", "root",
        "--password", "your_password",
        "--database", "your_database"
      ]
    }
  }
}

Restart Claude Desktop and start asking questions:

  • "Show me the structure of the users table"
  • "Count orders from the last 7 days"
  • "Find the top 5 products by sales"

HTTP API Mode

bash
# Set environment variables
export MODE=http
export HTTP_PORT=3000
export API_KEYS=your-secret-key

# Start the server
npx universal-db-mcp
bash
# Test the API
curl http://localhost:3000/api/health

MCP SSE Mode (Dify and Remote Access)

When running in HTTP mode, the server also exposes MCP protocol endpoints via SSE (Server-Sent Events) and Streamable HTTP. This allows platforms like Dify to connect using the MCP protocol directly.

SSE Endpoint (Legacy):

GET http://localhost:3000/sse?type=mysql&host=localhost&port=3306&user=root&password=xxx&database=mydb

Streamable HTTP Endpoint (MCP 2025 Spec, Recommended):

POST http://localhost:3000/mcp
Headers:
  X-DB-Type: mysql
  X-DB-Host: localhost
  X-DB-Port: 3306
  X-DB-User: root
  X-DB-Password: your_password
  X-DB-Database: your_database
Body: MCP JSON-RPC request
EndpointMethodDescription
/sseGETEstablish SSE connection (legacy)
/sse/messagePOSTSend message to SSE session
/mcpPOSTStreamable HTTP endpoint (recommended)
/mcpGETSSE stream for Streamable HTTP
/mcpDELETEClose session

See Dify Integration Guide for detailed setup instructions.

📊 Supported Databases

DatabaseTypeDefault PortCategory
MySQLmysql3306Open Source
PostgreSQLpostgres5432Open Source
Redisredis6379NoSQL
Oracleoracle1521Commercial
SQL Serversqlserver1433Commercial
MongoDBmongodb27017NoSQL
SQLitesqlite-Embedded
Dameng (达梦)dm5236Chinese
KingbaseESkingbase54321Chinese
GaussDBgaussdb5432Chinese (Huawei)
OceanBaseoceanbase2881Chinese (Ant)
TiDBtidb4000Distributed
ClickHouseclickhouse8123OLAP
PolarDBpolardb3306Cloud (Alibaba)
Vastbasevastbase5432Chinese
HighGohighgo5866Chinese
GoldenDBgoldendb3306Chinese (ZTE)

🏗️ Architecture

┌─────────────────────────────────────────────────────────────────────────┐
│                         Universal DB MCP                                 │
├─────────────────────────────────────────────────────────────────────────┤
│                                                                          │
│  Startup Modes:                                                          │
│  ┌────────────────────────────┬────────────────────────────────────┐    │
│  │ stdio mode                 │ http mode                          │    │
│  │ (npm run start:mcp)        │ (npm run start:http)               │    │
│  └─────────────┬──────────────┴───────────────┬────────────────────┘    │
│                │                              │                          │
│                ▼                              ▼                          │
│  ┌─────────────────────────┐    ┌───────────────────────────────────┐   │
│  │      MCP Protocol       │    │           HTTP Server             │   │
│  │    (stdio transport)    │    │                                   │   │
│  │                         │    │  ┌─────────────────────────────┐  │   │
│  │  Tools:                 │    │  │      MCP Protocol           │  │   │
│  │  • execute_query        │    │  │  (SSE / Streamable HTTP)    │  │   │
│  │  • get_schema           │    │  │                             │  │   │
│  │  • get_table_info       │    │  │  Tools: (same as stdio)     │  │   │
│  │  • clear_cache          │    │  │  • execute_query            │  │   │
│  │  • get_enum_values      │    │  │  • get_schema               │  │   │
│  │  • get_sample_data      │    │  │  • get_table_info           │  │   │
│  │  • connect_database     │    │  │  • clear_cache              │  │   │
│  │  • disconnect_database  │    │  │  • get_enum_values          │  │   │
│  │  • get_connection_status│    │  │  • get_sample_data          │  │   │
│  │                         │    │  │  • connect_database         │  │   │
│  │  For: Claude Desktop,   │    │  │  • disconnect_database      │  │   │
│  │       Cursor, etc.      │    │  │  • get_connection_status    │  │   │
│  └─────────────┬───────────┘    │  │                             │  │   │
│                │                │  │  For: Dify, Remote Access   │  │   │
│                │                │  └──────────────┬──────────────┘  │   │
│                │                │                 │                 │   │
│                │                │  ┌──────────────┴──────────────┐  │   │
│                │                │  │        REST API             │  │   │
│                │                │  │                             │  │   │
│                │                │  │  Endpoints:                 │  │   │
│                │                │  │  • /api/connect             │  │   │
│                │                │  │  • /api/query               │  │   │
│                │                │  │  • /api/schema              │  │   │
│                │                │  │  • ... (10+ endpoints)      │  │   │
│                │                │  │                             │  │   │
│                │                │  │  For: Coze, n8n, Custom     │  │   │
│                │                │  └──────────────┬──────────────┘  │   │
│                │                └─────────────────┼─────────────────┘   │
│                │                                  │                     │
│                └──────────────────┬───────────────┘                     │
│                                   ▼                                     │
│  ┌──────────────────────────────────────────────────────────────────┐  │
│  │                     Core Business Logic                           │  │
│  │  • Query Execution    • Schema Caching                           │  │
│  │  • Safety Validation  • Connection Management                    │  │
│  └──────────────────────────────────┬───────────────────────────────┘  │
│                                     ▼                                   │
│  ┌──────────────────────────────────────────────────────────────────┐  │
│  │                    Database Adapter Layer                         │  │
│  │  MySQL │ PostgreSQL │ Redis │ Oracle │ MongoDB │ SQLite │ ...    │  │
│  │        (Connection Pool + TCP Keep-Alive + Auto-Retry)           │  │
│  └──────────────────────────────────────────────────────────────────┘  │
│                                                                          │
└─────────────────────────────────────────────────────────────────────────┘

🔒 Security

By default, Universal DB MCP runs in read-only mode, blocking all write operations (INSERT, UPDATE, DELETE, DROP, etc.).

Permission Modes

Fine-grained permission control is supported for flexible configuration:

ModeAllowed OperationsDescription
safe (default)SELECTRead-only, safest
readwriteSELECT, INSERT, UPDATERead/write but no delete
fullAll operationsFull control (dangerous!)
customCustom combinationSpecify via --permissions

Permission Types:

  • read - SELECT queries (always included)
  • insert - INSERT, REPLACE
  • update - UPDATE
  • delete - DELETE, TRUNCATE
  • ddl - CREATE, ALTER, DROP, RENAME

Usage Examples:

bash
# Read-only mode (default)
npx universal-db-mcp --type mysql ...

# Read/write but no delete
npx universal-db-mcp --type mysql --permission-mode readwrite ...

# Custom: only read and insert
npx universal-db-mcp --type mysql --permissions read,insert ...

# Full control (equivalent to --danger-allow-write)
npx universal-db-mcp --type mysql --permission-mode full ...

Permission Configuration by Transport:

⚠️ Different transports use different parameter naming conventions!

TransportParameter LocationPermission ModeCustom Permissions
STDIO (Claude Desktop)CLI args--permission-mode--permissions
SSE (Dify, etc.)URL QuerypermissionModepermissions
Streamable HTTPHTTP HeaderX-DB-Permission-ModeX-DB-Permissions
REST APIJSON BodypermissionModepermissions

Best Practices:

  • Never enable write mode in production
  • Use dedicated read-only database accounts
  • Connect through VPN or bastion hosts
  • Regularly audit query logs

🔌 Supported Platforms

Universal DB MCP works with any platform that supports the MCP protocol or REST API. Here's a comprehensive list:

AI-Powered Code Editors & IDEs

PlatformAccess MethodDescriptionGuide
CursorMCP stdioAI-powered code editor with built-in MCP supportEN / 中文
WindsurfMCP stdioCodeium's AI IDE with Cascade agentEN / 中文
VS CodeMCP stdio / REST APIVia GitHub Copilot agent mode or Cline/Continue extensionsEN / 中文
ZedMCP stdioHigh-performance open-source code editorEN / 中文
IntelliJ IDEAMCP stdioJetBrains IDE with MCP support (2025.1+)EN / 中文
PyCharmMCP stdioJetBrains Python IDEEN / 中文
WebStormMCP stdioJetBrains JavaScript IDEEN / 中文
Android StudioMCP stdioVia JetBrains MCP pluginEN / 中文
NeovimMCP stdioVia MCPHub.nvim pluginEN / 中文
EmacsMCP stdioVia mcp.el packageEN / 中文

AI Coding Assistants

PlatformAccess MethodDescriptionGuide
Claude CodeMCP stdioAnthropic's agentic coding toolEN / 中文
GitHub CopilotMCP stdioAgent mode in VS Code/JetBrainsEN / 中文
ClineMCP stdio / REST APIAutonomous coding agent for VS CodeEN / 中文
ContinueMCP stdioOpen-source AI code assistantEN / 中文
Roo CodeMCP stdioFork of Cline for VS CodeEN / 中文
Sourcegraph CodyMCP stdioAI coding assistantEN / 中文
Amazon Q DeveloperMCP stdioAWS AI coding assistantEN / 中文
DevinMCP stdioAI software engineerEN / 中文
GooseMCP stdioBlock's AI coding agentEN / 中文
Gemini CLIMCP stdioGoogle's command-line AI toolEN / 中文

Desktop AI Chat Applications

PlatformAccess MethodDescriptionGuide
Claude DesktopMCP stdioAnthropic's official desktop appEN / 中文
ChatGPT DesktopMCP SSE/Streamable HTTPOpenAI's desktop app with MCP connectorsEN / 中文
Cherry StudioMCP stdioMulti-model desktop chat appEN / 中文
LM StudioMCP stdioRun local LLMs with MCP supportEN / 中文
JanMCP stdioOpen-source ChatGPT alternativeEN / 中文
MstyMCP stdioDesktop AI chat applicationEN / 中文
LibreChatMCP stdioOpen-source chat interfaceEN / 中文
WitsyMCP stdioDesktop AI assistantEN / 中文
5ireMCP stdioCross-platform AI chatEN / 中文
ChatMCPMCP stdioMCP-focused chat UIEN / 中文
HyperChatMCP stdioMulti-platform chat appEN / 中文
TomeMCP stdiomacOS app for local LLMsEN / 中文

Web-Based AI Platforms

PlatformAccess MethodDescriptionGuide
Claude.aiMCP SSE/Streamable HTTPAnthropic's web interfaceEN / 中文
ChatGPTMCP SSE/Streamable HTTPVia custom connectorsEN / 中文
DifyMCP SSE/Streamable HTTPLLM app development platformEN / 中文
CozeREST APIByteDance's AI bot platformEN / 中文
n8nREST API / MCPWorkflow automation platformEN / 中文
ReplitMCP stdioOnline IDE with AI agentEN / 中文
MindPalMCP SSE/Streamable HTTPNo-code AI agent builderEN / 中文

Agent Frameworks & SDKs

PlatformAccess MethodDescriptionGuide
LangChainMCP stdioPopular LLM frameworkEN / 中文
SmolagentsMCP stdioHugging Face agent libraryEN / 中文
OpenAI Agents SDKMCP SSE/Streamable HTTPOpenAI's agent frameworkEN / 中文
Amazon Bedrock AgentsMCP SSE/Streamable HTTPAWS AI agent serviceEN / 中文
Google ADKMCP stdioGoogle's Agent Development KitEN / 中文
Vercel AI SDKMCP stdioVercel's AI development kitEN / 中文
Spring AIMCP stdioJava/Spring AI frameworkEN / 中文

CLI Tools & Terminal

PlatformAccess MethodDescriptionGuide
Claude Code CLIMCP stdioTerminal-based coding agentEN / 中文
WarpMCP stdioAI-powered terminalEN / 中文
OtermMCP stdioChat with Ollama via CLIEN / 中文
MCPHostMCP stdioCLI chat with LLMsEN / 中文

Productivity & Automation

PlatformAccess MethodDescriptionGuide
RaycastMCP stdiomacOS productivity launcherEN / 中文
NotionMCP SSE/Streamable HTTPWorkspace with AI integrationEN / 中文
ObsidianMCP stdioVia MCP Tools pluginEN / 中文
Home AssistantMCP stdioHome automation platformEN / 中文

Messaging Platform Integrations

PlatformAccess MethodDescriptionGuide
SlackMCP stdio / REST APIVia Slack MCP botsEN / 中文
DiscordMCP stdio / REST APIVia Discord MCP botsEN / 中文
MattermostMCP stdioOpen-source messagingEN / 中文

Local LLM Runners

PlatformAccess MethodDescriptionGuide
OllamaMCP stdioRun local LLMsEN / 中文
LM StudioMCP stdioLocal LLM desktop appEN / 中文
JanMCP stdioOffline ChatGPT alternativeEN / 中文

Development & Testing Tools

PlatformAccess MethodDescriptionGuide
MCP InspectorMCP stdioOfficial MCP debugging toolEN / 中文
PostmanREST API / MCPAPI testing platformEN / 中文

Note: Any MCP-compatible client can connect via stdio (local) or SSE/Streamable HTTP (remote). Any HTTP client can use the REST API.

📚 Documentation

Getting Started

Deployment

Database Guides

HTTP API

Integrations

AI Editors & IDEs: Cursor | VS Code | JetBrains | Windsurf | Zed | Neovim | Emacs

AI Assistants: Claude Desktop | Claude Code | GitHub Copilot | Cline | Continue

AI Platforms: Dify | Coze | n8n | ChatGPT | LangChain

Desktop Apps: Cherry Studio | LM Studio | Jan | Ollama

Messaging: Slack | Discord

Tools: MCP Inspector | Postman

📁 View all 55 integration guides | 中文版本请在对应文档名后加 .zh-CN

Advanced

🤝 Contributing

Contributions are welcome! Please read our Contributing Guide before submitting a Pull Request.

bash
# Clone the repository
git clone https://github.com/Anarkh-Lee/universal-db-mcp.git

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

📄 License

This project is licensed under the MIT License.

🌟 Star History

If you find this project useful, please consider giving it a star! Your support helps us continue improving Universal DB MCP.

Star History Chart

📝 Changelog

See CHANGELOG.md for a detailed version history.


Installation

TypingMind
{
  "mcpServers": {
    "universal-db-mcp": {
      "command": "npx",
      "args": [
        "universal-db-mcp",
        "--type",
        "{{config.DB_TYPE}}",
        "--host",
        "{{config.DB_HOST}}",
        "--port",
        "{{config.DB_PORT}}",
        "--user",
        "{{config.DB_USER}}",
        "--password",
        "{{config.DB_PASSWORD}}",
        "--database",
        "{{config.DB_DATABASE}}"
      ],
      "env": {
        "DB_TYPE": "<DB_TYPE>",
        "DB_HOST": "<DB_HOST>",
        "DB_PORT": "<DB_PORT>",
        "DB_USER": "<DB_USER>",
        "DB_PASSWORD": "<DB_PASSWORD>",
        "DB_DATABASE": "<DB_DATABASE>"
      }
    }
  }
}

Use Universal DB MCP MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Universal DB MCP is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. You can run MCP locally on your device or connect to a remote MCP server URL.

Option 1: Use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Universal DB MCP as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Universal DB MCP MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "universal-db-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "universal-db-mcp"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Universal DB MCP MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Universal DB MCP MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Universal DB MCP to help me with this task?
Universal DB MCP
Sure. I read it.
Here is what I found using Universal DB MCP.

Option 2: Add an MCP server URL

Use this when Universal DB MCP is already hosted remotely or your team wants one shared connector that multiple users can access.

1

Open MCP connectors

In TypingMind, go to Plugins, open MCP connectors, then choose Add URL.

  1. Open TypingMind in your browser.
  2. Go to Plugins.
  3. Open MCP connectors.
  4. Click Add URL.
TypingMind Add Custom MCP Server URL form
2

Paste the server URL

Enter the MCP server URL from the provider in the Server URL field. Add a connection name, description, icon, custom HTTP headers, or OAuth client settings if the server requires them.

  1. Paste the MCP server URL from the provider into the Server URL field.
  2. Enter a connection name for Universal DB MCP.
  3. Add a description and icon if you want it to be easier to identify.
  4. Add custom HTTP headers or OAuth client details if the server requires authentication.
3

Create the connection

Click Create connection, then return to the Plugins list and confirm the new MCP connection is active.

  1. Click Create connection.
  2. Return to the MCP connectors list.
  3. Confirm the Universal DB MCP connection appears as active.
  4. Refresh the plugin list if the connection does not appear immediately.
4

Switch models without reconnecting

Start a chat with your preferred model, enable the Universal DB MCP tools from Plugins, and switch to another model whenever needed. The MCP connection stays available to the TypingMind workspace.

  1. Start a new chat in TypingMind.
  2. Select the AI model you want to use.
  3. Enable the Universal DB MCP tools from Plugins.
  4. Ask the model to use the tool when needed.
  5. Switch to another AI model and reuse the same MCP connection.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Universal DB MCP to help me with this task?
Universal DB MCP
Sure. I read it.
Here is what I found using Universal DB MCP.

Frequently asked questions

What is the Universal DB MCP MCP server used for?

Universal DB MCP is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Universal DB MCP MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Universal DB MCP with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Universal DB MCP MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Universal DB MCP connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Universal DB MCP MCP to TypingMind?

Universal DB MCP can be connected in TypingMind with the local MCP connector or by adding a remote MCP server URL. Use the local connector when the server needs access to files, apps, or private resources on your device, and use a server URL when the MCP server is hosted remotely.

What tools does Universal DB MCP MCP provide in TypingMind?

Universal DB MCP exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Universal DB MCP MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Universal DB MCP requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇