mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 00:16:23 +02:00
Feature/react call mcp (#428)
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
This commit is contained in:
parent
e56186054a
commit
9c7a070681
22 changed files with 2718 additions and 9 deletions
137
docs/apis/api-mcp-tool.md
Normal file
137
docs/apis/api-mcp-tool.md
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
# TrustGraph MCP Tool API
|
||||
|
||||
This is a higher-level interface to the MCP (Model Control Protocol) tool service. The input
|
||||
specifies an MCP tool by name and parameters to pass to the tool.
|
||||
|
||||
## Request/response
|
||||
|
||||
### Request
|
||||
|
||||
The request contains the following fields:
|
||||
- `name`: The MCP tool name
|
||||
- `parameters`: A set of key/values describing the tool parameters
|
||||
|
||||
### Response
|
||||
|
||||
The response contains either of these fields:
|
||||
- `text`: A plain text response
|
||||
- `object`: A structured object response
|
||||
|
||||
## REST service
|
||||
|
||||
The REST service accepts `name` and `parameters` fields, with parameters
|
||||
encoded as a JSON object.
|
||||
|
||||
e.g.
|
||||
|
||||
In this example, the MCP tool takes parameters and returns a
|
||||
structured response in the `object` field.
|
||||
|
||||
Request:
|
||||
```
|
||||
{
|
||||
"name": "file-reader",
|
||||
"parameters": {
|
||||
"path": "/path/to/file.txt"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Response:
|
||||
|
||||
```
|
||||
{
|
||||
"object": {"content": "file contents here", "size": 1024}
|
||||
}
|
||||
```
|
||||
|
||||
## Websocket
|
||||
|
||||
Requests have `name` and `parameters` fields.
|
||||
|
||||
e.g.
|
||||
|
||||
Request:
|
||||
|
||||
```
|
||||
{
|
||||
"id": "akshfkiehfkseffh-142",
|
||||
"service": "mcp-tool",
|
||||
"flow": "default",
|
||||
"request": {
|
||||
"name": "file-reader",
|
||||
"parameters": {
|
||||
"path": "/path/to/file.txt"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Responses:
|
||||
|
||||
```
|
||||
{
|
||||
"id": "akshfkiehfkseffh-142",
|
||||
"response": {
|
||||
"object": {"content": "file contents here", "size": 1024}
|
||||
},
|
||||
"complete": true
|
||||
}
|
||||
```
|
||||
|
||||
e.g.
|
||||
|
||||
An example which returns plain text
|
||||
|
||||
Request:
|
||||
|
||||
```
|
||||
{
|
||||
"id": "akshfkiehfkseffh-141",
|
||||
"service": "mcp-tool",
|
||||
"request": {
|
||||
"name": "calculator",
|
||||
"parameters": {
|
||||
"expression": "2 + 2"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Response:
|
||||
|
||||
```
|
||||
{
|
||||
"id": "akshfkiehfkseffh-141",
|
||||
"response": {
|
||||
"text": "4"
|
||||
},
|
||||
"complete": true
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Pulsar
|
||||
|
||||
The Pulsar schema for the MCP Tool API is defined in Python code here:
|
||||
|
||||
https://github.com/trustgraph-ai/trustgraph/blob/master/trustgraph-base/trustgraph/schema/mcp_tool.py
|
||||
|
||||
Default request queue:
|
||||
`non-persistent://tg/request/mcp-tool`
|
||||
|
||||
Default response queue:
|
||||
`non-persistent://tg/response/mcp-tool`
|
||||
|
||||
Request schema:
|
||||
`trustgraph.schema.McpToolRequest`
|
||||
|
||||
Response schema:
|
||||
`trustgraph.schema.McpToolResponse`
|
||||
|
||||
## Pulsar Python client
|
||||
|
||||
The client class is
|
||||
`trustgraph.clients.McpToolClient`
|
||||
|
||||
https://github.com/trustgraph-ai/trustgraph/blob/master/trustgraph-base/trustgraph/clients/mcp_tool_client.py
|
||||
Loading…
Add table
Add a link
Reference in a new issue