mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-06-03 11:55:14 +02:00
Feature/mcp tool arguments (#462)
* Tech spec for MCP arguments * Agent support for MCP tool arguments * Extra tests for MCP arguments * Fix tg-set-tool help and docs
This commit is contained in:
parent
79e16e65f6
commit
865bb47349
6 changed files with 472 additions and 21 deletions
|
|
@ -106,11 +106,21 @@ class Processor(AgentService):
|
|||
impl = TextCompletionImpl
|
||||
arguments = TextCompletionImpl.get_arguments()
|
||||
elif impl_id == "mcp-tool":
|
||||
# For MCP tools, arguments come from config (similar to prompt tools)
|
||||
config_args = data.get("arguments", [])
|
||||
arguments = [
|
||||
Argument(
|
||||
name=arg.get("name"),
|
||||
type=arg.get("type"),
|
||||
description=arg.get("description")
|
||||
)
|
||||
for arg in config_args
|
||||
]
|
||||
impl = functools.partial(
|
||||
McpToolImpl,
|
||||
mcp_tool_id=data.get("mcp-tool")
|
||||
mcp_tool_id=data.get("mcp-tool"),
|
||||
arguments=arguments
|
||||
)
|
||||
arguments = McpToolImpl.get_arguments()
|
||||
elif impl_id == "prompt":
|
||||
# For prompt tools, arguments come from config
|
||||
config_args = data.get("arguments", [])
|
||||
|
|
|
|||
|
|
@ -57,15 +57,14 @@ class TextCompletionImpl:
|
|||
# the mcp-tool service.
|
||||
class McpToolImpl:
|
||||
|
||||
def __init__(self, context, mcp_tool_id):
|
||||
def __init__(self, context, mcp_tool_id, arguments=None):
|
||||
self.context = context
|
||||
self.mcp_tool_id = mcp_tool_id
|
||||
self.arguments = arguments or []
|
||||
|
||||
@staticmethod
|
||||
def get_arguments():
|
||||
# MCP tools define their own arguments dynamically
|
||||
# For now, we return empty list and let the MCP service handle validation
|
||||
return []
|
||||
def get_arguments(self):
|
||||
# Return configured arguments if available, otherwise empty list for backward compatibility
|
||||
return self.arguments
|
||||
|
||||
async def invoke(self, **arguments):
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue