mcp-dbutils 0.14.0__py3-none-any.whl → 0.15.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_dbutils/__init__.py +4 -3
- mcp_dbutils/base.py +5 -6
- mcp_dbutils/config.py +3 -4
- mcp_dbutils/log.py +2 -1
- mcp_dbutils/mysql/__init__.py +1 -1
- mcp_dbutils/mysql/config.py +4 -2
- mcp_dbutils/mysql/handler.py +2 -2
- mcp_dbutils/mysql/server.py +6 -6
- mcp_dbutils/postgres/__init__.py +1 -1
- mcp_dbutils/postgres/config.py +4 -2
- mcp_dbutils/postgres/handler.py +2 -2
- mcp_dbutils/postgres/server.py +6 -6
- mcp_dbutils/sqlite/__init__.py +1 -1
- mcp_dbutils/sqlite/config.py +4 -2
- mcp_dbutils/sqlite/handler.py +2 -2
- mcp_dbutils/sqlite/server.py +5 -6
- mcp_dbutils/stats.py +4 -3
- {mcp_dbutils-0.14.0.dist-info → mcp_dbutils-0.15.0.dist-info}/METADATA +36 -1
- mcp_dbutils-0.15.0.dist-info/RECORD +22 -0
- mcp_dbutils-0.14.0.dist-info/RECORD +0 -22
- {mcp_dbutils-0.14.0.dist-info → mcp_dbutils-0.15.0.dist-info}/WHEEL +0 -0
- {mcp_dbutils-0.14.0.dist-info → mcp_dbutils-0.15.0.dist-info}/entry_points.txt +0 -0
- {mcp_dbutils-0.14.0.dist-info → mcp_dbutils-0.15.0.dist-info}/licenses/LICENSE +0 -0
mcp_dbutils/__init__.py
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
"""MCP Connection Utilities Service"""
|
2
2
|
|
3
|
-
import asyncio
|
4
3
|
import argparse
|
4
|
+
import asyncio
|
5
5
|
import os
|
6
6
|
import sys
|
7
|
+
from importlib.metadata import metadata
|
7
8
|
from pathlib import Path
|
9
|
+
|
8
10
|
import yaml
|
9
|
-
from importlib.metadata import metadata
|
10
11
|
|
12
|
+
from .base import LOG_NAME, ConnectionServer
|
11
13
|
from .log import create_logger
|
12
|
-
from .base import ConnectionServer, LOG_NAME
|
13
14
|
|
14
15
|
# 获取包信息
|
15
16
|
pkg_meta = metadata("mcp-dbutils")
|
mcp_dbutils/base.py
CHANGED
@@ -12,18 +12,17 @@ class ConnectionError(ConnectionHandlerError):
|
|
12
12
|
"""Connection related errors"""
|
13
13
|
pass
|
14
14
|
|
15
|
+
import json
|
15
16
|
from abc import ABC, abstractmethod
|
16
|
-
from typing import Any, List, Optional, AsyncContextManager
|
17
17
|
from contextlib import asynccontextmanager
|
18
|
-
import json
|
19
|
-
import yaml
|
20
|
-
import time
|
21
18
|
from datetime import datetime
|
22
19
|
from importlib.metadata import metadata
|
23
|
-
from
|
20
|
+
from typing import AsyncContextManager
|
21
|
+
|
24
22
|
import mcp.server.stdio
|
25
23
|
import mcp.types as types
|
26
|
-
|
24
|
+
import yaml
|
25
|
+
from mcp.server import Server
|
27
26
|
|
28
27
|
from .log import create_logger
|
29
28
|
from .stats import ResourceStats
|
mcp_dbutils/config.py
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
"""Common configuration utilities"""
|
2
2
|
|
3
3
|
import os
|
4
|
-
import yaml
|
5
4
|
from abc import ABC, abstractmethod
|
6
|
-
from
|
7
|
-
|
8
|
-
|
5
|
+
from typing import Any, Dict, Literal
|
6
|
+
|
7
|
+
import yaml
|
9
8
|
|
10
9
|
# Supported connection types
|
11
10
|
ConnectionType = Literal['sqlite', 'postgres', 'mysql']
|
mcp_dbutils/log.py
CHANGED
mcp_dbutils/mysql/__init__.py
CHANGED
mcp_dbutils/mysql/config.py
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
"""MySQL configuration module"""
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import
|
4
|
-
from urllib.parse import
|
3
|
+
from typing import Any, Dict, Literal, Optional
|
4
|
+
from urllib.parse import parse_qs, urlparse
|
5
|
+
|
5
6
|
from ..config import ConnectionConfig
|
6
7
|
|
8
|
+
|
7
9
|
@dataclass
|
8
10
|
class SSLConfig:
|
9
11
|
"""SSL configuration for MySQL connection"""
|
mcp_dbutils/mysql/handler.py
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
"""MySQL connection handler implementation"""
|
2
2
|
|
3
|
-
import mysql.connector
|
4
|
-
from mysql.connector.pooling import MySQLConnectionPool
|
5
3
|
import mcp.types as types
|
4
|
+
import mysql.connector
|
6
5
|
|
7
6
|
from ..base import ConnectionHandler, ConnectionHandlerError
|
8
7
|
from .config import MySQLConfig
|
9
8
|
|
9
|
+
|
10
10
|
class MySQLHandler(ConnectionHandler):
|
11
11
|
@property
|
12
12
|
def db_type(self) -> str:
|
mcp_dbutils/mysql/server.py
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
"""MySQL MCP server implementation"""
|
2
|
+
from typing import Optional
|
3
|
+
|
4
|
+
import mcp.types as types
|
2
5
|
import mysql.connector
|
3
6
|
from mysql.connector.pooling import MySQLConnectionPool, PooledMySQLConnection
|
4
|
-
|
5
|
-
|
6
|
-
from
|
7
|
-
from ..base import ConnectionServer
|
7
|
+
|
8
|
+
# 获取包信息用于日志命名
|
9
|
+
from ..base import LOG_NAME, ConnectionServer
|
8
10
|
from ..log import create_logger
|
9
11
|
from .config import MySQLConfig
|
10
12
|
|
11
|
-
# 获取包信息用于日志命名
|
12
|
-
from ..base import LOG_NAME
|
13
13
|
|
14
14
|
class MySQLServer(ConnectionServer):
|
15
15
|
def __init__(self, config: MySQLConfig, config_path: Optional[str] = None):
|
mcp_dbutils/postgres/__init__.py
CHANGED
mcp_dbutils/postgres/config.py
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
"""PostgreSQL configuration module"""
|
2
2
|
from dataclasses import dataclass
|
3
|
-
from typing import
|
4
|
-
from urllib.parse import
|
3
|
+
from typing import Any, Dict, Literal, Optional
|
4
|
+
from urllib.parse import parse_qs, urlparse
|
5
|
+
|
5
6
|
from ..config import ConnectionConfig
|
6
7
|
|
8
|
+
|
7
9
|
@dataclass
|
8
10
|
class SSLConfig:
|
9
11
|
"""SSL configuration for PostgreSQL connection"""
|
mcp_dbutils/postgres/handler.py
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
"""PostgreSQL connection handler implementation"""
|
2
2
|
|
3
|
-
import psycopg2
|
4
|
-
from psycopg2.pool import SimpleConnectionPool
|
5
3
|
import mcp.types as types
|
4
|
+
import psycopg2
|
6
5
|
|
7
6
|
from ..base import ConnectionHandler, ConnectionHandlerError
|
8
7
|
from .config import PostgreSQLConfig
|
9
8
|
|
9
|
+
|
10
10
|
class PostgreSQLHandler(ConnectionHandler):
|
11
11
|
@property
|
12
12
|
def db_type(self) -> str:
|
mcp_dbutils/postgres/server.py
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
"""PostgreSQL MCP server implementation"""
|
2
|
+
from typing import Optional
|
3
|
+
|
4
|
+
import mcp.types as types
|
2
5
|
import psycopg2
|
3
6
|
from psycopg2.pool import SimpleConnectionPool
|
4
|
-
|
5
|
-
|
6
|
-
from
|
7
|
-
from ..base import ConnectionServer
|
7
|
+
|
8
|
+
# 获取包信息用于日志命名
|
9
|
+
from ..base import LOG_NAME, ConnectionServer
|
8
10
|
from ..log import create_logger
|
9
11
|
from .config import PostgreSQLConfig
|
10
12
|
|
11
|
-
# 获取包信息用于日志命名
|
12
|
-
from ..base import LOG_NAME
|
13
13
|
|
14
14
|
class PostgreSQLServer(ConnectionServer):
|
15
15
|
def __init__(self, config: PostgreSQLConfig, config_path: Optional[str] = None):
|
mcp_dbutils/sqlite/__init__.py
CHANGED
mcp_dbutils/sqlite/config.py
CHANGED
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
from dataclasses import dataclass
|
4
4
|
from pathlib import Path
|
5
|
-
from typing import Dict,
|
6
|
-
from urllib.parse import
|
5
|
+
from typing import Any, Dict, Literal, Optional
|
6
|
+
from urllib.parse import parse_qs, urlparse
|
7
|
+
|
7
8
|
from ..config import ConnectionConfig
|
8
9
|
|
10
|
+
|
9
11
|
def parse_jdbc_url(jdbc_url: str) -> Dict[str, str]:
|
10
12
|
"""Parse JDBC URL into connection parameters
|
11
13
|
|
mcp_dbutils/sqlite/handler.py
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
"""SQLite connection handler implementation"""
|
2
2
|
|
3
3
|
import sqlite3
|
4
|
-
|
5
|
-
from typing import Any
|
4
|
+
|
6
5
|
import mcp.types as types
|
7
6
|
|
8
7
|
from ..base import ConnectionHandler, ConnectionHandlerError
|
9
8
|
from .config import SQLiteConfig
|
10
9
|
|
10
|
+
|
11
11
|
class SQLiteHandler(ConnectionHandler):
|
12
12
|
@property
|
13
13
|
def db_type(self) -> str:
|
mcp_dbutils/sqlite/server.py
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
"""SQLite MCP server implementation"""
|
2
2
|
|
3
3
|
import sqlite3
|
4
|
-
from pathlib import Path
|
5
4
|
from contextlib import closing
|
6
|
-
from
|
5
|
+
from pathlib import Path
|
6
|
+
from typing import Optional
|
7
|
+
|
7
8
|
import mcp.types as types
|
8
|
-
from importlib.metadata import metadata
|
9
9
|
|
10
|
-
|
10
|
+
# 获取包信息用于日志命名
|
11
|
+
from ..base import LOG_NAME, ConnectionServer
|
11
12
|
from ..log import create_logger
|
12
13
|
from .config import SQLiteConfig
|
13
14
|
|
14
|
-
# 获取包信息用于日志命名
|
15
|
-
from ..base import LOG_NAME
|
16
15
|
|
17
16
|
class SQLiteServer(ConnectionServer):
|
18
17
|
def __init__(self, config: SQLiteConfig, config_path: Optional[str] = None):
|
mcp_dbutils/stats.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
"""Resource monitoring statistics module"""
|
2
2
|
|
3
|
+
import statistics
|
4
|
+
import sys
|
3
5
|
from dataclasses import dataclass
|
4
6
|
from datetime import datetime
|
5
|
-
from typing import
|
6
|
-
|
7
|
-
import statistics
|
7
|
+
from typing import List, Optional, Tuple
|
8
|
+
|
8
9
|
|
9
10
|
@dataclass
|
10
11
|
class ResourceStats:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mcp-dbutils
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.15.0
|
4
4
|
Summary: MCP Database Utilities Service
|
5
5
|
Author: Dong Hao
|
6
6
|
License-Expression: MIT
|
@@ -14,10 +14,12 @@ Requires-Dist: pyyaml>=6.0.2
|
|
14
14
|
Provides-Extra: test
|
15
15
|
Requires-Dist: aiosqlite>=0.19.0; extra == 'test'
|
16
16
|
Requires-Dist: docker>=7.0.0; extra == 'test'
|
17
|
+
Requires-Dist: pre-commit>=3.6.0; extra == 'test'
|
17
18
|
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'test'
|
18
19
|
Requires-Dist: pytest-cov>=4.1.0; extra == 'test'
|
19
20
|
Requires-Dist: pytest-docker>=2.0.0; extra == 'test'
|
20
21
|
Requires-Dist: pytest>=7.0.0; extra == 'test'
|
22
|
+
Requires-Dist: ruff>=0.3.0; extra == 'test'
|
21
23
|
Requires-Dist: testcontainers>=3.7.0; extra == 'test'
|
22
24
|
Description-Content-Type: text/markdown
|
23
25
|
|
@@ -483,6 +485,19 @@ Our CI/CD pipeline automatically performs:
|
|
483
485
|
|
484
486
|
Pull requests that don't meet these standards will be automatically blocked from merging.
|
485
487
|
|
488
|
+
### Code Style
|
489
|
+
We use Ruff for code style checking and formatting:
|
490
|
+
|
491
|
+
[](https://github.com/astral-sh/ruff)
|
492
|
+
|
493
|
+
All code must follow our style guide:
|
494
|
+
- Line length: 88 characters
|
495
|
+
- Indentation: 4 spaces
|
496
|
+
- Quotes: Double quotes
|
497
|
+
- Naming: PEP8 conventions
|
498
|
+
|
499
|
+
For detailed guidelines, see [STYLE_GUIDE.md](docs/STYLE_GUIDE.md).
|
500
|
+
|
486
501
|
### Local Development
|
487
502
|
To check code quality locally:
|
488
503
|
1. Run tests with coverage:
|
@@ -491,6 +506,26 @@ To check code quality locally:
|
|
491
506
|
```
|
492
507
|
2. Use SonarLint in your IDE to catch issues early
|
493
508
|
3. Review SonarCloud analysis results in PR comments
|
509
|
+
4. Run Ruff for code style checking:
|
510
|
+
```bash
|
511
|
+
# Install Ruff
|
512
|
+
uv pip install ruff
|
513
|
+
|
514
|
+
# Check code style
|
515
|
+
ruff check .
|
516
|
+
|
517
|
+
# Format code
|
518
|
+
ruff format .
|
519
|
+
```
|
520
|
+
5. Use pre-commit hooks for automatic checks:
|
521
|
+
```bash
|
522
|
+
# Install pre-commit
|
523
|
+
uv pip install pre-commit
|
524
|
+
pre-commit install
|
525
|
+
|
526
|
+
# Run all checks
|
527
|
+
pre-commit run --all-files
|
528
|
+
```
|
494
529
|
|
495
530
|
## Contributing
|
496
531
|
Contributions are welcome! Here's how you can help:
|
@@ -0,0 +1,22 @@
|
|
1
|
+
mcp_dbutils/__init__.py,sha256=6LLccQv7je2L4IpY_I3OzSJZcK32VUDJv2IY31y6eYg,1900
|
2
|
+
mcp_dbutils/base.py,sha256=A9BUV3YmFpjkW88nfnJv38Fbk4gu3tHIs2D8Wpitg9E,27571
|
3
|
+
mcp_dbutils/config.py,sha256=bmXpOd1fyYfoyUS75I035ChT6t3wP5AyEnJ06e2ZS2o,1848
|
4
|
+
mcp_dbutils/log.py,sha256=pwnY1Y8R0wWrAFleFJlOM6m1ey1itgwijsXZmWFd2Z0,819
|
5
|
+
mcp_dbutils/stats.py,sha256=dOEvkEgZwgbbQn10diS-VNUyuhCCNGlQ990ZoCqTKHM,7102
|
6
|
+
mcp_dbutils/mysql/__init__.py,sha256=gNhoHaxK1qhvMAH5AVl1vfV1rUpcbV9KZWUQb41aaQk,129
|
7
|
+
mcp_dbutils/mysql/config.py,sha256=Yvdd02ZwPMM7RCjEvjNJphGiUfImI7Q2gcEH6Zi3Vjo,8071
|
8
|
+
mcp_dbutils/mysql/handler.py,sha256=J-vitJ1DDZIGB3OTDdAai3rzvR2DEpFrvZ9egcKbJi4,19682
|
9
|
+
mcp_dbutils/mysql/server.py,sha256=6Tcs5pAb_YZPjP5EjtGMT-bHa4kICXehbLqbS22nLOM,8526
|
10
|
+
mcp_dbutils/postgres/__init__.py,sha256=-2zYuEJEQ2AMvmGhH5Z_umerSvt7S4xOa_XV4wgvGfI,154
|
11
|
+
mcp_dbutils/postgres/config.py,sha256=NyQOVhkXJ1S-JD0w-ePNjTKI1Ja-aZQkDUdHi6U7Vl4,7752
|
12
|
+
mcp_dbutils/postgres/handler.py,sha256=3uiXK0-Qgn5Rbyr-C2FX9Khk7H2O7-jYQ06kfM1RAJg,24351
|
13
|
+
mcp_dbutils/postgres/server.py,sha256=_CiJC9PitpI1NB99Q1Bcs5TYADNgDpYMwv88fRHQunE,8640
|
14
|
+
mcp_dbutils/sqlite/__init__.py,sha256=fK_3-WylCBYpBAzwuopi8hlwoIGJm2TPAlwcPWG46I0,134
|
15
|
+
mcp_dbutils/sqlite/config.py,sha256=B_LlB8I1Akh70brcTSuIESEVTz27wayN-NLoVXk5ykE,4535
|
16
|
+
mcp_dbutils/sqlite/handler.py,sha256=y1ICrwhoJNczUiACkadhS4FAAb2c5RvMZwEk4J_qwq0,17698
|
17
|
+
mcp_dbutils/sqlite/server.py,sha256=OMKOMCDJLlodKQMsqtsRbHAteKYDNaLV6tvz_LhZWdo,7631
|
18
|
+
mcp_dbutils-0.15.0.dist-info/METADATA,sha256=7oY5Z-fYgAo7GqTyv4eUaiL6gVoqqEqdEdlVL732J8Q,16095
|
19
|
+
mcp_dbutils-0.15.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
20
|
+
mcp_dbutils-0.15.0.dist-info/entry_points.txt,sha256=XTjt0QmYRgKOJQT6skR9bp1EMUfIrgpHeZJPZ3CJffs,49
|
21
|
+
mcp_dbutils-0.15.0.dist-info/licenses/LICENSE,sha256=1A_CwpWVlbjrKdVEYO77vYfnXlW7oxcilZ8FpA_BzCI,1065
|
22
|
+
mcp_dbutils-0.15.0.dist-info/RECORD,,
|
@@ -1,22 +0,0 @@
|
|
1
|
-
mcp_dbutils/__init__.py,sha256=t3Ds0b_WhFSSw2widqJ2IDQdIGNQuM5215UU-hENPXw,1899
|
2
|
-
mcp_dbutils/base.py,sha256=TDE5y7e2-Q5WOKFCesMnoNfLBzEb4UNd0-DvAj_IUy0,27672
|
3
|
-
mcp_dbutils/config.py,sha256=K0rlNio8sjuTp-CAuY1CnG8zljp2dhPsfZY7wUhwZX4,1923
|
4
|
-
mcp_dbutils/log.py,sha256=wKyMzB8IpKI7wsDUsN5SRfjf-bh_se6U9QhmzoNuxhw,809
|
5
|
-
mcp_dbutils/stats.py,sha256=WYD9NAKHH2bFKmUSTOg18-SuIXergpznPq8AtIjtxdI,7101
|
6
|
-
mcp_dbutils/mysql/__init__.py,sha256=OgwFO0gdymkvcEw-d1yqJB55XhcucmYQMEZkQ__CG_M,129
|
7
|
-
mcp_dbutils/mysql/config.py,sha256=C977PtaRk7gJm47fV7NaPeEDGInDZNBIQKfcgvjdBbU,8069
|
8
|
-
mcp_dbutils/mysql/handler.py,sha256=AJ1C-aVsBD3NXD31UjFC44cl4yuNeOO-HOY2mFBym0U,19737
|
9
|
-
mcp_dbutils/mysql/server.py,sha256=lL_Q9D5AFKTKdm_sl3Eo8LC3_vKOffYpqokw4kc4IrY,8588
|
10
|
-
mcp_dbutils/postgres/__init__.py,sha256=XanCXw-kVE6ayqFqjuLJ9swWPcCVlcKZXB2Et2Wjl9w,154
|
11
|
-
mcp_dbutils/postgres/config.py,sha256=FG0YUV4TtP1IGZT87ov_PK-ouOEjAOHdSaK42klk5OE,7750
|
12
|
-
mcp_dbutils/postgres/handler.py,sha256=O45K0MOosNQ68SJ8piXXH3aZ74RVQ981hudk6faj28Y,24397
|
13
|
-
mcp_dbutils/postgres/server.py,sha256=VKiIQhEoup2ye1XX14z12lRtR2-mYXMRe4Lfso0crOg,8702
|
14
|
-
mcp_dbutils/sqlite/__init__.py,sha256=lTUOkSfSWNw_BohJ_KNxYKMCANdtpGa3JK_ZyJsg_Ls,134
|
15
|
-
mcp_dbutils/sqlite/config.py,sha256=2ekTp89rcCu4qQN1O3sZjIcOwjhzWi4tisD20T2WAik,4533
|
16
|
-
mcp_dbutils/sqlite/handler.py,sha256=VxBVbwpNSQHyiudQXYFYpcdoScvbK2IGzYMbkcpvFcI,17731
|
17
|
-
mcp_dbutils/sqlite/server.py,sha256=PBjQLvxuxMq7FhTuu5ZX1y1AR1casCbio4dp1eeX6y0,7694
|
18
|
-
mcp_dbutils-0.14.0.dist-info/METADATA,sha256=luBQ5_SiC5LDs5aO-TBDNHqqJt7eb_Q1fC_g6opDe3o,15241
|
19
|
-
mcp_dbutils-0.14.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
20
|
-
mcp_dbutils-0.14.0.dist-info/entry_points.txt,sha256=XTjt0QmYRgKOJQT6skR9bp1EMUfIrgpHeZJPZ3CJffs,49
|
21
|
-
mcp_dbutils-0.14.0.dist-info/licenses/LICENSE,sha256=1A_CwpWVlbjrKdVEYO77vYfnXlW7oxcilZ8FpA_BzCI,1065
|
22
|
-
mcp_dbutils-0.14.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|