"""Models of MCPClients: connections to Model Context Protocol servers, whose tools an LLMClient's LLM can call."""fromdatetimeimportdatetimefromtypingimportOptionalfrompydanticimportFieldfromsmarter.core.typingimportSmarterJsonObjectTypefrom.baseimportSmarterCamelModel,SmarterResource
[docs]classMCPClient(SmarterResource):"""An MCPClient: an MCP server, how to reach it, and which of its tools the LLM may call."""transport:Optional[str]=Field(None,description="http, sse or stdio.")endpoint_url:Optional[str]=Nonecommand:Optional[str]=Nonetimeout:Optional[int]=Noneauth_type:Optional[str]=Noneallowed_tools:list[str]=[]allowed_resources:list[str]=[]include_instructions:Optional[bool]=Nonecache_ttl:Optional[int]=Noneis_active:Optional[bool]=Nonestatus:Optional[str]=Field(None,description="e.g. connected or error.")priority:Optional[int]=Noneprotocol_version:Optional[str]=Noneserver_name:Optional[str]=Noneserver_version:Optional[str]=Nonetools:list[str]=Field(default_factory=list,description="The names of every tool that the server offers.")last_connected_at:Optional[datetime]=Nonelast_error:Optional[str]=None
[docs]classMCPClientStatus(SmarterCamelModel):"""The connection state of an MCPClient."""name:strstatus:Optional[str]=Noneprotocol_version:Optional[str]=Noneserver_name:Optional[str]=Noneserver_version:Optional[str]=Nonelast_connected:Optional[datetime]=Nonelast_error:Optional[str]=Noneerror:Optional[str]=Field(None,description="The error of a failed refresh.")
[docs]classMCPTool(SmarterCamelModel):"""A tool of an MCP server, which the MCPClient allows the LLM to call."""name:strtitle:Optional[str]=Nonedescription:Optional[str]=Noneinput_schema:Optional[SmarterJsonObjectType]=Field(None,description="The tool's arguments, as a JSON Schema.")read_only:Optional[bool]=Nonedestructive:Optional[bool]=None
[docs]classMCPClientTools(MCPClientStatus):"""An MCPClient's allowed tools, and the server's instructions."""instructions:Optional[str]=Nonetools:list[MCPTool]=[]
[docs]classMCPToolResult(SmarterCamelModel):"""The result of a tool call."""name:str=Field(...,description="The MCPClient's name.")tool:stris_error:bool=Falsecontent:Optional[str]=Field(None,description="The tool's result, as text.")