Skip to main content
Glama
MCP-MySQL Server

MCP-MySQL Server

by enemyrr

@enemyrr/mcp-mysql-server

대장간 배지

MySQL 데이터베이스 작업을 제공하는 모델 컨텍스트 프로토콜 서버입니다. 이 서버를 통해 AI 모델은 표준화된 인터페이스를 통해 MySQL 데이터베이스와 상호 작용할 수 있습니다.

커서 IDE 설치 및 설정

Smithery를 통해 설치

Smithery를 통해 Claude Desktop용 MySQL 데이터베이스 서버를 자동으로 설치하려면:

지엑스피1

수동 설치

  1. 프로젝트를 복제하고 빌드합니다.

git clone https://github.com/enemyrr/mcp-mysql-server.git
cd mcp-mysql-server
npm install
npm run build
  1. 커서 IDE 설정에 서버를 추가합니다.

    • 명령 팔레트 열기(Cmd/Ctrl + Shift + P)

    • "MCP: 서버 추가"를 검색하세요

    • 다음 필드를 채워주세요:

      • 이름: mysql

      • 유형: command

      • 명령어: node /absolute/path/to/mcp-mysql-server/build/index.js

참고 : /absolute/path/to/ 프로젝트를 복제하고 빌드한 실제 경로로 바꾸세요.

Related MCP server: MySQL MCP Server

데이터베이스 구성

데이터베이스 연결은 세 가지 방법으로 구성할 수 있습니다.

  1. .env의 데이터베이스 URL (권장):

DATABASE_URL=mysql://user:password@host:3306/database
  1. .env의 개별 매개변수 :

DB_HOST=localhost
DB_USER=your_user
DB_PASSWORD=your_password
DB_DATABASE=your_database
  1. 도구를 통한 직접 연결 :

use_mcp_tool({
  server_name: "mysql",
  tool_name: "connect_db",
  arguments: {
    url: "mysql://user:password@host:3306/database"
    // OR
    workspace: "/path/to/your/project" // Will use project's .env
    // OR
    host: "localhost",
    user: "your_user",
    password: "your_password",
    database: "your_database"
  }
});

사용 가능한 도구

1. 연결_DB

URL, 작업 공간 경로 또는 직접 자격 증명을 사용하여 MySQL 데이터베이스에 연결합니다.

2. 질의

선택적으로 준비된 명령문 매개변수를 사용하여 SELECT 쿼리를 실행합니다.

use_mcp_tool({
  server_name: "mysql",
  tool_name: "query",
  arguments: {
    sql: "SELECT * FROM users WHERE id = ?",
    params: [1]
  }
});

3. 실행하다

선택적으로 준비된 명령문 매개변수를 사용하여 INSERT, UPDATE 또는 DELETE 쿼리를 실행합니다.

use_mcp_tool({
  server_name: "mysql",
  tool_name: "execute",
  arguments: {
    sql: "INSERT INTO users (name, email) VALUES (?, ?)",
    params: ["John Doe", "john@example.com"]
  }
});

4. 리스트_테이블

연결된 데이터베이스에 있는 모든 테이블을 나열합니다.

use_mcp_tool({
  server_name: "mysql",
  tool_name: "list_tables"
});

5. 설명_테이블

특정 테이블의 구조를 가져옵니다.

use_mcp_tool({
  server_name: "mysql",
  tool_name: "describe_table",
  arguments: {
    table: "users"
  }
});

6. 테이블 생성

지정된 필드와 인덱스로 새 테이블을 만듭니다.

use_mcp_tool({
  server_name: "mysql",
  tool_name: "create_table",
  arguments: {
    table: "users",
    fields: [
      {
        name: "id",
        type: "int",
        autoIncrement: true,
        primary: true
      },
      {
        name: "email",
        type: "varchar",
        length: 255,
        nullable: false
      }
    ],
    indexes: [
      {
        name: "email_idx",
        columns: ["email"],
        unique: true
      }
    ]
  }
});

7. 열 추가

기존 표에 새 열을 추가합니다.

use_mcp_tool({
  server_name: "mysql",
  tool_name: "add_column",
  arguments: {
    table: "users",
    field: {
      name: "phone",
      type: "varchar",
      length: 20,
      nullable: true
    }
  }
});

특징

  • 다양한 연결 방식(URL, 워크스페이스, 직접)

  • 자동 정리를 통한 안전한 연결 처리

  • 쿼리 매개변수에 대한 준비된 명령문 지원

  • 스키마 관리 도구

  • 포괄적인 오류 처리 및 검증

  • TypeScript 지원

  • 자동 작업 공간 감지

보안

  • SQL 주입을 방지하기 위해 준비된 명령문을 사용합니다.

  • 환경 변수를 통해 안전한 암호 처리를 지원합니다.

  • 실행 전에 쿼리를 검증합니다.

  • 완료되면 자동으로 연결을 닫습니다.

오류 처리

서버는 다음에 대한 자세한 오류 메시지를 제공합니다.

  • 연결 실패

  • 잘못된 쿼리 또는 매개변수

  • 구성이 누락되었습니다

  • 데이터베이스 오류

  • 스키마 검증 오류

기여하다

기여를 환영합니다! https://github.com/enemyrr/mcp-mysql-server 에 풀 리퀘스트를 제출해 주세요.

특허

MIT

Available Tools

7 tools
add_columnC

Add a new column to existing table

Inputs: field (required), table (required).

connect_dbC

Connect to MySQL database using URL or config

Inputs: database, host, password, url, +2 more.

create_tableC

Create a new table in the database

Inputs: fields (required), table (required), indexes.

describe_tableB

Get table structure

Inputs: table (required).

executeC

Execute an INSERT, UPDATE, or DELETE query

Inputs: sql (required), params.

list_tablesB

List all tables in the database

Inputs: no named parameters.

queryC

Execute a SELECT query

Inputs: sql (required), params.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.4/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose with no ambiguity. For example, 'execute' handles INSERT/UPDATE/DELETE while 'query' handles SELECT, and 'describe_table' provides structure while 'list_tables' enumerates tables. The separation between schema operations (add_column, create_table) and data operations (execute, query) is well-defined.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern with clear, descriptive names. The naming convention is uniform throughout (e.g., add_column, create_table, describe_table, list_tables), making it easy to predict functionality. There are no deviations in style or formatting.

    Tool Count5/5

    With 7 tools, this server is well-scoped for MySQL database operations. Each tool serves a specific, necessary function in the database management workflow, from connection (connect_db) to schema manipulation (create_table, add_column) and data querying (query, execute). The count avoids both bloat and insufficiency.

    Completeness4/5

    The tool set covers core MySQL operations effectively, including connection, schema management, and data querying. Minor gaps exist, such as the lack of tools for updating or deleting tables, which could limit full lifecycle management. However, agents can work around this using existing tools like 'execute' for DROP TABLE queries.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI models to interact with MySQL databases through a standardized interface, supporting queries, data manipulation, table inspection, and query performance analysis with secure prepared statements.
      40 npm
      23
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI models to interact with MySQL databases through standardized operations including querying, executing commands, listing tables, and describing table structures with secure prepared statement support.
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to securely connect to and manage MySQL databases with support for multiple database connections, complete CRUD operations, schema inspection, and dynamic connection management through natural language.
      19 npm
      81
      MIT
    • A
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables AI assistants to securely interact with MySQL databases through tools for query execution, schema inspection, and transaction management. It features built-in safety controls like row limits and query validation to ensure safe and standardized database access.
      716 npm
      -