Feat : MCP agent

This commit is contained in:
martin legrand
2025-05-04 18:34:05 +02:00
parent 887060acdf
commit 442bb4a340
18 changed files with 261 additions and 22 deletions
+8
View File
@@ -90,6 +90,12 @@ class Agent():
raise TypeError("Tool must be a callable object (a method)")
self.tools[name] = tool
def get_tools_name(self) -> list:
"""
Get the list of tools names.
"""
return list(self.tools.keys())
def load_prompt(self, file_path: str) -> str:
try:
with open(file_path, 'r', encoding="utf-8") as f:
@@ -235,11 +241,13 @@ class Agent():
answer = "I will execute:\n" + answer # there should always be a text before blocks for the function that display answer
self.success = True
self.blocks_result = []
for name, tool in self.tools.items():
feedback = ""
blocks, save_path = tool.load_exec_block(answer)
if blocks != None:
pretty_print(f"Executing {len(blocks)} {name} blocks...", color="status")
for block in blocks:
self.show_block(block)
output = tool.execute([block])