MCP 数据库服务器のロゴ

MCP 数据库服务器

コミュニティ
Melkeydev

A Model Context Protocol (MCP) server that provides safe, read-only database access to Large Language Models (LLMs). This enables LLMs like Claude to explore database schemas, sample data, and…

公開者Melkeydev
リポジトリmcp-database
言語Go
フォーク
1
スター
12
利用可能なツール
0
通信方式stdio
カテゴリ
ライセンスMIT
リンク
  • ツールをAIワークフローに接続

    MCP 数据库服务器は、対応するAIクライアントやAIエージェントから利用できるMCP機能を提供します。

  • 0個の利用可能なツール

    呼び出し可能なアクションを以下で確認できます。サーバーから提供されている場合は、名前や説明も表示されます。

  • コピーして使える設定

    セットアップ用の設定例を使って、お好みのMCPクライアントにこのサーバーを設定できます。

  • オープンソースの注目度

    リンク先のリポジトリには12件のスターと1件のフォークがあります。

MCP Database Server

A Model Context Protocol (MCP) server that provides safe, read-only database access to Large Language Models (LLMs). This enables LLMs like Claude to explore database schemas, sample data, and execute SELECT queries through a standardized interface.

⚠️ Early Development Notice: This project is in early development. While functional, it lacks comprehensive testing and production-ready features. Use at your own risk in production environments.

Features

  • Schema Exploration: Discover database structure, tables, and columns
  • Data Sampling: Preview table contents with configurable row limits
  • Safe Querying: Execute read-only SELECT queries with built-in safety measures
  • Multi-Database Support: PostgreSQL, MySQL, and SQLite
  • MCP Protocol: Seamless integration with Claude Desktop and other MCP-compatible clients

Installation

Prerequisites

  • Go 1.24.4 or higher
  • Docker (for development database)
  • One of the supported databases:
    • PostgreSQL
    • MySQL
    • SQLite

Quick Start

  1. Clone the repository:
bash
git clone https://github.com/melkeydev/mcp-database
cd mcp-database
  1. Start the development database (PostgreSQL):
bash
docker-compose up -d
  1. Configure your database connection in config.yaml:
yaml
database:
  type: "postgres" # Options: postgres, mysql, sqlite
  connection_string: "postgres://postgres:postgres@localhost:5432/mcp_db?sslmode=disable"
  file: "database.db" # For SQLite only
  1. Build and run:
bash
go build -o mcp-database
./mcp-database -config config.yaml

Usage with Claude Desktop

Add the server to your Claude Desktop configuration:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%/Claude/claude_desktop_config.json

json
{
  "mcpServers": {
    "database": {
      "command": "/path/to/mcp-database",
      "args": ["-config", "/path/to/config.yaml"]
    }
  }
}

Available Tools

The server exposes three MCP tools:

1. scan_database

Discovers the database schema including all tables, columns, and their types.

typescript
// No parameters required

2. sample_table

Returns a sample of rows from a specified table.

typescript
{
  "table_name": "users",  // Required
  "limit": 10            // Optional, default: 10
}

3. query_database

Executes a read-only SELECT query.

typescript
{
  "query": "SELECT name, email FROM users WHERE created_at > '2024-01-01'"
}

Configuration

The config.yaml file supports the following database configurations:

PostgreSQL

yaml
database:
  type: "postgres"
  connection_string: "postgres://user:password@host:port/dbname?sslmode=disable"

MySQL

yaml
database:
  type: "mysql"
  connection_string: "user:password@tcp(host:port)/dbname"

SQLite

yaml
database:
  type: "sqlite"
  file: "path/to/database.db"

Architecture

mcp-database/
├── main.go              # Entry point
├── config/              # Configuration management
├── databases/           # Database connectors
│   ├── connector.go     # Common interface
│   ├── postgres/        # PostgreSQL implementation
│   ├── mysql/          # MySQL implementation
│   └── sqlite/         # SQLite implementation
├── handlers/           # Request handlers
├── mcp/               # MCP protocol implementation
└── types/             # Shared type definitions

Safety Features

  • Read-only operations: All database operations are executed within read-only transactions
  • Query validation: Only SELECT statements are allowed
  • Resource limits: Configurable row limits for data sampling
  • Error handling: Comprehensive error handling and reporting

Development

Building from Source

bash
# Install dependencies
go mod download

# Build
go build -o mcp-database

# Run tests (coming soon)
go test ./...

Adding a New Database

  1. Create a new package under databases/
  2. Implement the DatabaseConnector interface
  3. Update GetConnector() in databases/connector.go
  4. Add configuration support in config/

Roadmap

  • Comprehensive test suite
  • Connection pooling
  • Query result caching
  • Support for more databases (Oracle, SQL Server)
  • Query timeout configuration
  • Result size limits
  • Schema caching for better performance
  • Support for custom SQL functions
  • Docker image for easier deployment

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. Since this is an early-stage project, please open an issue first to discuss major changes.

Areas where help is needed:

  • Writing comprehensive tests
  • Adding support for more databases
  • Improving error messages and debugging
  • Documentation improvements
  • Performance optimizations

License

MIT License

Disclaimer

This project is in early development and not yet production-ready. While it implements safety measures for read-only access, please use caution when connecting to production databases. Always use appropriate credentials with minimal required permissions.

Acknowledgments

Built on the Model Context Protocol by Anthropic.

インストール

TypingMind
{
  "mcpServers": {
    "mcp-database": {
      "command": "./mcp-database",
      "args": [
        "-config",
        "config.yaml"
      ]
    }
  }
}

MCP 数据库服务器のMCPを複数のAIモデルで活用

TypingMindはワークスペース単位でMCPツールに接続します。そのため、一度MCP 数据库服务器に接続すれば、モデルごとに個別に設定することなく、TypingMind内のさまざまなAIモデルで利用できます。 このMCPは、デバイス上のTypingMind MCPコネクタを通じてローカルで動作します。

ローカルコネクタのセットアップガイド

MCPサーバーが、お使いのコンピューター上のローカルファイル、アプリ、非公開リソースにアクセスする必要がある場合は、この方法を使います。

1

MCP設定を開く

TypingMindで「設定」、「詳細設定」、「MCP」の順に進み、「コネクタを設定」を選択してください。

  1. ブラウザでTypingMindを開いてください。
  2. 設定アイコンをクリックしてください。
  3. 「詳細設定」に移動してください。
  4. 「MCP」セクションを開いてください。
  5. 「コネクタを設定」をクリックし、「このデバイス」を選択してください。
「このデバイス」が選択されたTypingMindのMCPコネクタ設定画面
2

コネクタのコマンドを実行

「このデバイス」を選択し、TypingMindからコマンドをコピーしてターミナルで実行してください。MCPの使用中は、プロセスを実行したままにしてください。

  1. TypingMindに表示されるセットアップコマンドをコピーしてください。
  2. macOSではターミナルを、WindowsではWindows Terminalを開いてください。
  3. コマンドを貼り付けて実行してください。
  4. ターミナルで続行の確認を求められた場合は、パッケージのインストールを承認してください。
  5. MCPツールの使用中は、ターミナルウィンドウを開いたまま、プロセスの実行を継続してください。
3

MCP 数据库服务器をサーバーとして追加

コネクタのステータスが「準備完了」になったら、「サーバーを編集」をクリックし、MCPサーバーの設定を貼り付けてください。

  1. コネクタのステータスが「準備完了」になるまでお待ちください。
  2. 「サーバーを編集」をクリックしてください。
  3. MCP 数据库服务器のMCPサーバー設定を貼り付けてください。
  4. サーバー一覧を保存してください。
  5. コネクタが引き続き使用可能か確認するには、更新してください。
稼働中のサーバーと「サーバーを編集」ボタンが表示されたTypingMindのMCP設定画面
{
  "mcpServers": {
    "mcp-database": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

複数のモデルで同じ接続を使用

サーバー一覧を保存し、「プラグイン」を開いてMCP 数据库服务器のMCPツールを有効にしてください。その後、TypingMindで対応するAIモデルを選択し、チャットでツールを使うか、AIエージェントに割り当ててください。

  1. TypingMindの「プラグイン」ページを開いてください。
  2. MCP 数据库服务器のMCPツールを有効にしてください。
  3. チャットを開始し、使用するAIモデルを選択してください。
  4. MCPツールをチャットで使うか、AIエージェントに割り当ててください。
  5. MCPに再接続することなく、必要に応じて別のAIモデルに切り替えられます。
選択したAIモデルと有効なMCPツールを使用したTypingMindのチャット
MCP 数据库服务器を使ってこのタスクを手伝ってもらえますか?
MCP 数据库服务器
はい、読みました。
MCP 数据库服务器で調べた結果をお伝えします。

よくある質問

MCP 数据库服务器 MCPサーバーは何に使いますか?

MCP 数据库服务器は、対応するAIクライアントを外部ツールやコンテキストに接続するためのMCPサーバーです。TypingMindでは、このMCPサーバーを一度追加するだけで、AIワークスペース内でそのツールを利用できるようになります。

TypingMindでMCP 数据库服务器 MCPを複数のAIモデルと併用できますか?

はい。TypingMindはワークスペース単位でMCPツールに接続するため、モデルごとにMCPサーバーを設定する必要はありません。Claude、ChatGPT、Geminiや、TypingMindで設定したその他のAIモデルでMCP 数据库服务器を利用できます。

TypingMindでMCP 数据库服务器 MCPを使うメリットは何ですか?

TypingMindは、複数のAIモデル、プロンプト、プラグイン、AIエージェント、APIキー、MCPツールを1つのワークスペースにまとめられる、LLMチャット向けの優れたフロントエンドです。MCP 数据库服务器を接続すると、TypingMindでチャットのワークフローを整理しながら、お好みのモデルでそのMCPツールを利用できます。

MCP 数据库服务器 MCPをTypingMindに接続するにはどうすればよいですか?

MCP 数据库服务器はTypingMindのローカルMCPコネクタ経由で動作します。MCPサーバーがコンピューター上のローカルファイル、デスクトップアプリ、コマンドラインツール、プライベートリソースにアクセスする必要がある場合に最適です。

TypingMindでMCP 数据库服务器 MCPのどのようなツールを利用できますか?

MCP 数据库服务器はMCP機能を提供しています。TypingMindのプラグインページで有効にすると、チャットで使用したり、AIエージェントに割り当てたりできます。

MCP 数据库服务器 MCPを使うには、APIキーをTypingMindと共有する必要がありますか?

いいえ。TypingMindはローカルファーストの設計で、モデルプロバイダー、APIキー、プロンプト、MCP設定をご自身で管理できます。MCP 数据库服务器で認証が必要な場合は、接続の作成時に、そのMCPサーバーに必要なヘッダー、OAuth設定、またはローカル設定を追加してください。

関連するMCPサーバー

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇