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:
cybermaggedon 2025-08-21 14:46:10 +01:00 committed by GitHub
parent 79e16e65f6
commit 865bb47349
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 472 additions and 21 deletions

View file

@ -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", [])

View file

@ -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):