MCPDB - Database Access MCP Server

MCPDB - Database Access MCP Server

Provides Claude Desktop with secure access to multiple database connections, allowing users to query MySQL, PostgreSQL, SQLite, and SQL Server databases directly through natural language.

Category
访问服务器

README

MCPDB - Database Access MCP Server

MCPDB is a Laravel-based MCP (Model Context Protocol) server that provides Claude Desktop with secure access to multiple database connections. Through a web-based management interface, you can configure database connections and then query them directly from Claude Desktop using natural language.

Features

  • Multi-Database Support: Connect to MySQL, PostgreSQL, SQLite, and SQL Server databases
  • Web Management Interface: Easy-to-use web UI for managing database connections
  • MCP Integration: Seamlessly integrates with Claude Desktop via the Model Context Protocol
  • Secure Connection Management: Store and manage database credentials securely
  • SQL Query Execution: Execute SQL queries directly from Claude Desktop conversations

Prerequisites

  • Docker and Docker Compose (for Laravel Sail)
  • Node.js and npm (for frontend assets)
  • Claude Desktop application

Installation

1. Clone and Setup the Project

git clone <repository-url>
cd mcpdb

2. Start the Laravel Application

# Copy environment file
cp .env.example .env

# Start Docker containers
./vendor/bin/sail up -d

# Install PHP dependencies
./vendor/bin/sail composer install

# Install Node.js dependencies and build assets
./vendor/bin/sail npm install
./vendor/bin/sail npm run dev

# Run database migrations
./vendor/bin/sail artisan migrate

The application will be available at http://localhost:8000

3. Configure Database Connections

  1. Open http://localhost:8000 in your browser
  2. Click "Add Connection" to create database connections
  3. Fill in the connection details:
    • Connection Name: Unique identifier (e.g., "my_production_db")
    • Driver: mysql, pgsql, sqlite, or sqlsrv
    • Host: Database host address
    • Port: Database port (optional, uses default if empty)
    • Database: Database name
    • Username: Database username
    • Password: Database password
    • Description: Optional description
  4. Test the connection to ensure it works
  5. Make sure "Active" is checked

4. Configure Claude Desktop

Create or edit the Claude Desktop configuration file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

Add the following configuration:

{
  "mcpServers": {
    "mcpdb": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "http://localhost:8000/mcp"
      ]
    }
  }
}

5. Install mcp-remote (if not already installed)

npm install -g mcp-remote

6. Restart Claude Desktop

Completely quit and restart Claude Desktop for the configuration to take effect.

Usage

Once configured, you can interact with your databases directly through Claude Desktop:

List Available Connections

What database connections are available?

Execute SQL Queries

Execute this SQL query on the "my_production_db" connection: SELECT * FROM users LIMIT 5
Show me the table structure for the products table in the inventory database
Count the number of orders in the last 30 days using the sales_db connection

Available MCP Tools

The server provides two main tools:

  1. list_connections: Lists all active database connections
  2. execute_sql: Executes SQL queries on specified connections

Development

Project Structure

  • app/Models/SubjectConnection.php - Database connection model
  • app/Http/Controllers/ConnectionController.php - Web interface for managing connections
  • app/Http/Controllers/McpController.php - MCP server implementation
  • resources/views/connections/ - Web interface views
  • database/migrations/ - Database schema migrations

Running Tests

./vendor/bin/sail artisan test

Code Formatting

./vendor/bin/sail artisan pint

Security Considerations

  • Database passwords are stored in the application database
  • Only active connections are exposed to the MCP server
  • SQL queries are executed with the permissions of the configured database user
  • Consider using read-only database users for security
  • The MCP server runs on localhost only by default

Troubleshooting

MCP Server Not Connecting

  1. Ensure Laravel server is running: ./vendor/bin/sail up -d
  2. Check MCP server health: curl http://localhost:8000/health
  3. Verify Claude Desktop configuration file syntax
  4. Check Claude Desktop logs: ~/Library/Logs/Claude/

Database Connection Failures

  1. Test connections in the web interface: http://localhost:8000
  2. Verify database credentials and network access
  3. Check if database user has appropriate permissions
  4. For remote databases, ensure firewall allows connections

Asset Loading Issues

# Rebuild frontend assets
./vendor/bin/sail npm run dev

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests and ensure code formatting
  5. Submit a pull request

License

This project is open-sourced software licensed under the MIT license.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选