Updated CLI invocation and config model for tools and mcp (#438)

* Updated CLI invocation and config model for tools and mcp

* CLI anomalies

* Tweaked the MCP tool implementation for new model

* Update agent implementation to match the new model

* Fix agent tools, now all tested

* Fixed integration tests

* Fix MCP delete tool params
This commit is contained in:
cybermaggedon 2025-07-16 23:09:32 +01:00 committed by GitHub
parent a96d02da5d
commit 81c7c1181b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 270 additions and 183 deletions

54
trustgraph-cli/scripts/tg-set-mcp-tool Normal file → Executable file
View file

@ -1,10 +1,17 @@
#!/usr/bin/env python3
"""
Configures and registers MCP (Model Control Protocol) tools in the
TrustGraph system. Allows defining MCP tool configurations with name and
URL. Tools are stored in the 'mcp' configuration group for discovery and
execution.
Configures and registers MCP (Model Context Protocol) tools in the
TrustGraph system.
MCP tools are external services that follow the Model Context Protocol
specification. This script stores MCP tool configurations with:
- id: Unique identifier for the tool
- remote-name: Name used by the MCP server (defaults to id)
- url: MCP server endpoint URL
Configurations are stored in the 'mcp' configuration group and can be
referenced by agent tools using the 'mcp-tool' type.
"""
import argparse
@ -17,7 +24,8 @@ default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
def set_mcp_tool(
url : str,
name : str,
id : str,
remote_name : str,
tool_url : str,
):
@ -26,15 +34,13 @@ def set_mcp_tool(
# Store the MCP tool configuration in the 'mcp' group
values = api.put([
ConfigValue(
type="mcp", key=name, value=json.dumps({
"name": name,
type="mcp", key=id, value=json.dumps({
"remote-name": remote_name,
"url": tool_url,
})
)
])
print(f"MCP tool '{name}' set with URL: {tool_url}")
def main():
parser = argparse.ArgumentParser(
@ -45,8 +51,8 @@ def main():
to the MCP server endpoint that provides the tool functionality.
Examples:
%(prog)s --name weather --tool-url "http://localhost:3000/weather"
%(prog)s --name calculator --tool-url "http://mcp-tools.example.com/calc"
%(prog)s --id weather --tool-url "http://localhost:3000/weather"
%(prog)s --id calculator --tool-url "http://mcp-tools.example.com/calc"
''').strip(),
formatter_class=argparse.RawDescriptionHelpFormatter
)
@ -58,9 +64,15 @@ def main():
)
parser.add_argument(
'--name',
'-i', '--id',
required=True,
help='MCP tool name',
help='MCP tool identifier',
)
parser.add_argument(
'-r', '--remote-name',
required=False,
help='Remote MCP tool name (defaults to --id if not specified)',
)
parser.add_argument(
@ -73,15 +85,21 @@ def main():
try:
if not args.name:
raise RuntimeError("Must specify --name for MCP tool")
if not args.id:
raise RuntimeError("Must specify --id for MCP tool")
if not args.tool_url:
raise RuntimeError("Must specify --url for MCP tool")
raise RuntimeError("Must specify --tool-url for MCP tool")
if args.remote_name:
remote_name = args.remote_name
else:
remote_name = args.id
set_mcp_tool(
url=args.api_url,
name=args.name,
url=args.api_url,
id=args.id,
remote_name=remote_name,
tool_url=args.tool_url
)