mcp-dbutils 0.6.0__tar.gz → 0.8.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.
Files changed (35) hide show
  1. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/CHANGELOG.md +32 -0
  2. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/PKG-INFO +18 -2
  3. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/README.md +17 -1
  4. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/README_CN.md +17 -1
  5. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/pyproject.toml +1 -1
  6. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/src/mcp_dbutils/base.py +11 -6
  7. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/tests/integration/test_tools.py +8 -4
  8. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/.coveragerc +0 -0
  9. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/.github/workflows/release.yml +0 -0
  10. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/.github/workflows/test.yml +0 -0
  11. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/.gitignore +0 -0
  12. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/Dockerfile +0 -0
  13. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/LICENSE +0 -0
  14. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/config.yaml.example +0 -0
  15. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/smithery.yaml +0 -0
  16. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/src/mcp_dbutils/__init__.py +0 -0
  17. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/src/mcp_dbutils/config.py +0 -0
  18. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/src/mcp_dbutils/log.py +0 -0
  19. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/src/mcp_dbutils/postgres/__init__.py +0 -0
  20. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/src/mcp_dbutils/postgres/config.py +0 -0
  21. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/src/mcp_dbutils/postgres/handler.py +0 -0
  22. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/src/mcp_dbutils/postgres/server.py +0 -0
  23. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/src/mcp_dbutils/sqlite/__init__.py +0 -0
  24. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/src/mcp_dbutils/sqlite/config.py +0 -0
  25. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/src/mcp_dbutils/sqlite/handler.py +0 -0
  26. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/src/mcp_dbutils/sqlite/server.py +0 -0
  27. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/src/mcp_dbutils/stats.py +0 -0
  28. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/tests/conftest.py +0 -0
  29. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/tests/integration/test_monitoring.py +0 -0
  30. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/tests/integration/test_postgres.py +0 -0
  31. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/tests/integration/test_postgres_config.py +0 -0
  32. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/tests/integration/test_prompts.py +0 -0
  33. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/tests/integration/test_sqlite.py +0 -0
  34. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/tests/integration/test_sqlite_config.py +0 -0
  35. {mcp_dbutils-0.6.0 → mcp_dbutils-0.8.0}/tests/unit/test_stats.py +0 -0
@@ -1,6 +1,38 @@
1
1
  # CHANGELOG
2
2
 
3
3
 
4
+ ## v0.8.0 (2025-03-09)
5
+
6
+ ### Features
7
+
8
+ - Unify tool names with dbutils prefix ([#11](https://github.com/donghao1393/mcp-dbutils/pull/11),
9
+ [`30ebbc2`](https://github.com/donghao1393/mcp-dbutils/commit/30ebbc251be55f7d18fc9873021151b82c3f0fde))
10
+
11
+ 给工具名称添加dbutils前缀,使所有工具名称规范统一: - query -> dbutils-run-query - list_tables -> dbutils-list-tables
12
+
13
+ 让工具名称更清晰地表明是属于dbutils的工具,避免与其他MCP服务的工具冲突。
14
+
15
+ Fixes #11
16
+
17
+
18
+ ## v0.7.0 (2025-03-09)
19
+
20
+ ### Documentation
21
+
22
+ - Update README with list_tables tool information
23
+ ([`f3a2592`](https://github.com/donghao1393/mcp-dbutils/commit/f3a259200bbf18aaebbf6d4511a18d35246f5044))
24
+
25
+ ### Features
26
+
27
+ - Add database type prefix to list_tables tool response
28
+ ([#10](https://github.com/donghao1393/mcp-dbutils/pull/10),
29
+ [`e32ce1f`](https://github.com/donghao1393/mcp-dbutils/commit/e32ce1f2502f24d111643d7233f0fdd420238bd7))
30
+
31
+ 添加数据库类型前缀到list_tables工具的返回结果中,使LLM能够知道当前操作的数据库类型, 便于后续操作。格式与错误信息保持一致,使用[数据库类型]前缀。
32
+
33
+ Fixes #9
34
+
35
+
4
36
  ## v0.6.0 (2025-03-08)
5
37
 
6
38
  ### Documentation
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-dbutils
3
- Version: 0.6.0
3
+ Version: 0.8.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(): 获取表资源列表
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mcp-dbutils"
3
- version = "0.6.0"
3
+ version = "0.8.0"
4
4
  description = "MCP Database Utilities Service"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -204,8 +204,8 @@ class DatabaseServer:
204
204
  async def handle_list_tools() -> list[types.Tool]:
205
205
  return [
206
206
  types.Tool(
207
- name="query",
208
- description="Execute read-only SQL query",
207
+ name="dbutils-run-query",
208
+ description="Execute read-only SQL query on database",
209
209
  inputSchema={
210
210
  "type": "object",
211
211
  "properties": {
@@ -222,7 +222,7 @@ class DatabaseServer:
222
222
  }
223
223
  ),
224
224
  types.Tool(
225
- name="list_tables",
225
+ name="dbutils-list-tables",
226
226
  description="List all available tables in the specified database",
227
227
  inputSchema={
228
228
  "type": "object",
@@ -244,9 +244,13 @@ class DatabaseServer:
244
244
 
245
245
  database = arguments["database"]
246
246
 
247
- if name == "list_tables":
247
+ if name == "dbutils-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,8 +258,9 @@ class DatabaseServer:
254
258
  "---"
255
259
  for table in tables
256
260
  ])
257
- return [types.TextContent(type="text", text=formatted_tables)]
258
- elif name == "query":
261
+ # 添加数据库类型前缀
262
+ return [types.TextContent(type="text", text=f"[{handler.db_type}]\n{formatted_tables}")]
263
+ elif name == "dbutils-run-query":
259
264
  sql = arguments.get("sql", "").strip()
260
265
  if not sql:
261
266
  raise ConfigurationError("SQL query cannot be empty")
@@ -43,19 +43,23 @@ async def test_list_tables_tool(postgres_db, sqlite_db, mcp_config):
43
43
  # List available tools
44
44
  response = await client.list_tools()
45
45
  tool_names = [tool.name for tool in response.tools]
46
- assert "list_tables" in tool_names
47
- assert "query" in tool_names
46
+ assert "dbutils-list-tables" in tool_names
47
+ assert "dbutils-run-query" in tool_names
48
48
 
49
49
  # Test list_tables tool with PostgreSQL
50
- result = await client.call_tool("list_tables", {"database": "test_pg"})
50
+ result = await client.call_tool("dbutils-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
- result = await client.call_tool("list_tables", {"database": "test_sqlite"})
58
+ result = await client.call_tool("dbutils-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