Merge branch 'feature/mcp-ui' into bot_manager
This commit is contained in:
commit
df87238433
@ -29,7 +29,7 @@
|
||||
},
|
||||
{
|
||||
"name": "ask_user",
|
||||
"description": "Ask the user a question and present options for them to choose from. Use this tool when you need user input to proceed, such as clarifying requirements, choosing between alternatives, or confirming an action. The question will be displayed at the end of your response with clickable option buttons.",
|
||||
"description": "MANDATORY: You MUST call this tool whenever you need the user to make a choice or provide input. Do NOT present options as plain text in your response — always use this tool to render interactive option buttons. This step is required and cannot be skipped or replaced by listing options in text. Use this tool when: (1) the user asks to choose between multiple alternatives, (2) you need to clarify ambiguous requirements before proceeding, (3) you need confirmation before taking an action, (4) there are multiple valid approaches and the user must decide. The question will be displayed at the end of your response with clickable option buttons. If options is empty, a free text input will be shown instead.",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -43,6 +43,11 @@
|
||||
"type": "string"
|
||||
},
|
||||
"description": "List of options for the user to choose from. If empty, a free text input will be shown instead."
|
||||
},
|
||||
"multi_select": {
|
||||
"type": "boolean",
|
||||
"description": "If true, the user can select multiple options. If false (default), only one option can be selected.",
|
||||
"default": false
|
||||
}
|
||||
},
|
||||
"required": ["question"]
|
||||
|
||||
@ -24,7 +24,9 @@ from mcp_common import (
|
||||
ASK_USER_MARKER = "__ask_user__"
|
||||
|
||||
|
||||
def ask_user(question: str, options: list = None) -> Dict[str, Any]:
|
||||
def ask_user(
|
||||
question: str, options: list = None, multi_select: bool = False
|
||||
) -> Dict[str, Any]:
|
||||
"""Create an ask_user response.
|
||||
|
||||
Returns a JSON structure with a marker so the backend can detect it
|
||||
@ -34,6 +36,7 @@ def ask_user(question: str, options: list = None) -> Dict[str, Any]:
|
||||
"__type__": ASK_USER_MARKER,
|
||||
"question": question,
|
||||
"options": options or [],
|
||||
"multi_select": multi_select,
|
||||
}
|
||||
return {
|
||||
"content": [
|
||||
@ -139,13 +142,14 @@ async def handle_request(request: Dict[str, Any]) -> Dict[str, Any]:
|
||||
elif tool_name == "ask_user":
|
||||
question = arguments.get("question", "")
|
||||
options = arguments.get("options", [])
|
||||
multi_select = arguments.get("multi_select", False)
|
||||
|
||||
if not question:
|
||||
return create_error_response(
|
||||
request_id, -32602, "Missing required parameter: question"
|
||||
)
|
||||
|
||||
result = ask_user(question, options)
|
||||
result = ask_user(question, options, multi_select)
|
||||
return {"jsonrpc": "2.0", "id": request_id, "result": result}
|
||||
|
||||
else:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user