mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-04-25 08:26:21 +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
94 lines
2.2 KiB
Python
94 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
|
|
"""
|
|
Deletes MCP (Model Control Protocol) tools from the TrustGraph system.
|
|
Removes MCP tool configurations by name from the 'mcp' configuration group.
|
|
"""
|
|
|
|
import argparse
|
|
import os
|
|
from trustgraph.api import Api, ConfigKey
|
|
import textwrap
|
|
|
|
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
|
|
|
def delete_mcp_tool(
|
|
url : str,
|
|
name : str,
|
|
):
|
|
|
|
api = Api(url).config()
|
|
|
|
# Check if the tool exists first
|
|
try:
|
|
values = api.get([
|
|
ConfigKey(type="mcp", key=name)
|
|
])
|
|
|
|
if not values or not values[0].value:
|
|
print(f"MCP tool '{name}' not found.")
|
|
return False
|
|
|
|
except Exception as e:
|
|
print(f"MCP tool '{name}' not found.")
|
|
return False
|
|
|
|
# Delete the MCP tool configuration from the 'mcp' group
|
|
try:
|
|
api.delete([
|
|
ConfigKey(type="mcp", key=name)
|
|
])
|
|
|
|
print(f"MCP tool '{name}' deleted successfully.")
|
|
return True
|
|
|
|
except Exception as e:
|
|
print(f"Error deleting MCP tool '{name}': {e}")
|
|
return False
|
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser(
|
|
prog='tg-delete-mcp-tool',
|
|
description=__doc__,
|
|
epilog=textwrap.dedent('''
|
|
This utility removes MCP tool configurations from the TrustGraph system.
|
|
Once deleted, the tool will no longer be available for use.
|
|
|
|
Examples:
|
|
%(prog)s --name weather
|
|
%(prog)s --name calculator
|
|
%(prog)s --api-url http://localhost:9000/ --name file-reader
|
|
''').strip(),
|
|
formatter_class=argparse.RawDescriptionHelpFormatter
|
|
)
|
|
|
|
parser.add_argument(
|
|
'-u', '--api-url',
|
|
default=default_url,
|
|
help=f'API URL (default: {default_url})',
|
|
)
|
|
|
|
parser.add_argument(
|
|
'--name',
|
|
required=True,
|
|
help='MCP tool name to delete',
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
try:
|
|
|
|
if not args.name:
|
|
raise RuntimeError("Must specify --name for MCP tool to delete")
|
|
|
|
delete_mcp_tool(
|
|
url=args.api_url,
|
|
name=args.name
|
|
)
|
|
|
|
except Exception as e:
|
|
|
|
print("Exception:", e, flush=True)
|
|
|
|
main()
|