Skip to content

Commit 58d3da1

Browse files
authored
Merge pull request #21 from yanbeipang/feat/tool_paramater
Add model information to the tool parameters
2 parents 7d0493e + d2e23a4 commit 58d3da1

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

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.13"
3+
version = "0.1.14"
44
description = "MCP Server for AlibabaCloud DMS"
55
readme = "README.md"
66
authors = [

src/alibabacloud_dms_mcp_server/server.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ async def create_data_change_order(
365365
script: str = Field(description="SQL script to execute"),
366366
logic: bool = Field(default=False, description="Whether to use logical execution mode")
367367
) -> Dict[str, Any]:
368-
369368
client = create_client()
370369
req = dms_enterprise_20181101_models.CreateDataCorrectOrderRequest()
371370
req.comment = "Data correct order submitted by MCP"
@@ -395,7 +394,6 @@ async def create_data_change_order(
395394
async def get_order_base_info(
396395
order_id: str = Field(description="DMS order ID")
397396
) -> Dict[str, Any]:
398-
399397
client = create_client()
400398
req = dms_enterprise_20181101_models.GetOrderBaseInfoRequest()
401399
req.order_id = order_id
@@ -410,7 +408,6 @@ async def get_order_base_info(
410408
async def submit_order_approval(
411409
order_id: str = Field(description="DMS order ID")
412410
) -> Dict[str, Any]:
413-
414411
client = create_client()
415412
req = dms_enterprise_20181101_models.SubmitOrderApprovalRequest()
416413
req.order_id = order_id
@@ -421,16 +418,21 @@ async def submit_order_approval(
421418
logger.error(f"Error in submit_order_approval: {e}")
422419
raise
423420

421+
424422
async def nl2sql(
425423
database_id: str = Field(description="DMS databaseId"),
426424
question: str = Field(description="Natural language question"),
427-
knowledge: Optional[str] = Field(default=None, description="Additional context")
425+
knowledge: Optional[str] = Field(default=None, description="Optional: additional context"),
426+
model: Optional[str] = Field(default=None, description="Optional: if a specific model is desired, it can be specified here")
428427
) -> SqlResult:
429428
client = create_client()
430429
req = dms_enterprise_20181101_models.GenerateSqlFromNLRequest(db_id=database_id, question=question)
431-
if knowledge: req.knowledge = knowledge
430+
if knowledge:
431+
req.knowledge = knowledge
432432
if mcp.state.real_login_uid:
433433
req.real_login_user_uid = mcp.state.real_login_uid
434+
if model:
435+
req.model = model
434436
try:
435437
resp = client.generate_sql_from_nl(req)
436438
if not resp or not resp.body: return SqlResult(sql=None)
@@ -495,13 +497,15 @@ async def execute_script_configured(
495497
async def create_data_change_order_configured(
496498
script: str = Field(description="SQL script to execute")
497499
) -> str:
498-
result_obj = await create_data_change_order(database_id=self.default_database_id, script=script, logic=False)
500+
result_obj = await create_data_change_order(database_id=self.default_database_id, script=script,
501+
logic=False)
499502
return str(result_obj)
500503

501504
self.mcp.tool(name="getOrderInfo", description="Retrieve order information from DMS using the order ID.",
502505
annotations={"title": "获取DMS工单详情", "readOnlyHint": True})(get_order_base_info)
503506

504-
self.mcp.tool(name="submitOrderApproval", description="Submit the order for approval in DMS using the order ID.",
507+
self.mcp.tool(name="submitOrderApproval",
508+
description="Submit the order for approval in DMS using the order ID.",
505509
annotations={"title": "提交工单审批", "readOnlyHint": False})(submit_order_approval)
506510

507511
@self.mcp.tool(name="askDatabase",
@@ -511,10 +515,11 @@ async def ask_database_configured(
511515
question: str = Field(
512516
description="Your question in natural language about the pre-configured database."),
513517
knowledge: Optional[str] = Field(default=None,
514-
description="Optional: Additional context to help formulate the SQL query.")
518+
description="Optional: additional context to help formulate the SQL query."),
519+
model: Optional[str] = Field(default=None, description="Optional: if a specific model is desired, it can be specified here")
515520
) -> AskDatabaseResult:
516521
sql_result_obj = await nl2sql(database_id=self.default_database_id, question=question,
517-
knowledge=knowledge)
522+
knowledge=knowledge, model=model)
518523
generated_sql = ""
519524
if not sql_result_obj or not sql_result_obj.sql:
520525
logger.warning(f"Failed to generate SQL for question: {question} on preconfigured DB.")
@@ -600,7 +605,8 @@ async def create_data_change_order_wrapper(
600605
self.mcp.tool(name="getOrderInfo", description="Retrieve order information from DMS using the order ID.",
601606
annotations={"title": "获取DMS工单详情", "readOnlyHint": True})(get_order_base_info)
602607

603-
self.mcp.tool(name="submitOrderApproval", description="Submit the order for approval in DMS using the order ID.",
608+
self.mcp.tool(name="submitOrderApproval",
609+
description="Submit the order for approval in DMS using the order ID.",
604610
annotations={"title": "提交工单审批", "readOnlyHint": False})(submit_order_approval)
605611

606612
self.mcp.tool(name="generateSql", description="Generate SELECT-type SQL queries from natural language input.",

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)