Provides a FastMCP framework interface for executing Microsoft SQL Server database queries and retrieving table structure information through Python-based client applications.
Jewei MSSQL MCP 服务器
项目简介
这是一个基于FastMCP框架开发的MCP服务器,专门用于执行Microsoft SQL Server的数据查询和表结构查询操作。该服务器提供了一系列工具,使客户端能够方便地与SQL Server数据库进行交互。
功能特点
- 数据查询:执行SQL查询并返回结果集
- 表结构查询:获取数据库表的结构信息
- 简单易用:通过MCP协议提供标准化的接口
- 高效可靠:优化的数据库连接管理
技术架构
本项目基于以下技术构建:
- FastMCP:一个用于构建MCP服务器的Python框架
- Python:主要开发语言
- Microsoft SQL Server:目标数据库系统
- MCP协议:用于客户端与服务器之间的通信
MCP 配置
本项目支持通过多种客户端配置 MCP 服务器,以便与各种 IDE 或工具集成。以下是一些常见客户端的配置示例:
Windsurf / Cursor / Claude
对于基于 Windsurf 框架的客户端(如 Cursor 和 Claude),您可以在 ~/.codeium/windsurf/mcp_config.json
文件中配置 MCP 服务器。以下是一个示例配置:
请将 your_db_host
, your_db_user
, your_db_password
, 和 your_db_name
替换为您的实际数据库连接信息。
Cline
对于 Cline 客户端,您可以在其配置文件中添加类似的 MCP 服务器配置。具体的配置方式请参考 Cline 的官方文档。通常,您需要指定服务器的名称、命令、参数和环境变量。
请将示例中的占位符替换为您的实际数据库连接信息,并根据 Cline 的具体配置格式进行调整。
安装与配置
前提条件
- Python 3.7+
- 访问Microsoft SQL Server的权限
- FastMCP库
安装步骤
方法一:通过PyPI安装(推荐)
方法二:从源码安装
- 克隆本仓库
- 安装依赖
- 配置数据库连接
- 创建配置文件或设置环境变量(具体配置方法见下文)
使用方法
启动服务器
默认情况下,服务器使用STDIO传输机制。如需使用HTTP传输,可修改server.py
中的相关配置。
客户端调用示例
使用任何支持MCP协议的客户端都可以连接到此服务器。以下是一个基本的调用示例:
配置选项
服务器配置可以通过以下方式设置:
- 环境变量
- 配置文件
- 直接在代码中设置
- 通过uv配置MCP服务器
使用uv安装和管理依赖
本项目支持使用uv(一个快速的Python包管理器)来安装和管理依赖。使用uv可以显著提高包安装速度并确保环境一致性。
首先安装uv:
然后使用uv创建虚拟环境并安装依赖:
安装完成后,您可以通过以下方式启动MCP服务器:
您也可以在~/.codeium/windsurf/mcp_config.json
文件中配置服务器,以便与Cascade集成。本项目支持使用uvx命令来配置MCP服务器:
其中,uvx
是用于运行已安装的Python包的命令,jewei-mssql-mcp-server
是包名。这种方式可以确保使用正确的环境运行MCP服务器。
主要配置项
主要配置项包括:
- 数据库连接信息(服务器地址、用户名、密码、数据库名)
- 服务器监听地址和端口
- 日志级别
贡献指南
欢迎贡献代码或提出改进建议!请遵循以下步骤:
- Fork本仓库
- 创建功能分支 (
git checkout -b feature/amazing-feature
) - 提交更改 (
git commit -m 'Add some amazing feature'
) - 推送到分支 (
git push origin feature/amazing-feature
) - 创建Pull Request
许可证
[指定许可证类型]
联系方式
如有问题或建议,请联系[联系人信息]。
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
A FastMCP-based server that enables executing Microsoft SQL Server data queries and table structure queries through a standardized MCP protocol interface.
Related MCP Servers
- -securityAlicense-qualityFastMCP is a comprehensive MCP server allowing secure and standardized data and functionality exposure to LLM applications, offering resources, tools, and prompt management for efficient LLM interactions.Last updated -3PythonMIT License
- -securityFlicense-qualityA FastMCP server that provides natural language interaction with MS SQL databases, enabling users to query data, list tables, describe structures, and execute database operations through a conversational AI interface.Last updated -Python
- -securityAlicense-qualityOpen source MCP server specializing in easy, fast, and secure tools for Databases.Last updated -1,319GoApache 2.0
- -security-license-qualityAn MCP server that allows working with MySQL databases by providing tools for executing read-only SQL queries, getting table schemas, and listing database tables.Last updated -1JavaScript