mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-26 00:46:22 +02:00
Key Features - MCP Tool Integration: Added core MCP tool support with ToolClientSpec and ToolClient classes - API Enhancement: New mcp_tool method for flow-specific tool invocation - CLI Tooling: New tg-invoke-mcp-tool command for testing MCP integration - React Agent Enhancement: Fixed and improved multi-tool invocation capabilities - Tool Management: Enhanced CLI for tool configuration and management Changes - Added MCP tool invocation to API with flow-specific integration - Implemented ToolClientSpec and ToolClient for tool call handling - Updated agent-manager-react to invoke MCP tools with configurable types - Enhanced CLI with new commands and improved help text - Added comprehensive documentation for new CLI commands - Improved tool configuration management Testing - Added tg-invoke-mcp-tool CLI command for isolated MCP integration testing - Enhanced agent capability to invoke multiple tools simultaneously
40 lines
1,019 B
Python
40 lines
1,019 B
Python
|
|
import json
|
|
|
|
from . request_response_spec import RequestResponse, RequestResponseSpec
|
|
from .. schema import ToolRequest, ToolResponse
|
|
|
|
class ToolClient(RequestResponse):
|
|
|
|
async def invoke(self, name, parameters={}, timeout=600):
|
|
|
|
if parameters is None:
|
|
parameters = {}
|
|
|
|
resp = await self.request(
|
|
ToolRequest(
|
|
name = name,
|
|
parameters = json.dumps(parameters),
|
|
),
|
|
timeout=timeout
|
|
)
|
|
|
|
if resp.error:
|
|
raise RuntimeError(resp.error.message)
|
|
|
|
if resp.text: return resp.text
|
|
|
|
return json.loads(resp.object)
|
|
|
|
class ToolClientSpec(RequestResponseSpec):
|
|
def __init__(
|
|
self, request_name, response_name,
|
|
):
|
|
super(ToolClientSpec, self).__init__(
|
|
request_name = request_name,
|
|
request_schema = ToolRequest,
|
|
response_name = response_name,
|
|
response_schema = ToolResponse,
|
|
impl = ToolClient,
|
|
)
|
|
|