Skip to main content

A MSSQL MCP server using pure Python TDS

Project description

mssql-py-mcp

A MSSQL MCP server implementation in Python, designed to work with the pytds library. This project provides a simple and efficient way to interact with Microsoft SQL Server databases, leveraging the pure Python pytds driver for connectivity.

This project uses pure pytds for database connections.

What is pytds?

pytds is a pure Python implementation of the Tabular Data Stream (TDS) protocol, which is used to communicate with Microsoft SQL Server. Unlike other drivers that rely on native libraries (like FreeTDS), pytds is written entirely in Python, making it platform-independent and easy to install.

Key Features of pytds

  • Pure Python: No external dependencies or compilers needed.
  • Cross-Platform: Runs on any platform where Python is supported.
  • Thread-Safe: Safe to use in multi-threaded applications.
  • Supports various authentication methods: Including SQL Server and Windows authentication.
  • Lightweight: Minimal overhead and easy to integrate.

Features

  • MCP Server: Implements the Minecraft JEWEI MCP protocol for database interaction.
  • MSSQL Connectivity: Connects to Microsoft SQL Server using pytds.
  • Database Operations: Supports executing queries, listing tables, and retrieving database information.
  • Easy Configuration: Uses a .env file for simple setup of database credentials.

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/mssql-py-mcp.git
    cd mssql-py-mcp
    
  2. Create a virtual environment (recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
    
  3. Install dependencies:

    pip install -r requirements.txt
    

Configuration

  1. Create a .env file in the root directory of the project. You can copy the example file:

    cp .env.example .env
    
  2. Edit the .env file with your MSSQL database credentials:

    DB_HOST=your_server_address
    DB_USER=your_username
    DB_PASSWORD=your_password
    DB_NAME=your_database_name
    DB_PORT=1433
    

Usage

Run the MCP server with the following command:

python -m mssql_py_mcp.server

The server will start and listen for incoming MCP connections on the default port.

How It Works

The server listens for MCP commands, establishes a connection to the MSSQL database using pytds, executes the requested queries, and returns the results in the MCP format. The core logic is handled in mssql_py_mcp/core.py, which manages the database connection and query execution.

Contributing

Contributions are welcome! Please open an issue or submit a pull request if you have any improvements or bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mssql_py_mcp-0.1.1.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mssql_py_mcp-0.1.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file mssql_py_mcp-0.1.1.tar.gz.

File metadata

  • Download URL: mssql_py_mcp-0.1.1.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for mssql_py_mcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ebfd37a83bbc3180eab412e8cfa4ffab6f1086d1c97a17fb5f7f5923bbe69cd8
MD5 6acc5d36c5d3ec9d3ae3f22a9a0a1cd8
BLAKE2b-256 1d11e6687f451cdf20684eab027b3f3dde733e754f5e7434562196864233558f

See more details on using hashes here.

File details

Details for the file mssql_py_mcp-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mssql_py_mcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 82e3dda2eeaa6ec589a086b1dfd5cbc2a2a2bbda4bd52b3d540397760ab65a93
MD5 a81d276e080c8dc72ded5652b8ab422a
BLAKE2b-256 2fd1a8184dbac769fb832b7c4ab713e19c238ee84dd24f73eff44619b7c5b99c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page