Skip to main content
Glama

@yuuzu/sql-mcp

CI npm version

Ein Model Context Protocol (MCP)-Server für MSSQL-, PostgreSQL- und SQLite-Datenbankoperationen.

Installation

# Using bunx (recommended)
bunx @yuuzu/sql-mcp

# Using npx
npx @yuuzu/sql-mcp

Related MCP server: Database MCP Server

Funktionen

  • Multi-Datenbank-Unterstützung: MSSQL, PostgreSQL und SQLite (via better-sqlite3)

  • 8 Tools für Datenbankoperationen

  • Drei Abfragemodi: safe, write, full

  • Erweiterte Authentifizierung: Windows-Authentifizierung (MSSQL), SSL-Zertifikate (PostgreSQL)

Tools

Tool

Beschreibung

connect-database

Verbindung zu einem Datenbankserver herstellen

disconnect

Verbindung trennen

connection-status

Verbindungsstatus und Abfragemodus prüfen

list-databases

Alle Datenbanken auf dem Server auflisten

switch-database

Zu einer anderen Datenbank wechseln

list-tables

Alle Tabellen und Views auflisten

describe-table

Details zum Tabellenschema abrufen

execute-query

SQL-Abfragen ausführen

Abfragemodi

Steuern Sie die Abfrageberechtigungen über die Umgebungsvariable SQL_MCP_MODE:

Modus

Erlaubte Operationen

Beschreibung

safe (Standard)

SELECT, WITH, EXPLAIN

Schreibgeschützt, am sichersten

write

+ INSERT, UPDATE, DELETE

Erlaubt Datenänderungen

full

+ CREATE, DROP, ALTER, TRUNCATE

Vollzugriff, mit Vorsicht verwenden

Hinweis: PRAGMA-Anweisungen (z. B. PRAGMA table_info(users)) sind in allen Modi erlaubt, einschließlich safe, da es sich um schreibgeschützte Metadatenabfragen handelt, die häufig bei SQLite verwendet werden.

# Example: Enable write mode
SQL_MCP_MODE=write bunx @yuuzu/sql-mcp

Anwendungsbeispiele

Claude Desktop-Konfiguration

Fügen Sie dies zu Ihrer claude_desktop_config.json hinzu:

{
    "mcpServers": {
        "sql-mcp": {
            "command": "bunx",
            "args": ["@yuuzu/sql-mcp"],
            "env": {
                "SQL_MCP_MODE": "safe"
            }
        }
    }
}

Verbindung zu MSSQL

{
    "tool": "connect-database",
    "arguments": {
        "engine": "mssql",
        "server": "localhost",
        "port": 1433,
        "user": "sa",
        "password": "your_password",
        "database": "master"
    }
}

Verbindung zu PostgreSQL

{
    "tool": "connect-database",
    "arguments": {
        "engine": "postgres",
        "server": "localhost",
        "port": 5432,
        "user": "postgres",
        "password": "your_password",
        "database": "postgres"
    }
}

Verbindung mit Windows-Authentifizierung (MSSQL)

{
    "tool": "connect-database",
    "arguments": {
        "engine": "mssql",
        "server": "localhost",
        "windowsAuth": true
    }
}

Verbindung mit SSL (PostgreSQL)

{
    "tool": "connect-database",
    "arguments": {
        "engine": "postgres",
        "server": "your-server.com",
        "user": "postgres",
        "password": "your_password",
        "ssl": {
            "rejectUnauthorized": true,
            "ca": "/path/to/ca-certificate.crt"
        }
    }
}

Verbindung zu SQLite (Datei)

{
    "tool": "connect-database",
    "arguments": {
        "engine": "sqlite",
        "filename": "/absolute/path/to/database.db"
    }
}

Verbindung zu SQLite (im Arbeitsspeicher)

Nützlich für Tests, Demos oder temporäre Arbeitsbereiche.

{
    "tool": "connect-database",
    "arguments": {
        "engine": "sqlite",
        "filename": ":memory:"
    }
}

Verbindung zu SQLite (schreibgeschützt)

{
    "tool": "connect-database",
    "arguments": {
        "engine": "sqlite",
        "filename": "/absolute/path/to/database.db",
        "readonly": true,
        "fileMustExist": true
    }
}

Hinweis zur SQLite-Laufzeit: Die SQLite-Unterstützung verwendet better-sqlite3, was Node.js erfordert. Bei der Ausführung über bunx funktionieren MSSQL und PostgreSQL normal, aber SQLite-Verbindungen geben einen klaren Fehler zurück, der Sie anweist, stattdessen npx oder node zu verwenden.

Entwicklung

# Install dependencies
bun install

# Run in development mode
bun run dev

# Run tests
bun test

# Run tests with coverage
bun test --coverage

# Build
bun run build

# Type check
bun run typecheck

Release

Releases werden über GitHub Actions automatisiert. Um ein neues Release zu erstellen:

# Create and push a version tag
git tag v1.0.0
git push origin v1.0.0

Dies führt folgende Schritte aus:

  1. Das Projekt bauen

  2. Veröffentlichung auf npm mit Provenance

  3. Erstellung eines GitHub-Releases mit automatisch generierten Release-Notes

Voraussetzungen: Setzen Sie das NPM_TOKEN-Secret in Ihren GitHub-Repository-Einstellungen.

Lizenz

MIT

Related MCP Connectors

Related MCP Servers

  • A
    license
    B
    quality
    D
    maintenance
    A Model Context Protocol server that enables secure interaction with Microsoft SQL Server databases, allowing AI assistants to list tables, read data, and execute SQL queries through a controlled interface.
    10
    1
    394
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that provides tools for connecting to and interacting with various database systems (SQLite, PostgreSQL, MySQL/MariaDB, SQL Server) through a unified interface.
    3
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that enables Large Language Models to access and interact with database connections, including viewing schemas and performing CRUD operations on connected databases.
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    A Model Context Protocol server that allows Large Language Models like Claude to execute SQL queries, explore database schemas, and maintain persistent connections to SQL Server databases.
    -