mirror of
https://github.com/jmagar/unraid-mcp.git
synced 2026-03-23 04:29:17 -07:00
fix(guards): use Pydantic model for elicitation to get labeled checkbox instead of 'Value: []'
This commit is contained in:
@@ -6,6 +6,8 @@ tool action with interactive user confirmation or confirm=True bypass.
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fastmcp import Context
|
||||
@@ -14,6 +16,10 @@ from ..config.logging import logger
|
||||
from .exceptions import ToolError
|
||||
|
||||
|
||||
class _ConfirmAction(BaseModel):
|
||||
confirmed: bool = Field(False, description="Check the box to confirm and proceed")
|
||||
|
||||
|
||||
async def elicit_destructive_confirmation(
|
||||
ctx: "Context | None", action: str, description: str
|
||||
) -> bool:
|
||||
@@ -42,7 +48,7 @@ async def elicit_destructive_confirmation(
|
||||
f"{description}\n\n"
|
||||
"Are you sure you want to proceed?"
|
||||
),
|
||||
response_type=bool,
|
||||
response_type=_ConfirmAction,
|
||||
)
|
||||
except NotImplementedError:
|
||||
logger.warning(
|
||||
@@ -56,7 +62,7 @@ async def elicit_destructive_confirmation(
|
||||
logger.info("Destructive action '%s' declined by user (%s).", action, result.action)
|
||||
return False
|
||||
|
||||
confirmed: bool = result.data # type: ignore[union-attr]
|
||||
confirmed: bool = result.data.confirmed # type: ignore[union-attr]
|
||||
if not confirmed:
|
||||
logger.info("Destructive action '%s' not confirmed by user.", action)
|
||||
return confirmed
|
||||
|
||||
Reference in New Issue
Block a user