Logo vun MCP 数据库服务器

MCP 数据库服务器

Communautéit
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…

EditeurMelkeydev
Repositorymcp-database
SproochGo
Forks
1
Stären
12
Disponibel Tools
0
Transporttypstdio
Kategorien
LizenzMIT
Linken
  • Tools mat KI-Workflows verbannen

    MCP 数据库服务器 stellt MCP-Funktioune bereit, déi vu kompatibele KI-Clienten a KI-Agente kënne benotzt ginn.

  • 0 disponibel Tools

    Kuckt Iech déi opruffbar Aktiounen hei drënner un, mat Nimm a Beschreiwungen, wa se vum Server geliwwert ginn.

  • Konfiguratioun fir ze kopéieren

    Benotzt d'Installatiounsbeispiller, fir dëse Server an Ärem bevorzugte MCP-Client ze konfiguréieren.

  • Indicateure fir Open Source

    12 Stären an 1 Forks aus dem verlinkte Repository.

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.

Installatioun

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

MCP 数据库服务器 MCP mat verschiddene KI-Modeller benotzen

TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Soubal MCP 数据库服务器 verbonnen ass, kënnt Dir et mat verschiddene KI-Modeller an TypingMind benotzen, amplaz et fir all Modell separat anzeriichten. Dës MCP-Integratioun leeft lokal iwwer den TypingMind-MCP-Connector op Ärem Apparat.

Ariichtungsuleedung fir de lokale Connector ze benotzen

Benotzt dës Optioun, wann den MCP-Server Zougrëff op lokal Fichieren, Appen oder privat Ressourcen op Ärem Computer brauch.

1

D'MCP-Astellungen opmaachen

Gitt an TypingMind op „Astellungen“, „Erweidert Astellungen“, dann op „Model Context Protocol“ a wielt „Connector ariichten“.

  1. Maacht TypingMind an Ärem Browser op.
  2. Klickt op d'Astellungssymbol.
  3. Gitt op „Erweidert Astellungen“.
  4. Maacht d'Sektioun „Model Context Protocol“ op.
  5. Klickt op „Connector ariichten“ a wielt „Dësen Apparat“.
Ariichtungsbildschierm vum TypingMind-MCP-Connector mat „Dësen Apparat“ ausgewielt
2

De Connector-Befeel ausféieren

Wielt „Dësen Apparat“, kopéiert de Befeel aus TypingMind a féiert en am Terminal aus. Loosst de Prozess lafen, wärend Dir MCP benotzt.

  1. Kopéiert den Ariichtungsbefeel, deen TypingMind uweist.
  2. Maacht Terminal op macOS oder Windows Terminal op Windows op.
  3. Pescht de Befeel an a féiert en aus.
  4. Bestätegt d'Installatioun vum Package, wann den Terminal Iech freet, ob Dir weiderfuere wëllt.
  5. Loosst den Terminal an de Prozess doranner lafen, wärend Dir MCP-Tools benotzt.
3

MCP 数据库服务器 als Server derbäisetzen

Wann de Connector-Status „Prett“ ass, klickt op „Serveren änneren“ a pescht d'MCP-Serverkonfiguratioun an.

  1. Waart, bis de Connector-Status „Prett“ weist.
  2. Klickt op „Serveren änneren“.
  3. Pescht d'MCP-Serverkonfiguratioun vu MCP 数据库服务器 an.
  4. Späichert d'Serverlëscht.
  5. Aktualiséiert, wann Dir kontrolléiere wëllt, ob de Connector nach ëmmer prett ass.
MCP-Astellunge vun TypingMind mat aktivem Server an dem Knäppchen „Serveren änneren“
{
  "mcpServers": {
    "mcp-database": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

D'Verbindung mat verschiddene Modeller benotzen

Späichert d'Serverlëscht, maacht „Plugins“ op an aktivéiert d'MCP-Tools vu MCP 数据库服务器. Wielt dann e belibegen ënnerstëtzte KI-Modell an TypingMind a benotzt d'Tools am Chat oder weist se engem KI-Agent zou.

  1. Maacht d'Säit „Plugins“ an TypingMind op.
  2. Aktivéiert d'MCP-Tools vu MCP 数据库服务器.
  3. Start e Chat a wielt de KI-Modell, deen Dir benotze wëllt.
  4. Benotzt d'MCP-Tools am Chat oder weist se engem KI-Agent zou.
  5. Wiesselt bei Bedarf op en anere KI-Modell, ouni MCP nei ze verbannen.
TypingMind-Chat mat aktivéierte MCP-Tools an engem ausgewielte KI-Modell
Hëlleft Dir mir bei dëser Aufgab mat MCP 数据库服务器?
MCP 数据库服务器
Jo. Ech hunn et gelies.
Dat hunn ech mat MCP 数据库服务器 fonnt.

Heefeg gestallte Froen

Fir wat gëtt de MCP-Server MCP 数据库服务器 benotzt?

MCP 数据库服务器 ass e MCP-Server, deen et kompatibele KI-Clienten erlaabt, sech mat externen Tools a Kontext ze verbannen. An TypingMind kënnt Dir dëse MCP-Server eemol derbäisetzen a seng Tools an Ärem KI-Aarbechtsberäich zur Verfügung stellen.

Kann ech MCP 数据库服务器 MCP mat méi KI-Modeller an TypingMind benotzen?

Jo. TypingMind verbënnt MCP-Tools um Niveau vum Aarbechtsberäich. Sou kënnt Dir MCP 数据库服务器 mat verschiddene KI-Modeller wéi Claude, ChatGPT, Gemini oder anere Modeller benotzen, déi Dir an TypingMind konfiguréiert hutt, ouni de MCP-Server fir all Modell separat anzeriichten.

Firwat MCP 数据库服务器 MCP mat TypingMind benotzen?

TypingMind ass eng vun de beschte Benotzeruewerfläche fir LLM-Chat, well et méi KI-Modeller, Prompts, Plugins, KI-Agenten, API-Schlësselen a MCP-Tools an engem Aarbechtsberäich zesummebréngt. Wann MCP 数据库服务器 verbonnen ass, kënnt Dir seng MCP-Tools mat Äre bevorzugte Modeller benotzen a gläichzäiteg Är Chataarbecht an TypingMind organiséieren.

Wéi verbannen ech MCP 数据库服务器 MCP mat TypingMind?

MCP 数据库服务器 leeft iwwer de lokale MCP-Connector vun TypingMind. Dat eegent sech am beschten, wann de MCP-Server Zougrëff op lokal Fichieren, Desktop-Apps, Kommandozeilen-Tools oder privat Ressourcen op Ärem Computer brauch.

Wéi eng Tools stellt MCP 数据库服务器 MCP an TypingMind zur Verfügung?

MCP 数据库服务器 stellt MCP-Funktiounen zur Verfügung, déi Dir op der Plugins-Säit vun TypingMind aktivéiere kënnt, fir se am Chat ze benotzen oder KI-Agenten zouzeweisen.

Muss ech meng API-Schlëssele mat TypingMind deelen, fir MCP 数据库服务器 MCP ze benotzen?

Nee. TypingMind setzt op lokal Veraarbechtung a léisst Iech d'Kontroll iwwer Är Modellubidder, API-Schlësselen, Prompts a MCP-Konfiguratioun. Wann MCP 数据库服务器 eng Authentifizéierung verlaangt, setzt déi néideg Headeren, OAuth-Astellungen oder lokal Konfiguratioun fir dee MCP-Server derbäi, wann Dir d'Verbindung erstallt.

Änlech MCP-Serveren

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇