db2-mcp-server logo

db2-mcp-server

by huangjien

The db2-mcp-server is a Python-based server using the MCP framework to interact with IBM DB2 databases. It provides tools for listing tables and retrieving table metadata.

View on GitHub

Last updated: N/A

db2-mcp-server

Overview

The db2-mcp-server is a Python-based server utilizing the MCP framework to interact with IBM DB2 databases. It provides tools for listing tables and retrieving table metadata.

Features

  • List Tables: Retrieve a list of tables from the connected DB2 database.
  • Get Table Metadata: Fetch metadata for a specific table, including column details and data types.

Requirements

  • Python 3.12
  • FastMCP (latest stable version)
  • IBM DB2 Python driver (ibm_db)
  • Pydantic

Setup Instructions

  1. Clone the Repository

    git clone <repository-url>
    cd db2-mcp-server
    
  2. Set Up Virtual Environment

    uv v0.6.x
    source uv/bin/activate
    
  3. Install Dependencies

    pip install -r requirements.txt
    
  4. Run the Server

    python src/db2_mcp_server/core.py
    

Testing

  • Use pytest (version ≥ 7.0.0) for running tests.
  • Ensure code coverage is ≥ 90%.
  • Run tests with:
    pytest --strict-markers --cov
    

Security and API Restrictions

  • The server is read-only, prohibiting SQL INSERT, UPDATE, or DELETE operations.
  • Uses a database user with only SELECT privileges.

Logging

  • Errors are logged with structured logs in JSON format, excluding sensitive data.

Contribution

  • Contributions are welcome. Please follow the project's coding standards and testing guidelines.