About
MCP server for DB2
README
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
Clone the Repository
git clone <repository-url> cd db2-mcp-serverSet Up Virtual Environment
uv v0.6.x source uv/bin/activateInstall Dependencies
pip install -r requirements.txtRun 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)
- Core functionality tests (
- 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.
Installing Db2
This server has no published package — it is built from source. Open the repository and follow its README.
▸ github.com/huangjien/db2-mcp-serverFAQ
Is Db2 MCP free?
Yes, Db2 MCP is free — one-click install via Unyly at no cost.
Does Db2 need an API key?
No, Db2 runs without API keys or environment variables.
Is Db2 hosted or self-hosted?
Self-hosted: the server runs locally on your machine via the install command above.
How do I install Db2 in Claude Desktop, Claude Code or Cursor?
Open Db2 on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
GitHub
PRs, issues, code search, CI status
by GitHubFilesystem
Secure file operations with configurable access controls.
Memory
Knowledge graph-based persistent memory system.
Template MCP Server
A CLI tool to create a new Model Context Protocol server project with TypeScript support, dual transport options, and an extensible structure
by mcpdotdirectCompare Db2 with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All development MCPs
