Skip to main content

db2-mcp-server

PyPI version License: MIT Coverage

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.
  • Dynamic Prompt Loading: Load custom prompts from JSON configuration files for flexible query assistance.
  • Built-in Prompts: Pre-configured prompts for DB2 query help and schema analysis.

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
    

Dynamic Prompts

The server supports dynamic prompt loading from JSON configuration files. Set the PROMPTS_FILE environment variable to specify a custom prompts configuration file.

Example Usage

export PROMPTS_FILE=/path/to/your/prompts_config.json
python src/db2_mcp_server/core.py

Configuration Format

See examples/prompts_config.json for a complete example and docs/DYNAMIC_PROMPTS.md for detailed documentation.

Testing

  • Use pytest (version ≥ 7.0.0) for running tests.
  • Current test coverage: 92.98% (exceeding the 80% requirement).
  • Comprehensive test suite includes:
    • Core functionality tests (test_core.py)
    • Database tools tests (test_list_tables.py, test_metadata_retrieval.py)
    • Caching mechanism tests (test_cache.py)
    • Logging configuration tests (test_logger.py)
    • Dynamic prompt loading tests (test_dynamic_loader.py, test_integration_dynamic_prompts.py)
  • Run tests with:
    pytest --cov=src/db2_mcp_server --cov-report=html tests/
    
  • For verbose output:
    pytest --cov=src/db2_mcp_server --cov-report=term-missing -v
    

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.

Metadata

Release files for db2-mcp-server 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for db2-mcp-server 0.2.2
File Size Uploaded
db2_mcp_server-0.2.2.tar.gz 31.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for db2-mcp-server 0.2.2
File Interpreter ABI Platform
db2_mcp_server-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 52.7 kB

Release files / db2_mcp_server-0.2.2.tar.gz

Download URL db2_mcp_server-0.2.2.tar.gz
Size 31.5 kB
Tags Source
SHA-256 checksum
How to use checksums
833acb385d049417595a08617f3d244c41c0ae75377526694bd19528200a4e49
BLAKE2b-256 checksum
How to use checksums
8e6d9dff2de1465153f81069d9467a0ee92aa7a1ecb086839ee035f0065fffda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / db2_mcp_server-0.2.2-py3-none-any.whl

Download URL db2_mcp_server-0.2.2-py3-none-any.whl
Size 21.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cb6a36ae22a467276b05000a708f621f50f31e5dbd6e48aeaad820aaa639b8ed
BLAKE2b-256 checksum
How to use checksums
54262c9e60aae0b3250fa8617a2926b74a1e2d5d75ec27f9a96992870e92cdbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page