Skip to main content
Glama
Debanjan29

mcp-sqlserver

by Debanjan29

mcp-sqlserver

Microsoft SQL Server용 강력한 Model Context Protocol (MCP) 서버입니다. AI 어시스턴트(Claude, Gemini, Kiro, OpenAI, Copilot, Cursor)를 엔터프라이즈급 보안 제어로 SQL Server 데이터베이스에 직접 연결합니다.

7개 카테고리에 걸친 39개 도구: 스키마 탐색, 쿼리 실행, DDL, 저장 프로시저, 성능/DBA 진단, 개발자 유틸리티, 서버 관리.

npm 버전 GitHub release

변경사항: 버전 기록은 CHANGELOG.md를, 자세한 릴리스 노트는 GitHub Releases를 참조하세요.

v1.3의 새로운 기능

  • 멀티 서버 지원 — 하나의 구성에서 dev/staging/prod 서버를 정의하고 server 매개변수로 전환

  • list_servers 도구 — 구성된 모든 연결을 한눈에 확인

  • 서버별 보안 — 각 서버에 고유한 보안 모드, 행 제한, 차단 데이터베이스 설정

  • 하위 호환성 — 기존 단일 서버 구성은 변경 없이 그대로 작동

Related MCP server: SQL Server MCP

v1.2의 새로운 기능

  • 신규 도구 16개 — DBA 진단, 코드 생성, ER 다이어그램, 스키마 비교, 데이터 샘플링 등

  • SQL 인젝션 방지 — 모든 쿼리는 매개변수화된 입력과 이스케이프된 식별자를 사용

  • ISO 날짜 형식 지정 — 날짜가 JavaScript Date 문자열 대신 2025-01-27 형식으로 표시됩니다.

  • Streamable HTTP 전송--http <port>로 MCP 서버를 원격 호스팅

  • 헬스 체크 — 연결 상태 및 서버 응답성 확인

기능

서버 관리 (1개 도구)

도구

설명

list_servers

호스트, 데이터베이스, 인증, 보안 모드를 포함한 구성된 모든 서버 연결 목록

멀티 서버: 모든 도구는 선택적 server 매개변수를 사용하여 특정 서버를 대상으로 지정할 수 있습니다. 생략하면 기본 서버를 사용합니다.

스키마 탐색 (9개 도구)

도구

설명

list_databases

인스턴스에서 액세스 가능한 모든 데이터베이스 목록

list_schemas

데이터베이스의 스키마 목록

list_tables

행 수와 크기를 포함한 테이블 목록

list_views

데이터베이스의 뷰 목록

describe_table

열 유형, 기본값, NULL 허용, IDENTITY, 계산 열 등 상세 정보

get_foreign_keys

테이블의 외래 키 관계

get_indexes

포함 열을 포함한 인덱스 정보

get_constraints

PK, UNIQUE, CHECK, DEFAULT 제약 조건

get_triggers

테이블의 트리거 정의

쿼리 실행 (3개 도구)

도구

설명

execute_query

자동 행 제한을 적용해 SELECT 쿼리 실행

execute_mutation

INSERT/UPDATE/DELETE/MERGE 실행 (readwrite 모드 필요)

export_query

쿼리 결과를 CSV 또는 JSON 형식으로 내보내기

DDL 연산 (1개 도구)

도구

설명

execute_ddl

CREATE/ALTER/DROP 문 실행 (admin 모드 필요)

저장 프로시저 (3개 도구)

도구

설명

list_procedures

데이터베이스의 저장 프로시저 목록

describe_procedure

프로시저의 매개변수 및 소스 코드 확인

execute_procedure

명명된 매개변수로 실행 (readwrite 모드 필요)

성능 및 DBA (16개 도구)

도구

설명

get_query_plan

모든 쿼리의 예상 실행 계획

get_active_queries

sys.dm_exec_requests에서 실행 중인 쿼리

get_table_stats

행 수, 전체/사용/미사용 크기, 조각화 %

get_index_usage

인덱스 탐색, 스캔, 조회, 업데이트 통계

get_missing_indexes

사용 가능한 CREATE INDEX DDL을 포함한 누락 인덱스 제안

get_server_info

서버 버전, 에디션, CPU 수, 메모리, 가동 시간

get_database_info

데이터베이스 크기, 파일 레이아웃, 상태, 복구 모델, 개체 수

get_wait_stats

CPU, I/O, 잠금 병목을 식별하는 상위 서버 대기 통계

get_deadlocks

system_health 확장 이벤트 세션의 최근 교착 상태

get_block_ing_chains

다른 세션을 차단하는 현재 차단 체인

get_most_time_transactions

잠금을 보유할 수 있는 장기 실행 중인 트랜잭션

get_space_usage

테이블별 상세 디스크 공간 사용(데이터, 인덱스, 사용되지 않은 공간)

get_backup_history

최근 백업 기록: 유형, 크기, 기간, 장치 경로

get_query_store_stats

Query Store의 리소스 사용량 상위 쿼리 (SQL Server 2016+) — CPU, 기간, 읽기, 쓰기 또는 실행 수로 정렬 가능

rebuild_index

조각난 인덱스 다시 작성 또는 재구성 (admin 모드 필요)

health_check

대기 시간, 버전, 활성 세션을 포함한 연결 상태 확인

개발자 유틸리티 (6개 도구)

compare_schemas — 스키마 비교

두 데이터베이스를 나란히 비교합니다. 테이블, 열 및 유형 차이를 표시하여 개발(dev)과 운영(prod)을 비교할 때 이상적입니다.

compare_schemas(source_database: "DevDB", target_database: "ProdDB")

출력에는 원본/대상에만 있는 테이블, 원본/대상에만 있는 열, 열 유형/NULL 허용 여부 차이가 포함됩니다.

generate_code — 코드 생성

테이블의 스키마에서 유형이 있는 코드를 생성합니다.

  • TypeScript — 적절한 유형(number, string, Date, Buffer | null)의 인터페이스

  • C# — nullable 값 유형(int?, long?, DateTime?, decimal?)이 있는 클래스

  • SQL — 전체 열 정의가 포함된 CREATE TABLE 스크립트

generate_code(table: "Products", language: "typescript")
→ export interface Products {
    productId: number;
    productName: string;
    unitPrice: number | null;
    ...
  }

generate_insert_scripts — INSERT 문으로 데이터 내보내기

기존 테이블 데이터에서 INSERT 문을 생성합니다. 마이그레이션 스크립트, 시드 데이터 또는 작은 참조 테이블의 백업에 유용합니다.

generate_insert_scripts(table: "Categories", top: 10)
→ INSERT INTO [dbo].[Categories] ([CategoryName], [Description]) VALUES (N'Beverages', N'Soft drinks...');

generate_er_diagram — ER 다이어그램

외래 키 관계에서 Mermaid ER 다이어그램을 생성합니다. 출력을 Mermaid와 호환되는 렌더러(GitHub, Notion, VS Code 등)에 붙여 넣으세요.

generate_er_diagram(database: "Northwind")
→ erDiagram
    Products }o--|| Categories : "CategoryID"
    Products }o--|| Suppliers : "SupplierID"
    Orders }o--|| Customers : "CustomerID"
    ...

generate_test_data — 테스트 데이터 생성

열 이름과 유형을 기반으로 가짜 데이터로 실제적인 INSERT 문을 생성합니다. 일반적인 패턴(이메일, 전화번호, 이름, 도시, 가격 등)에 대한 스마트 추론을 적용합니다.

generate_test_data(table: "Customers", count: 5)
→ INSERT INTO [dbo].[Customers] (...) VALUES (N'Alice', N'user1@example.com', N'New York', ...);

sample_table — 무작위 샘플링

NEWID()를 사용하여 모든 테이블에서 무작위 행 샘플을 가져옵니다. AI 어시스턴트가 전체 테이블을 인스턴스하지 않고 데이터 패턴을 이해하는 데 유용합니다.

sample_table(table: "Orders", count: 5)

보안

세 가지 보안 모드

모드

SELECT

INSERT/UPDATE/DELETE

DDL

저장된 프로시저

readonly

아니오

아니오

읽기 전용 (목록/설명)

readwrite

아니오

전체 (실행)

admin

전체 (실행)

SQL 인젝턴 방지

사용자 제공 값은 모두 매개변수화된 쿼리 입력(@param)로 전달됩니다. 개체 식별자(데이터베이스, 스키마, 테이블 이름)는 SQL Server 대괄호 표기법([name]에서 ]]])을 사용하여 이스케이프 합니다.

추가 보안 기능

  • 데이터베이스 및 스키마 허용/차단 목록

  • 자동 행 수 제한(구성 가능한 maxRowCount)

  • 차단된 키워드 탐지 ( xp\_cmdshell, SHUTDOWN, DROP DATABASE 등)

  • 개인정보 보호를 위한 열 단위 데이터 마스킹

  • 보안 모드별 쿼리 유형 검증

데이터 마스킹

쿼리 결과에서 민감한 열을 마스킹합니다.

security:
  maskColumns:
    - pattern: "*.password"
      mask: "***"
    - pattern: "*.ssn"
      mask: "XXX-XX-XXXX"
    - pattern: "dbo.users.email"
      mask: "***@***.***"

패턴 형식: [schema.]table.column (*를 와일드카드로 사용)

인증

방법

구성 type

요구 사항

SQL Server

sql

user + password

Windows (NTLM)

windows

user + password + 선택 domain

Windows (SSPI)

windows

자격 인증 필요 없음; msnodesqlv8 필요

Azure AD

azure-ad

clientId + clientSecret + tenantId

Windows 인증

NTLM — 추가 패키지 없이 즉시 작동합니다.

connection:
  host: YOUR_SERVER\SQLEXPRESS
  authentication:
    type: windows
    user: YourUsername
    password: YourPassword
    domain: YOUR_DOMAIN
  trustServerCertificate: true

SSPI / 통합 보안 — 현재 Windows 로그인 세션을 사용합니다.

npm install msnodesqlv8
connection:
  host: YOUR_SERVER\SQLEXPRESS
  authentication:
    type: windows
  trustServerCertificate: true

참고: npx를 사용할 때 msnodesqlv8와 같은 선택적 의존 모듈이 자동으로 설치되지 않을 수 있습니다. SSPI를 사용하려면 전역 설치(npm install -g @tugberkgunber/mcp-sqlserver msnodesqlv8)를 고려하거나 NTLM 모드를 대신 사용하는 것이 좋습니다.

전송

stdio (기본)

표준 입력/출력 전송 — Claude Desktop, VS Code, Cursor 등을 비롯한 MCP 클라이언트에서 사용합니다.

Streamable HTTP

원격 호스팅 또는 웹 통합용:

mcp-sqlserver --config mssql-mcp.yaml --http 3000

이렇게 하면 시작됩니다:

  • MCP 엔드포인트: http://localhost:3000/mcp

  • 상태 확인: http://localhost:3000/health{"status":"ok","mode":"readonly"}

브라우저 기반 클라이언트를 위한 CORS 지원이 포함됩니다.

빠른 시작

설치

npm install -g @tugberkgunver/mcp-sqlserver

구성

작업 디렉터리에 mssql-mcp.yaml 구성 파일을 생성합니다:

connection:
  host: localhost
  port: 1433
  database: MyDatabase
  authentication:
    type: sql
    user: sa
    password: YourPassword123
  trustServerCertificate: true

security:
  mode: readonly
  maxRowCount: 1000
  blockedDatabases:
    - master
    - msdb
    - tempdb
    - model

모든 옵션은 config.example.yaml을 참조하세요.

멀티 서버 구성

한 구성에서 dev/staging/prod를 관리하도록 여러 엔드포인트 서버를 정의하세요:

defaultServer: dev

connections:
  dev:
    host: dev-server.example.com
    database: MyDatabase
    authentication:
      type: sql
      user: sa
      password: DevPass123
    trustServerCertificate: true
    security:
      mode: admin
      maxRowCount: 5000

  prod:
    host: prod-server.example.com
    database: MyDatabase
    authentication:
      type: sql
      user: readonly_user
      password: ProdReadOnly
    security:
      mode: readonly
      blockedDatabases: [master, msdb, tempdb, model]

# Global security defaults (applied to all servers unless overridden)
security:
  maxRowCount: 1000
  blockedKeywords: [xp_cmdshell, SHUTDOWN, DROP DATABASE]

그런 다음 도구 호출에서 server 매개변수를 사용합니다:

list_tables(server: "prod", database: "MyDatabase")
health_check(server: "dev")
compare_schemas(source_database: "DevDB", target_database: "StagingDB", server: "dev")

MCP 클라이언트 구성

{
  "mcpServers": {
    "mssql": {
      "command": "npx",
      "args": ["-y", "@tugberkgunver/mcp-sqlserver"],
      "env": {
        "MSSQL_HOST": "localhost",
        "MSSQL_DATABASE": "MyDatabase",
        "MSSQL_USER": "sa",
        "MSSQL_PASSWORD": "YourPassword123"
      }
    }
  }
}

구성 파일 사용:

{
  "mcpServers": {
    "mssql": {
      "command": "npx",
      "args": ["-y", "@tugberkgunver/mcp-sqlserver", "--config", "/path/to/mssql-mcp.yaml"]
    }
  }
}

.vscode/mcp.json에 추가:

{
  "servers": {
    "mssql": {
      "command": "npx",
      "args": ["-y", "@tugberkgunver/mcp-sqlserver"],
      "env": {
        "MSSQL_HOST": "localhost",
        "MSSQL_DATABASE": "MyDatabase",
        "MSSQL_USER": "sa",
        "MSSQL_PASSWORD": "YourPassword123"
      }
    }
  }
}

~/.cursor/mcp.json에 추가:

{
  "mcpServers": {
    "mssql": {
      "command": "npx",
      "args": ["-y", "@tugberkgunver/mcp-sqlserver"],
      "env": {
        "MSSQL_HOST": "localhost",
        "MSSQL_DATABASE": "MyDatabase",
        "MSSQL_USER": "sa",
        "MSSQL_PASSWORD": "YourPassword123"
      }
    }
  }
}

.kiro/settings/mcp.json에 추가:

{
  "mcpServers": {
    "mssql": {
      "command": "npx",
      "args": ["-y", "@tugberkgunver/mcp-sqlserver"],
      "env": {
        "MSSQL_HOST": "localhost",
        "MSSQL_DATABASE": "MyDatabase",
        "MSSQL_USER": "sa",
        "MSSQL_PASSWORD": "YourPassword123"
      }
    }
  }
}

~/.gemini/settings.json에 추가:

{
  "mcpServers": {
    "mssql": {
      "command": "npx",
      "args": ["-y", "@tugberkgunver/mcp-sqlserver"],
      "env": {
        "MSSQL_HOST": "localhost",
        "MSSQL_DATABASE": "MyDatabase",
        "MSSQL_USER": "sa",
        "MSSQL_PASSWORD": "YourPassword123"
      }
    }
  }
}
{
  "mcpServers": {
    "mssql": {
      "command": "npx",
      "args": ["-y", "@tugberkgunver/mcp-sqlserver"],
      "env": {
        "MSSQL_HOST": "localhost",
        "MSSQL_DATABASE": "MyDatabase",
        "MSSQL_USER": "sa",
        "MSSQL_PASSWORD": "YourPassword123"
      }
    }
  }
}

~/.windsurf/mcp.json에 추가:

{
  "mcpServers": {
    "mssql": {
      "command": "npx",
      "args": ["-y", "@tugberkgunver/mcp-sqlserver"],
      "env": {
        "MSSQL_HOST": "localhost",
        "MSSQL_DATABASE": "MyDatabase",
        "MSSQL_USER": "sa",
        "MSSQL_PASSWORD": "YourPassword123"
      }
    }
  }
}

Windows에서는 cmd를 명령 래퍼로 사용하세요:

{
  "mcpServers": {
    "mssql": {
      "command": "cmd",
      "args": ["/c", "npx", "-y", "@tugberkgunver/mcp-sqlserver", "--config", "path/to/config.yaml"]
    }
  }
}

환경 변수

변수

설명

MSSQL_HOST

SQL Server 호스트 이름

MSSQL_PORT

SQL Server 포트(기본값: 1433)

MSSQL_DATABASE

기본 데이터베이스

MSSQL_USER

SQL 인증 사용자 이름

MSSQL_PASSWORD

SQL 인증 비밀번호

MSSQL_MCP_CONFIG

YAML 구성 파일 경로

환경 변수는 구성 파일 값을 덮어씁니다.

개발

git clone https://github.com/gunvertugberk/mcp-sqlserver.git
cd mcp-sqlserver
npm install
npm run build
npm start -- --config ./mssql-mcp.yaml

라이선스

MIT

Install Server
A
license - permissive license
B
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Enables AI agents to securely connect to and query Microsoft SQL Server databases with read-only access, schema discovery, and relationship mapping. Features advanced security protections, health monitoring, and bulk operations for production environments.
    9
    75
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Enables AI assistants to interact with Microsoft SQL Server databases through query execution, schema discovery, CRUD operations, stored procedures, and data export with built-in safety controls.
    18
    Apache 2.0
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to securely interact with Microsoft SQL Server databases to query data, inspect schemas, and retrieve metadata with read-only operations by default and optional write capabilities.
    1
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to interact with Microsoft SQL Server databases through a standardized interface. Supports executing SQL queries, browsing database schemas, and viewing table data with flexible authentication options for both local and Azure SQL databases.
    5
    MIT

View all related MCP servers

Related MCP Connectors

  • Explore, query, and inspect SQLite databases with ease. List tables, preview results, and view det…

  • Connect your AI assistants to Keboola and expose your data, transformations, SQL queries, ...

  • Connect AI assistants to GitHub - manage repos, issues, PRs, and workflows through natural language.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Debanjan29/readonly-mssql-mcp-db'

If you have feedback or need assistance with the MCP directory API, please join our Discord server