A read-only MCP server for interacting with a DB2 database.
Project description
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
-
Clone the Repository
git clone <repository-url> cd db2-mcp-server
-
Set Up Virtual Environment
uv v0.6.x source uv/bin/activate
-
Install Dependencies
pip install -r requirements.txt
-
Run the Server
python src/db2_mcp_server/core.py
Testing
- Use
pytest(version ≥ 7.0.0) for running tests. - Current test coverage: 97.19% (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)
- 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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file db2_mcp_server-0.1.2.tar.gz.
File metadata
- Download URL: db2_mcp_server-0.1.2.tar.gz
- Upload date:
- Size: 19.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cdbb9f1c7979265ff8465022ed3f794199defeb8458effb07db970560f32e72
|
|
| MD5 |
2728f866c03a6852fdd573a4c86379f6
|
|
| BLAKE2b-256 |
d94848309ecbc2c1e1b90e5ce6dfcc9667e299e9a7a2ce3edb3cb266ee899aa0
|
File details
Details for the file db2_mcp_server-0.1.2-py3-none-any.whl.
File metadata
- Download URL: db2_mcp_server-0.1.2-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c2f25a3b46085654b5bc092dbdcf75189247958a17e5dd5caf0803f20afdab4
|
|
| MD5 |
fc87210863f36c041e8ad6ead7ed781b
|
|
| BLAKE2b-256 |
df8f2d0284dd68039ec727c3bf9ccd6716ab79818eff0eef1930a3f027881fe4
|