Refactor and enhance MCP client and server functionality
- Removed prueba_cliente_mcp.py as it was no longer needed. - Updated prueba_loop_agente.py to integrate MCPServerRunner for managing server instances. - Modified prueba_mcp.py to implement a new structure for starting and stopping MCP servers. - Enhanced AgenteAI class to support multiple MCP blocks execution. - Improved MCPClient with timeout handling for tool calls. - Added new sandbox files for children's stories. - Created a simple ERP system with a main entry point. - Added unit tests for the ERP system. - Implemented MCPServerRunner to manage server processes. - Developed server_files.py to handle file operations securely within a sandbox environment. - Introduced ElementoWeb and Navegador classes for web scraping functionalities. - Enhanced Scrapper and Tab classes for better interaction with web pages.
This commit is contained in:
@@ -9,6 +9,7 @@ from fastmcp.client.transports import (
|
||||
)
|
||||
from mcp.types import *
|
||||
from fastmcp.exceptions import ClientError
|
||||
import asyncio
|
||||
|
||||
|
||||
class MCPClient:
|
||||
@@ -52,10 +53,13 @@ class MCPClient:
|
||||
|
||||
# Delegación MCP
|
||||
|
||||
async def call_tool(
|
||||
self, name: str, arguments: dict[str, Any] | None = None
|
||||
) -> list[TextContent | ImageContent | EmbeddedResource]:
|
||||
return await self.client.call_tool(name, arguments)
|
||||
async def call_tool(self, name: str, arguments: dict[str, Any] | None = None) -> list[TextContent | ImageContent | EmbeddedResource]:
|
||||
try:
|
||||
return await asyncio.wait_for(
|
||||
self.client.call_tool(name, arguments), timeout=10
|
||||
)
|
||||
except asyncio.TimeoutError:
|
||||
raise RuntimeError(f"Timeout al ejecutar herramienta '{name}'")
|
||||
|
||||
async def get_prompt(
|
||||
self, name: str, arguments: dict[str, str] | None = None
|
||||
|
||||
Reference in New Issue
Block a user