Skip to main content
Glama
MCP MySQL Server

MCP MySQL Server

by kevinbin

@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: MCP MySQL 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).

executeB

Execute an INSERT, UPDATE, or DELETE query

Inputs: sql (required), params.

list_tablesB

List all tables in the database

Inputs: no named parameters.

queryB

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: connect_db handles connections, list_tables and describe_table provide metadata, create_table and add_column manage schema, while execute and query separate write and read operations. The descriptions make it easy to distinguish between similar tools like execute vs query or create_table vs add_column.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern with clear, descriptive names (e.g., connect_db, list_tables, create_table). There are no deviations in naming conventions, and the snake_case style is applied uniformly throughout the toolset.

    Tool Count5/5

    With 7 tools, this server is well-scoped for basic MySQL database operations. Each tool earns its place by covering essential functions: connection management, schema operations, metadata queries, and data manipulation. The count is neither too sparse nor overwhelming for the domain.

    Completeness4/5

    The toolset provides solid coverage for core MySQL workflows, including connection, schema management (create, modify), and data operations (read/write). A minor gap exists in lacking explicit tools for updating or deleting tables (e.g., drop_table, alter_table), but agents can work around this using the execute tool for such DDL queries.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A server that enables AI models to interact with MySQL databases through a Model Control Protocol, providing tools for table creation, schema inspection, query execution, and data retrieval.
      28
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      A Model Context Protocol server that enables AI models to interact with MySQL databases, providing tools for querying, executing statements, listing tables, and describing table structures.
      5
      329 npm
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server that enables AI models to interact with MySQL databases through natural language, supporting SQL queries, table creation, and schema exploration.
      3
      -