Skip to content

Commit c29b27b

Browse files
author
tianzhen.wtz
committed
Merge branch feat/env_database into master
Title: to #65849001 message format to #65849001 message format Link: https://code.alibaba-inc.com/idb/alibabacloud-dms-mcp-server/codereview/21876006
2 parents aecc455 + c14a50d commit c29b27b

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ jobs:
5555
name: >-
5656
Sign the Python 🐍 distribution 📦 with Sigstore
5757
and upload them to GitHub Release
58+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
5859
needs:
5960
- publish-to-pypi
6061
runs-on: ubuntu-latest

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "alibabacloud-dms-mcp-server"
3-
version = "0.1.6"
3+
version = "0.1.7"
44
description = "MCP Server for AlibabaCloud DMS"
55
readme = "README.md"
66
authors = [

src/alibabacloud_dms_mcp_server/server.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ class ResultSet(MyBaseModel):
103103
Rows: List[Dict[str, Any]] = Field(description="List of rows, where each row is a dictionary of column_name: value")
104104
MarkdownTable: Optional[str] = Field(default=None, description="Data formatted as a Markdown table string")
105105
Success: bool = Field(description="Whether this result set was successfully retrieved")
106+
Message: str = Field(description="Additional message returned")
107+
106108

107109
class ExecuteScriptResult(MyBaseModel):
108110
RequestId: str = Field(description="Unique request identifier")
@@ -115,7 +117,7 @@ def __str__(self) -> str:
115117
if first_result.Success and first_result.MarkdownTable:
116118
return first_result.MarkdownTable
117119
elif not first_result.Success:
118-
return "The first result set was not successful."
120+
return first_result.Message
119121
else:
120122
return "Result data is not available in Markdown format."
121123
elif not self.Success:
@@ -266,7 +268,7 @@ async def get_meta_table_detail_info(
266268
raise
267269

268270
def _format_as_markdown_table(column_names: List[str], rows: List[Dict[str, Any]]) -> str:
269-
if not column_names or not rows: return ""
271+
if not column_names: return ""
270272
header = "| " + " | ".join(column_names) + " |"
271273
separator = "| " + " | ".join(["---"] * len(column_names)) + " |"
272274
table_rows_str = [header, separator]
@@ -296,15 +298,16 @@ async def execute_script(
296298
markdown_table = _format_as_markdown_table(column_names, rows_data)
297299
processed_results.append(
298300
ResultSet(ColumnNames=column_names, RowCount=res_item.get('RowCount', 0), Rows=rows_data,
299-
MarkdownTable=markdown_table, Success=True))
301+
MarkdownTable=markdown_table, Success=True, Message=''))
300302
else:
301303
processed_results.append(
302-
ResultSet(ColumnNames=[], RowCount=0, Rows=[], MarkdownTable=None, Success=False))
304+
ResultSet(ColumnNames=[], RowCount=0, Rows=[], MarkdownTable=None, Success=False, Message=res_item.get('Message')))
303305
return ExecuteScriptResult(RequestId=data.get('RequestId', ""), Results=processed_results,
304306
Success=data.get('Success', False))
305307
except Exception as e:
306308
logger.error(f"Error in execute_script: {e}")
307-
raise
309+
if "The instance is not in secure hosting mode" in str(e):
310+
return "当前实例尚未开启安全托管功能。您可以通过DMS控制台免费开启「安全托管模式」。请注意,该操作需要管理员或DBA身份权限。"
308311

309312
async def nl2sql(
310313
database_id: str = Field(description="DMS databaseId"),

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)