mcp-dbutils 0.6.0__tar.gz → 0.7.0__tar.gz
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-0.6.0 → mcp_dbutils-0.7.0}/CHANGELOG.md +18 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/PKG-INFO +18 -2
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/README.md +17 -1
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/README_CN.md +17 -1
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/pyproject.toml +1 -1
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/src/mcp_dbutils/base.py +6 -1
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/tests/integration/test_tools.py +4 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/.coveragerc +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/.github/workflows/release.yml +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/.github/workflows/test.yml +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/.gitignore +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/Dockerfile +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/LICENSE +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/config.yaml.example +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/smithery.yaml +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/src/mcp_dbutils/__init__.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/src/mcp_dbutils/config.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/src/mcp_dbutils/log.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/src/mcp_dbutils/postgres/__init__.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/src/mcp_dbutils/postgres/config.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/src/mcp_dbutils/postgres/handler.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/src/mcp_dbutils/postgres/server.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/src/mcp_dbutils/sqlite/__init__.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/src/mcp_dbutils/sqlite/config.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/src/mcp_dbutils/sqlite/handler.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/src/mcp_dbutils/sqlite/server.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/src/mcp_dbutils/stats.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/tests/conftest.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/tests/integration/test_monitoring.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/tests/integration/test_postgres.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/tests/integration/test_postgres_config.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/tests/integration/test_prompts.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/tests/integration/test_sqlite.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/tests/integration/test_sqlite_config.py +0 -0
- {mcp_dbutils-0.6.0 → mcp_dbutils-0.7.0}/tests/unit/test_stats.py +0 -0
@@ -1,6 +1,24 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
3
|
|
4
|
+
## v0.7.0 (2025-03-09)
|
5
|
+
|
6
|
+
### Documentation
|
7
|
+
|
8
|
+
- Update README with list_tables tool information
|
9
|
+
([`f3a2592`](https://github.com/donghao1393/mcp-dbutils/commit/f3a259200bbf18aaebbf6d4511a18d35246f5044))
|
10
|
+
|
11
|
+
### Features
|
12
|
+
|
13
|
+
- Add database type prefix to list_tables tool response
|
14
|
+
([#10](https://github.com/donghao1393/mcp-dbutils/pull/10),
|
15
|
+
[`e32ce1f`](https://github.com/donghao1393/mcp-dbutils/commit/e32ce1f2502f24d111643d7233f0fdd420238bd7))
|
16
|
+
|
17
|
+
添加数据库类型前缀到list_tables工具的返回结果中,使LLM能够知道当前操作的数据库类型, 便于后续操作。格式与错误信息保持一致,使用[数据库类型]前缀。
|
18
|
+
|
19
|
+
Fixes #9
|
20
|
+
|
21
|
+
|
4
22
|
## v0.6.0 (2025-03-08)
|
5
23
|
|
6
24
|
### Documentation
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mcp-dbutils
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.7.0
|
4
4
|
Summary: MCP Database Utilities Service
|
5
5
|
Author: Dong Hao
|
6
6
|
License-Expression: MIT
|
@@ -39,6 +39,7 @@ MCP Database Utilities is a unified database access service that supports multip
|
|
39
39
|
- Support for multiple database configurations
|
40
40
|
- Secure read-only query execution
|
41
41
|
- Table structure and schema information retrieval
|
42
|
+
- Database tables listing via MCP tools
|
42
43
|
- Intelligent connection management and resource cleanup
|
43
44
|
- Debug mode support
|
44
45
|
|
@@ -292,9 +293,24 @@ except Exception as e:
|
|
292
293
|
### DatabaseServer
|
293
294
|
Core server class providing:
|
294
295
|
- Resource list retrieval
|
295
|
-
- Tool call handling
|
296
|
+
- Tool call handling (list_tables, query)
|
296
297
|
- Database handler management
|
297
298
|
|
299
|
+
### MCP Tools
|
300
|
+
|
301
|
+
#### list_tables
|
302
|
+
Lists all tables in the specified database.
|
303
|
+
- Parameters:
|
304
|
+
* database: Database configuration name
|
305
|
+
- Returns: Text content with a list of table names
|
306
|
+
|
307
|
+
#### query
|
308
|
+
Executes a SQL query on the specified database.
|
309
|
+
- Parameters:
|
310
|
+
* database: Database configuration name
|
311
|
+
* sql: SQL query to execute (SELECT only)
|
312
|
+
- Returns: Query results in a formatted text
|
313
|
+
|
298
314
|
### DatabaseHandler
|
299
315
|
Abstract base class defining interfaces:
|
300
316
|
- get_tables(): Get table resource list
|
@@ -17,6 +17,7 @@ MCP Database Utilities is a unified database access service that supports multip
|
|
17
17
|
- Support for multiple database configurations
|
18
18
|
- Secure read-only query execution
|
19
19
|
- Table structure and schema information retrieval
|
20
|
+
- Database tables listing via MCP tools
|
20
21
|
- Intelligent connection management and resource cleanup
|
21
22
|
- Debug mode support
|
22
23
|
|
@@ -270,9 +271,24 @@ except Exception as e:
|
|
270
271
|
### DatabaseServer
|
271
272
|
Core server class providing:
|
272
273
|
- Resource list retrieval
|
273
|
-
- Tool call handling
|
274
|
+
- Tool call handling (list_tables, query)
|
274
275
|
- Database handler management
|
275
276
|
|
277
|
+
### MCP Tools
|
278
|
+
|
279
|
+
#### list_tables
|
280
|
+
Lists all tables in the specified database.
|
281
|
+
- Parameters:
|
282
|
+
* database: Database configuration name
|
283
|
+
- Returns: Text content with a list of table names
|
284
|
+
|
285
|
+
#### query
|
286
|
+
Executes a SQL query on the specified database.
|
287
|
+
- Parameters:
|
288
|
+
* database: Database configuration name
|
289
|
+
* sql: SQL query to execute (SELECT only)
|
290
|
+
- Returns: Query results in a formatted text
|
291
|
+
|
276
292
|
### DatabaseHandler
|
277
293
|
Abstract base class defining interfaces:
|
278
294
|
- get_tables(): Get table resource list
|
@@ -8,6 +8,7 @@ MCP数据库服务是一个统一的数据库访问服务,支持多种数据
|
|
8
8
|
- 支持多个数据库配置
|
9
9
|
- 安全的只读查询执行
|
10
10
|
- 表结构和模式信息查询
|
11
|
+
- 通过MCP工具列出数据库表
|
11
12
|
- 智能的连接管理和资源清理
|
12
13
|
- 支持调试模式
|
13
14
|
|
@@ -254,9 +255,24 @@ except Exception as e:
|
|
254
255
|
### DatabaseServer
|
255
256
|
核心服务器类,提供:
|
256
257
|
- 资源列表获取
|
257
|
-
-
|
258
|
+
- 工具调用处理(list_tables、query)
|
258
259
|
- 数据库处理器管理
|
259
260
|
|
261
|
+
### MCP工具
|
262
|
+
|
263
|
+
#### list_tables
|
264
|
+
列出指定数据库中的所有表。
|
265
|
+
- 参数:
|
266
|
+
* database: 数据库配置名称
|
267
|
+
- 返回:包含表名列表的文本内容
|
268
|
+
|
269
|
+
#### query
|
270
|
+
在指定数据库上执行SQL查询。
|
271
|
+
- 参数:
|
272
|
+
* database: 数据库配置名称
|
273
|
+
* sql: 要执行的SQL查询(仅支持SELECT)
|
274
|
+
- 返回:格式化的查询结果文本
|
275
|
+
|
260
276
|
### DatabaseHandler
|
261
277
|
抽象基类,定义接口:
|
262
278
|
- get_tables(): 获取表资源列表
|
@@ -247,6 +247,10 @@ class DatabaseServer:
|
|
247
247
|
if name == "list_tables":
|
248
248
|
async with self.get_handler(database) as handler:
|
249
249
|
tables = await handler.get_tables()
|
250
|
+
if not tables:
|
251
|
+
# 空表列表的情况也返回数据库类型
|
252
|
+
return [types.TextContent(type="text", text=f"[{handler.db_type}] No tables found")]
|
253
|
+
|
250
254
|
formatted_tables = "\n".join([
|
251
255
|
f"Table: {table.name}\n" +
|
252
256
|
f"URI: {table.uri}\n" +
|
@@ -254,7 +258,8 @@ class DatabaseServer:
|
|
254
258
|
"---"
|
255
259
|
for table in tables
|
256
260
|
])
|
257
|
-
|
261
|
+
# 添加数据库类型前缀
|
262
|
+
return [types.TextContent(type="text", text=f"[{handler.db_type}]\n{formatted_tables}")]
|
258
263
|
elif name == "query":
|
259
264
|
sql = arguments.get("sql", "").strip()
|
260
265
|
if not sql:
|
@@ -50,12 +50,16 @@ async def test_list_tables_tool(postgres_db, sqlite_db, mcp_config):
|
|
50
50
|
result = await client.call_tool("list_tables", {"database": "test_pg"})
|
51
51
|
assert len(result.content) == 1
|
52
52
|
assert result.content[0].type == "text"
|
53
|
+
# 检查数据库类型前缀
|
54
|
+
assert "[postgres]" in result.content[0].text
|
53
55
|
assert "users" in result.content[0].text
|
54
56
|
|
55
57
|
# Test list_tables tool with SQLite
|
56
58
|
result = await client.call_tool("list_tables", {"database": "test_sqlite"})
|
57
59
|
assert len(result.content) == 1
|
58
60
|
assert result.content[0].type == "text"
|
61
|
+
# 检查数据库类型前缀
|
62
|
+
assert "[sqlite]" in result.content[0].text
|
59
63
|
assert "products" in result.content[0].text
|
60
64
|
|
61
65
|
finally:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|