CoolFace
Apppublic

Backup-bdg/OpenHands

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
0likes
mcp.py33 linesDownload Raw Back to action
1from dataclasses import dataclass, field2from typing import Any, ClassVar3 4from openhands.core.schema import ActionType5from openhands.events.action.action import Action, ActionSecurityRisk6 7 8@dataclass9class MCPAction(Action):10    name: str11    arguments: dict[str, Any] = field(default_factory=dict)12    thought: str = ''13    action: str = ActionType.MCP14    runnable: ClassVar[bool] = True15    security_risk: ActionSecurityRisk | None = None16 17    @property18    def message(self) -> str:19        return (20            f'I am interacting with the MCP server with name:\n'21            f'```\n{self.name}\n```\n'22            f'and arguments:\n'23            f'```\n{self.arguments}\n```'24        )25 26    def __str__(self) -> str:27        ret = '**MCPAction**\n'28        if self.thought:29            ret += f'THOUGHT: {self.thought}\n'30        ret += f'NAME: {self.name}\n'31        ret += f'ARGUMENTS: {self.arguments}'32        return ret33