jeweis
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"jewei-mssql": {
"args": [
"jewei-mssql-mcp-server"
],
"command": "uvx",
"disabled": false,
"env": {
"DB_HOST": "your_db_host",
"DB_NAME": "your_db_name",
"DB_PASSWORD": "your_db_password",
"DB_USER": "your_db_user"
}
}
}
}
可用工具 (3 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
query_sql
执行SQL查询并返回结果集(仅支持SELECT语句)Args: sql: SQL查询语句(必须是SELECT语句,) Returns: 包含查询结果的字典,格式为: { columns: [列名列表], rows: [行数据列表], row_count: 结果行数 }
该工具无需必填参数,直接调用即可
get_table_structure
获取指定表的结构信息Args: table_name: 表名 schema: 架构名,默认为dbo Returns: 包含表结构信息的字典,格式为: { columns: [列信息列表], primary_keys: [主键列表], foreign_keys: [外键信息列表], indexes: [索引信息列表] }
该工具无需必填参数,直接调用即可
list_tables
列出数据库中的所有表Args: schema: 架构名,默认为dbo Returns: 包含表列表的字典,格式为: { tables: [表信息列表], count: 表数量 }
该工具无需必填参数,直接调用即可
服务介绍
Jewei MSSQL MCP Server
Project Overview
This is an MCP server developed based on the FastMCP framework, specifically designed for executing data queries and table structure queries on Microsoft SQL Server. The server provides a series of tools that enable clients to conveniently interact with SQL Server databases.
Features
- Data Query: Execute SQL queries and return result sets
- Table Structure Query: Obtain structural information about database tables
- Ease of Use: Provides standardized interfaces through the MCP protocol
- Efficiency and Reliability: Optimized database connection management
Technical Architecture
This project is built using the following technologies:
- FastMCP: A Python framework for building MCP servers
- Python: The primary development language
- Microsoft SQL Server: The target database system
- MCP Protocol: Used for communication between clients and the server
MCP Configuration
This project supports configuring the MCP server through various clients, allowing integration with different IDEs or tools. Below are some configuration examples for common clients:
Windsurf / Cursor / Claude
For clients based on the Windsurf framework (such as Cursor and Claude), you can configure the MCP server in the ~/.codeium/windsurf/mcp_config.json file. Here is an example configuration:
json
{
"mcpServers": {
"jewei-mssql": {
"disabled": false,
"command": "uvx",
"args": [
"jewei-mssql-mcp-server"
],
"env": {
"DB_HOST": "your_db_host",
"DB_USER": "your_db_user",
"DB_PASSWORD": "your_db_password",
"DB_NAME": "your_db_name",
"DB_PORT": "your_db_port"
}
}
}
}
Replace your_db_host, your_db_user, your_db_password, and your_db_name with your actual database connection information.
Cline
For the Cline client, you can add a similar MCP server configuration in its configuration file. Please refer to the official Cline documentation for specific configuration methods. Typically, you need to specify the server name, command, arguments, and environment variables.
json
// Example Cline configuration file (refer to Cline documentation for exact format)
{
"mcpServers": {
"jewei-mssql": {
"command": "uvx",
"args": [
"jewei-mssql-mcp-server"
],
"env": {
"DB_HOST": "your_db_host",
"DB_USER": "your_db_user",
"DB_PASSWORD": "your_db_password",
"DB_NAME": "your_db_name",
"DB_PORT": "your_db_port"
}
}
}
}
Replace the placeholders in the example with your actual database connection information and adjust according to the specific configuration format of Cline.
Installation and Configuration
Prerequisites
- Python 3.7+
- Access to Microsoft SQL Server
- FastMCP library
Installation Steps
Method One: Install via PyPI (Recommended)
bash
pip install jewei-mssql-mcp-server
Method Two: Install from Source Code
-
Clone this repository
bash
git clone [Repository URL]
cd jewei-mssql-mcp-server -
Install dependencies
bash
pip install -r requirements.txt -
Configure database connection
- Create a configuration file or set environment variables (see below for specific configuration methods)
Usage
Start the Server
bash
python server.py
By default, the server uses the STDIO transport mechanism. To use HTTP transport, modify the relevant configuration in server.py.
Client Call Example
Any client that supports the MCP protocol can connect to this server. Here is a basic call example:
python
from fastmcp import Client
Connect to the MCP server
client = Client("http://localhost:9000")
Execute SQL query
result = client.call("query_sql", sql="SELECT * FROM users LIMIT 10")
print(result)
Get table structure
structure = client.call("get_table_structure", table_name="users")
print(structure)
Configuration Options
Server configurations can be set in the following ways:
- Environment Variables
- Configuration Files
- Directly in the Code
- Through uv for MCP server configuration
Using uv to Install and Manage Dependencies
This project supports using uv (a fast Python package manager) to install and manage dependencies. Using uv can significantly improve package installation speed and ensure environment consistency.
First, install uv:
bash
Install uv
pip install uvThen use uv to create a virtual environment and install the dependencies:
bash
Create a virtual environment
uv venv
Activate the virtual environment
Windows
.venvScriptsactivate
Linux/macOS
source .venv/bin/activate
Install dependencies using uv
uv pip install -r requirements.txt
After installation, you can start the MCP server as follows:
bash
python server.py
You can also configure the server in the ~/.codeium/windsurf/mcp_config.json file for integration with Cascade. This project supports using the uvx command to configure the MCP server:
json
{
"mcpServers": {
"jewei-mssql": {
"disabled": false,
"command": "uvx",
"args": [
"jewei-mssql-mcp-server"
],
"env": {
"DB_HOST": "your_db_host",
"DB_USER": "your_db_user",
"DB_PASSWORD": "your_db_password",
"DB_NAME": "your_db_name"
}
}
}
}
Here, uvx is the command used to run the installed Python package, and jewei-mssql-mcp-server is the package name. This method ensures that the MCP server runs in the correct environment.
Main Configuration Items
The main configuration items include:
- Database connection information (server address, username, password, database name)
- Server listening address and port
- Log level
Contribution Guidelines
We welcome code contributions or suggestions for improvement! Please follow these steps:
- Fork this repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
[Specify license type]
Contact
If you have any questions or suggestions, please contact [contact information].