DM

daobataotie/mssql-mcp

数据库管理

本页由 AI 翻译,技术细节请以原文为准。 查看原文

39 stars 11 forks 质量 84 趋势 20MIT

daobataotie/mssql-mcp 是从 https://github.com/daobataotie/mssql-mcp. 导入的 MCP 服务器候选

概览

daobataotie/mssql-mcp 是从 https://github.com/daobataotie/mssql-mcp. 导入的 MCP 服务器候选

概述(AI 翻译)

英文 |中文

概述

MSSQL MCP 服务器提供数据库交互和商业智能功能。该服务器支持运行 SQL 查询、分析业务数据并自动生成业务洞察备忘录。 请参阅官方网站的SQLite以获取修改以适应MSSQL。

基于官方 MCP Python SDK(FastMCP),支持 MCP 2025-06-18 规范:结构化工具输出([structuredContent)、工具注释、资源模板和基于引发的写入确认。

亮点:

  • 多数据库 — 将开发/临时/生产连接挂载到一台服务器;每个工具都采用可选的database参数,每个连接都有自己的readonly / query_timeout / max_rows / confirm_writes 设置
  • 存储过程——列出签名并执行过程,并实现完整的多结果集采集
  • 资源模板 — schema://{database}/{schema}/{table} 按需服务表结构,无需每回合烧毁工具模式令牌
  • 安全栏杆 — SQL 白名单、只读模式、行限制、查询超时、写入前可选的触发确认

组成部分

  • read_query

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

MSSQL MCP Server

English | 中文

Overview

MSSQL MCP Server, provides database interaction and business intelligence capabilities. This server enables running SQL queries, analyzing business data, and automatically generating business insight memos.
Refer to the official website’s SQLite for modifications to adapt to MSSQL.

Built on the official MCP Python SDK (FastMCP), supporting the MCP 2025-06-18 specification: structured tool output (structuredContent), tool annotations, resource templates, and elicitation-based write confirmation.

Highlights:

  • Multi-database — mount dev/staging/prod connections in one server; every tool takes an optional database parameter, each connection with its own readonly / query_timeout / max_rows / confirm_writes settings
  • Stored procedures — list signatures and execute procedures with full multi-result-set harvesting
  • Resource templates — schema://{database}/{schema}/{table} serves table structures on demand without burning tool-schema tokens every turn
  • Safety guardrails — SQL whitelisting, read-only mode, row limits, query timeouts, optional elicitation confirmation before writes

Components

  • read_query
    • Execute SELECT / WITH queries with structured output (columns / rows / row_count / truncated), limited by max_rows
  • write_query
    • Execute INSERT, UPDATE, DELETE or MERGE queries, returns affected row count
  • create_table
    • Create new tables in the database
  • list_tables
    • Get a list of all tables in the database (schema + table name)
  • list_views
    • Get a list of all views in the database
  • describe_table
    • View full schema for a specific table (type, nullable, default, primary key, identity, foreign keys, indexes)
  • list_databases
    • List configured database connections (name, readonly, is_default)
  • list_procedures
    • List stored procedures with parameter signatures
  • execute_procedure
    • Execute a stored procedure (supports multiple result sets)
  • append_insight
    • Add new business insights to the memo resource

Resources

  • memo://insights — a living business-insights memo, updated in real time via append_insight
  • schema://{schema}/{table} — table structure of the default database (JSON: columns / PK / identity / FKs / indexes)
  • schema://{database}/{schema}/{table} — table structure of a named database connection

Resource templates are fetched on demand: unlike tool schemas they are not resent to the LLM every turn, which keeps long conversations lean.

Security

All SQL goes through static validation before execution:

  • read_query only accepts a single SELECT / WITH statement and rejects any write or EXEC keyword (blocks e.g. WITH c AS (...) DELETE FROM t)
  • write_query uses a whitelist (INSERT / UPDATE / DELETE / MERGE only); EXEC, DROP, TRUNCATE, ALTER are rejected
  • Multi-statement batches (separated by ;) are rejected
在 GitHub 查看完整 README

安装

npx -y @modelcontextprotocol/inspector python C:\\mssql-mcp\\src\\server.py
新手?先看 mcpskill.org 教程 →

配置

# add to claude_desktop_config.json. Note:use your path { "mcpServers": { "mssql": { "command": "python", "args": [ # your path,e.g.:"C:\\mssql-mcp\\src\\server.py" "~/server.py" ] } } }