trustgraph-cli 1.1.5__tar.gz → 1.1.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of trustgraph-cli might be problematic. Click here for more details.
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/PKG-INFO +2 -2
- trustgraph-cli-1.1.7/scripts/tg-delete-mcp-tool +94 -0
- trustgraph-cli-1.1.7/scripts/tg-delete-tool +127 -0
- trustgraph-cli-1.1.7/scripts/tg-invoke-mcp-tool +80 -0
- trustgraph-cli-1.1.7/scripts/tg-set-mcp-tool +93 -0
- trustgraph-cli-1.1.7/scripts/tg-set-tool +195 -0
- trustgraph-cli-1.1.7/scripts/tg-show-mcp-tools +70 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-show-tools +1 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/setup.py +6 -0
- trustgraph-cli-1.1.7/trustgraph/cli_version.py +1 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/trustgraph_cli.egg-info/PKG-INFO +2 -2
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/trustgraph_cli.egg-info/SOURCES.txt +6 -0
- trustgraph-cli-1.1.5/trustgraph/cli_version.py +0 -1
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/README.md +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-add-library-document +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-delete-flow-class +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-delete-kg-core +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-dump-msgpack +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-get-flow-class +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-get-kg-core +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-graph-to-turtle +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-init-trustgraph +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-invoke-agent +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-invoke-document-rag +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-invoke-graph-rag +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-invoke-llm +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-invoke-prompt +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-load-doc-embeds +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-load-kg-core +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-load-pdf +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-load-sample-documents +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-load-text +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-load-turtle +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-put-flow-class +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-put-kg-core +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-remove-library-document +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-save-doc-embeds +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-set-prompt +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-set-token-costs +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-show-config +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-show-flow-classes +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-show-flow-state +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-show-flows +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-show-graph +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-show-kg-cores +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-show-library-documents +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-show-library-processing +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-show-processor-state +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-show-prompts +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-show-token-costs +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-show-token-rate +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-start-flow +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-start-library-processing +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-stop-flow +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-stop-library-processing +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/scripts/tg-unload-kg-core +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/setup.cfg +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/trustgraph_cli.egg-info/dependency_links.txt +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/trustgraph_cli.egg-info/requires.txt +0 -0
- {trustgraph-cli-1.1.5 → trustgraph-cli-1.1.7}/trustgraph_cli.egg-info/top_level.txt +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: trustgraph-cli
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.7
|
|
4
4
|
Summary: TrustGraph provides a means to run a pipeline of flexible AI processing components in a flexible means to achieve a processing pipeline.
|
|
5
5
|
Home-page: https://github.com/trustgraph-ai/trustgraph
|
|
6
|
-
Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v1.1.
|
|
6
|
+
Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v1.1.7.tar.gz
|
|
7
7
|
Author: trustgraph.ai
|
|
8
8
|
Author-email: security@trustgraph.ai
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Deletes MCP (Model Control Protocol) tools from the TrustGraph system.
|
|
5
|
+
Removes MCP tool configurations by name from the 'mcp' configuration group.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import argparse
|
|
9
|
+
import os
|
|
10
|
+
from trustgraph.api import Api, ConfigKey
|
|
11
|
+
import textwrap
|
|
12
|
+
|
|
13
|
+
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
|
14
|
+
|
|
15
|
+
def delete_mcp_tool(
|
|
16
|
+
url : str,
|
|
17
|
+
name : str,
|
|
18
|
+
):
|
|
19
|
+
|
|
20
|
+
api = Api(url).config()
|
|
21
|
+
|
|
22
|
+
# Check if the tool exists first
|
|
23
|
+
try:
|
|
24
|
+
values = api.get([
|
|
25
|
+
ConfigKey(type="mcp", key=name)
|
|
26
|
+
])
|
|
27
|
+
|
|
28
|
+
if not values or not values[0].value:
|
|
29
|
+
print(f"MCP tool '{name}' not found.")
|
|
30
|
+
return False
|
|
31
|
+
|
|
32
|
+
except Exception as e:
|
|
33
|
+
print(f"MCP tool '{name}' not found.")
|
|
34
|
+
return False
|
|
35
|
+
|
|
36
|
+
# Delete the MCP tool configuration from the 'mcp' group
|
|
37
|
+
try:
|
|
38
|
+
api.delete([
|
|
39
|
+
ConfigKey(type="mcp", key=name)
|
|
40
|
+
])
|
|
41
|
+
|
|
42
|
+
print(f"MCP tool '{name}' deleted successfully.")
|
|
43
|
+
return True
|
|
44
|
+
|
|
45
|
+
except Exception as e:
|
|
46
|
+
print(f"Error deleting MCP tool '{name}': {e}")
|
|
47
|
+
return False
|
|
48
|
+
|
|
49
|
+
def main():
|
|
50
|
+
|
|
51
|
+
parser = argparse.ArgumentParser(
|
|
52
|
+
prog='tg-delete-mcp-tool',
|
|
53
|
+
description=__doc__,
|
|
54
|
+
epilog=textwrap.dedent('''
|
|
55
|
+
This utility removes MCP tool configurations from the TrustGraph system.
|
|
56
|
+
Once deleted, the tool will no longer be available for use.
|
|
57
|
+
|
|
58
|
+
Examples:
|
|
59
|
+
%(prog)s --name weather
|
|
60
|
+
%(prog)s --name calculator
|
|
61
|
+
%(prog)s --api-url http://localhost:9000/ --name file-reader
|
|
62
|
+
''').strip(),
|
|
63
|
+
formatter_class=argparse.RawDescriptionHelpFormatter
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
parser.add_argument(
|
|
67
|
+
'-u', '--api-url',
|
|
68
|
+
default=default_url,
|
|
69
|
+
help=f'API URL (default: {default_url})',
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
parser.add_argument(
|
|
73
|
+
'--name',
|
|
74
|
+
required=True,
|
|
75
|
+
help='MCP tool name to delete',
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
args = parser.parse_args()
|
|
79
|
+
|
|
80
|
+
try:
|
|
81
|
+
|
|
82
|
+
if not args.name:
|
|
83
|
+
raise RuntimeError("Must specify --name for MCP tool to delete")
|
|
84
|
+
|
|
85
|
+
delete_mcp_tool(
|
|
86
|
+
url=args.api_url,
|
|
87
|
+
name=args.name
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
except Exception as e:
|
|
91
|
+
|
|
92
|
+
print("Exception:", e, flush=True)
|
|
93
|
+
|
|
94
|
+
main()
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Deletes tools from the TrustGraph system.
|
|
5
|
+
Removes tool configurations by ID from the agent configuration
|
|
6
|
+
and updates the tool index accordingly.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import argparse
|
|
10
|
+
import os
|
|
11
|
+
from trustgraph.api import Api, ConfigKey, ConfigValue
|
|
12
|
+
import json
|
|
13
|
+
import textwrap
|
|
14
|
+
|
|
15
|
+
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
|
16
|
+
|
|
17
|
+
def delete_tool(
|
|
18
|
+
url : str,
|
|
19
|
+
id : str,
|
|
20
|
+
):
|
|
21
|
+
|
|
22
|
+
api = Api(url).config()
|
|
23
|
+
|
|
24
|
+
# Get the current tool index
|
|
25
|
+
try:
|
|
26
|
+
values = api.get([
|
|
27
|
+
ConfigKey(type="agent", key="tool-index")
|
|
28
|
+
])
|
|
29
|
+
|
|
30
|
+
ix = json.loads(values[0].value)
|
|
31
|
+
|
|
32
|
+
except Exception as e:
|
|
33
|
+
print(f"Error reading tool index: {e}")
|
|
34
|
+
return False
|
|
35
|
+
|
|
36
|
+
# Check if the tool exists in the index
|
|
37
|
+
if id not in ix:
|
|
38
|
+
print(f"Tool '{id}' not found in tool index.")
|
|
39
|
+
return False
|
|
40
|
+
|
|
41
|
+
# Check if the tool configuration exists
|
|
42
|
+
try:
|
|
43
|
+
tool_values = api.get([
|
|
44
|
+
ConfigKey(type="agent", key=f"tool.{id}")
|
|
45
|
+
])
|
|
46
|
+
|
|
47
|
+
if not tool_values or not tool_values[0].value:
|
|
48
|
+
print(f"Tool configuration for '{id}' not found.")
|
|
49
|
+
return False
|
|
50
|
+
|
|
51
|
+
except Exception as e:
|
|
52
|
+
print(f"Tool configuration for '{id}' not found.")
|
|
53
|
+
return False
|
|
54
|
+
|
|
55
|
+
# Remove the tool ID from the index
|
|
56
|
+
ix.remove(id)
|
|
57
|
+
|
|
58
|
+
# Delete the tool configuration and update the index
|
|
59
|
+
try:
|
|
60
|
+
|
|
61
|
+
# Update the tool index
|
|
62
|
+
api.put([
|
|
63
|
+
ConfigValue(
|
|
64
|
+
type="agent", key="tool-index", value=json.dumps(ix)
|
|
65
|
+
)
|
|
66
|
+
])
|
|
67
|
+
|
|
68
|
+
# Delete the tool configuration
|
|
69
|
+
api.delete([
|
|
70
|
+
ConfigKey(type="agent", key=f"tool.{id}")
|
|
71
|
+
])
|
|
72
|
+
|
|
73
|
+
print(f"Tool '{id}' deleted successfully.")
|
|
74
|
+
return True
|
|
75
|
+
|
|
76
|
+
except Exception as e:
|
|
77
|
+
print(f"Error deleting tool '{id}': {e}")
|
|
78
|
+
return False
|
|
79
|
+
|
|
80
|
+
def main():
|
|
81
|
+
|
|
82
|
+
parser = argparse.ArgumentParser(
|
|
83
|
+
prog='tg-delete-tool',
|
|
84
|
+
description=__doc__,
|
|
85
|
+
epilog=textwrap.dedent('''
|
|
86
|
+
This utility removes tool configurations from the TrustGraph system.
|
|
87
|
+
It removes the tool from both the tool index and deletes the tool
|
|
88
|
+
configuration. Once deleted, the tool will no longer be available for use.
|
|
89
|
+
|
|
90
|
+
Examples:
|
|
91
|
+
%(prog)s --id weather
|
|
92
|
+
%(prog)s --id calculator
|
|
93
|
+
%(prog)s --api-url http://localhost:9000/ --id file-reader
|
|
94
|
+
''').strip(),
|
|
95
|
+
formatter_class=argparse.RawDescriptionHelpFormatter
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
parser.add_argument(
|
|
99
|
+
'-u', '--api-url',
|
|
100
|
+
default=default_url,
|
|
101
|
+
help=f'API URL (default: {default_url})',
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
parser.add_argument(
|
|
105
|
+
'--id',
|
|
106
|
+
required=True,
|
|
107
|
+
help='Tool ID to delete',
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
args = parser.parse_args()
|
|
111
|
+
|
|
112
|
+
try:
|
|
113
|
+
|
|
114
|
+
if not args.id:
|
|
115
|
+
raise RuntimeError("Must specify --id for tool to delete")
|
|
116
|
+
|
|
117
|
+
delete_tool(
|
|
118
|
+
url=args.api_url,
|
|
119
|
+
id=args.id
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
except Exception as e:
|
|
123
|
+
|
|
124
|
+
print("Exception:", e, flush=True)
|
|
125
|
+
|
|
126
|
+
main()
|
|
127
|
+
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Invokes MCP (Model Control Protocol) tools through the TrustGraph API.
|
|
5
|
+
Allows calling MCP tools by specifying the tool name and providing
|
|
6
|
+
parameters as a JSON-encoded dictionary. The tool is executed within
|
|
7
|
+
the context of a specified flow.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
import os
|
|
12
|
+
import json
|
|
13
|
+
from trustgraph.api import Api
|
|
14
|
+
|
|
15
|
+
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
|
16
|
+
|
|
17
|
+
def query(url, flow_id, name, parameters):
|
|
18
|
+
|
|
19
|
+
api = Api(url).flow().id(flow_id)
|
|
20
|
+
|
|
21
|
+
resp = api.mcp_tool(name=name, parameters=parameters)
|
|
22
|
+
|
|
23
|
+
if isinstance(resp, str):
|
|
24
|
+
print(resp)
|
|
25
|
+
else:
|
|
26
|
+
print(json.dumps(resp, indent=4))
|
|
27
|
+
|
|
28
|
+
def main():
|
|
29
|
+
|
|
30
|
+
parser = argparse.ArgumentParser(
|
|
31
|
+
prog='tg-invoke-mcp-tool',
|
|
32
|
+
description=__doc__,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
parser.add_argument(
|
|
36
|
+
'-u', '--url',
|
|
37
|
+
default=default_url,
|
|
38
|
+
help=f'API URL (default: {default_url})',
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
parser.add_argument(
|
|
42
|
+
'-f', '--flow-id',
|
|
43
|
+
default="default",
|
|
44
|
+
help=f'Flow ID (default: default)'
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
parser.add_argument(
|
|
48
|
+
'-n', '--name',
|
|
49
|
+
metavar='tool-name',
|
|
50
|
+
help=f'MCP tool name',
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
parser.add_argument(
|
|
54
|
+
'-P', '--parameters',
|
|
55
|
+
help='''Tool parameters, should be JSON-encoded dict.''',
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
args = parser.parse_args()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
if args.parameters:
|
|
62
|
+
parameters = json.loads(args.parameters)
|
|
63
|
+
else:
|
|
64
|
+
parameters = {}
|
|
65
|
+
|
|
66
|
+
try:
|
|
67
|
+
|
|
68
|
+
query(
|
|
69
|
+
url = args.url,
|
|
70
|
+
flow_id = args.flow_id,
|
|
71
|
+
name = args.name,
|
|
72
|
+
parameters = parameters,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
except Exception as e:
|
|
76
|
+
|
|
77
|
+
print("Exception:", e, flush=True)
|
|
78
|
+
|
|
79
|
+
main()
|
|
80
|
+
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Configures and registers MCP (Model Control Protocol) tools in the
|
|
5
|
+
TrustGraph system. Allows defining MCP tool configurations with name and
|
|
6
|
+
URL. Tools are stored in the 'mcp' configuration group for discovery and
|
|
7
|
+
execution.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
import os
|
|
12
|
+
from trustgraph.api import Api, ConfigValue
|
|
13
|
+
import textwrap
|
|
14
|
+
import json
|
|
15
|
+
|
|
16
|
+
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
|
17
|
+
|
|
18
|
+
def set_mcp_tool(
|
|
19
|
+
url : str,
|
|
20
|
+
name : str,
|
|
21
|
+
tool_url : str,
|
|
22
|
+
):
|
|
23
|
+
|
|
24
|
+
api = Api(url).config()
|
|
25
|
+
|
|
26
|
+
# Store the MCP tool configuration in the 'mcp' group
|
|
27
|
+
values = api.put([
|
|
28
|
+
ConfigValue(
|
|
29
|
+
type="mcp", key=name, value=json.dumps({
|
|
30
|
+
"name": name,
|
|
31
|
+
"url": tool_url,
|
|
32
|
+
})
|
|
33
|
+
)
|
|
34
|
+
])
|
|
35
|
+
|
|
36
|
+
print(f"MCP tool '{name}' set with URL: {tool_url}")
|
|
37
|
+
|
|
38
|
+
def main():
|
|
39
|
+
|
|
40
|
+
parser = argparse.ArgumentParser(
|
|
41
|
+
prog='tg-set-mcp-tool',
|
|
42
|
+
description=__doc__,
|
|
43
|
+
epilog=textwrap.dedent('''
|
|
44
|
+
MCP tools are configured with just a name and URL. The URL should point
|
|
45
|
+
to the MCP server endpoint that provides the tool functionality.
|
|
46
|
+
|
|
47
|
+
Examples:
|
|
48
|
+
%(prog)s --name weather --tool-url "http://localhost:3000/weather"
|
|
49
|
+
%(prog)s --name calculator --tool-url "http://mcp-tools.example.com/calc"
|
|
50
|
+
''').strip(),
|
|
51
|
+
formatter_class=argparse.RawDescriptionHelpFormatter
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
parser.add_argument(
|
|
55
|
+
'-u', '--api-url',
|
|
56
|
+
default=default_url,
|
|
57
|
+
help=f'API URL (default: {default_url})',
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
parser.add_argument(
|
|
61
|
+
'--name',
|
|
62
|
+
required=True,
|
|
63
|
+
help='MCP tool name',
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
parser.add_argument(
|
|
67
|
+
'--tool-url',
|
|
68
|
+
required=True,
|
|
69
|
+
help='MCP tool URL endpoint',
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
args = parser.parse_args()
|
|
73
|
+
|
|
74
|
+
try:
|
|
75
|
+
|
|
76
|
+
if not args.name:
|
|
77
|
+
raise RuntimeError("Must specify --name for MCP tool")
|
|
78
|
+
|
|
79
|
+
if not args.tool_url:
|
|
80
|
+
raise RuntimeError("Must specify --url for MCP tool")
|
|
81
|
+
|
|
82
|
+
set_mcp_tool(
|
|
83
|
+
url=args.api_url,
|
|
84
|
+
name=args.name,
|
|
85
|
+
tool_url=args.tool_url
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
except Exception as e:
|
|
89
|
+
|
|
90
|
+
print("Exception:", e, flush=True)
|
|
91
|
+
|
|
92
|
+
main()
|
|
93
|
+
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Configures and registers tools in the TrustGraph system.
|
|
5
|
+
Allows defining tool metadata including ID, name, description, type,
|
|
6
|
+
and argument specifications. Tools are stored in the agent configuration
|
|
7
|
+
and indexed for discovery and execution.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from typing import List
|
|
11
|
+
import argparse
|
|
12
|
+
import os
|
|
13
|
+
from trustgraph.api import Api, ConfigKey, ConfigValue
|
|
14
|
+
import json
|
|
15
|
+
import tabulate
|
|
16
|
+
import textwrap
|
|
17
|
+
import dataclasses
|
|
18
|
+
|
|
19
|
+
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
|
20
|
+
|
|
21
|
+
@dataclasses.dataclass
|
|
22
|
+
class Argument:
|
|
23
|
+
name : str
|
|
24
|
+
type : str
|
|
25
|
+
description : str
|
|
26
|
+
|
|
27
|
+
@staticmethod
|
|
28
|
+
def parse(s):
|
|
29
|
+
|
|
30
|
+
parts = s.split(":")
|
|
31
|
+
if len(parts) != 3:
|
|
32
|
+
raise RuntimeError(
|
|
33
|
+
"Arguments should be form name:type:description"
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
valid_types = [
|
|
37
|
+
"string", "number",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
if parts[1] not in valid_types:
|
|
41
|
+
raise RuntimeError(
|
|
42
|
+
f"Type {parts[1]} invalid, use: " +
|
|
43
|
+
", ".join(valid_types)
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
return Argument(name=parts[0], type=parts[1], description=parts[2])
|
|
47
|
+
|
|
48
|
+
def set_tool(
|
|
49
|
+
url : str,
|
|
50
|
+
id : str,
|
|
51
|
+
name : str,
|
|
52
|
+
description : str,
|
|
53
|
+
type : str,
|
|
54
|
+
arguments : List[Argument],
|
|
55
|
+
):
|
|
56
|
+
|
|
57
|
+
api = Api(url).config()
|
|
58
|
+
|
|
59
|
+
values = api.get([
|
|
60
|
+
ConfigKey(type="agent", key="tool-index")
|
|
61
|
+
])
|
|
62
|
+
|
|
63
|
+
ix = json.loads(values[0].value)
|
|
64
|
+
|
|
65
|
+
object = {
|
|
66
|
+
"id": id,
|
|
67
|
+
"name": name,
|
|
68
|
+
"description": description,
|
|
69
|
+
"type": type,
|
|
70
|
+
"arguments": [
|
|
71
|
+
{
|
|
72
|
+
"name": a.name,
|
|
73
|
+
"type": a.type,
|
|
74
|
+
"description": a.description,
|
|
75
|
+
}
|
|
76
|
+
for a in arguments
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if id not in ix:
|
|
81
|
+
ix.append(id)
|
|
82
|
+
|
|
83
|
+
values = api.put([
|
|
84
|
+
ConfigValue(
|
|
85
|
+
type="agent", key="tool-index", value=json.dumps(ix)
|
|
86
|
+
),
|
|
87
|
+
ConfigValue(
|
|
88
|
+
type="agent", key=f"tool.{id}", value=json.dumps(object)
|
|
89
|
+
)
|
|
90
|
+
])
|
|
91
|
+
|
|
92
|
+
print("Tool set.")
|
|
93
|
+
|
|
94
|
+
def main():
|
|
95
|
+
|
|
96
|
+
parser = argparse.ArgumentParser(
|
|
97
|
+
prog='tg-set-tool',
|
|
98
|
+
description=__doc__,
|
|
99
|
+
epilog=textwrap.dedent('''
|
|
100
|
+
Valid tool types:
|
|
101
|
+
knowledge-query - Query knowledge bases
|
|
102
|
+
text-completion - Text completion/generation
|
|
103
|
+
mcp-tool - Model Control Protocol tool
|
|
104
|
+
|
|
105
|
+
Valid argument types:
|
|
106
|
+
string - String/text parameter
|
|
107
|
+
number - Numeric parameter
|
|
108
|
+
|
|
109
|
+
Examples:
|
|
110
|
+
%(prog)s --id weather --name "Weather lookup" \\
|
|
111
|
+
--type knowledge-query \\
|
|
112
|
+
--description "Get weather information" \\
|
|
113
|
+
--argument location:string:"Location to query" \\
|
|
114
|
+
--argument units:string:"Temperature units (C/F)"
|
|
115
|
+
|
|
116
|
+
%(prog)s --id calculator --name "Calculator" --type mcp-tool \\
|
|
117
|
+
--description "Perform calculations" \\
|
|
118
|
+
--argument expression:string:"Mathematical expression"
|
|
119
|
+
''').strip(),
|
|
120
|
+
formatter_class=argparse.RawDescriptionHelpFormatter
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
parser.add_argument(
|
|
124
|
+
'-u', '--api-url',
|
|
125
|
+
default=default_url,
|
|
126
|
+
help=f'API URL (default: {default_url})',
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
parser.add_argument(
|
|
130
|
+
'--id',
|
|
131
|
+
help=f'Tool ID',
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
parser.add_argument(
|
|
135
|
+
'--name',
|
|
136
|
+
help=f'Tool name',
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
parser.add_argument(
|
|
140
|
+
'--description',
|
|
141
|
+
help=f'Tool description',
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
parser.add_argument(
|
|
145
|
+
'--type',
|
|
146
|
+
help=f'Tool type, one of: knowledge-query, text-completion, mcp-tool',
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
parser.add_argument(
|
|
150
|
+
'--argument',
|
|
151
|
+
nargs="*",
|
|
152
|
+
help=f'Arguments, form: name:type:description',
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
args = parser.parse_args()
|
|
156
|
+
|
|
157
|
+
try:
|
|
158
|
+
|
|
159
|
+
valid_types = [
|
|
160
|
+
"knowledge-query", "text-completion", "mcp-tool"
|
|
161
|
+
]
|
|
162
|
+
|
|
163
|
+
if args.id is None:
|
|
164
|
+
raise RuntimeError("Must specify --id for prompt")
|
|
165
|
+
|
|
166
|
+
if args.name is None:
|
|
167
|
+
raise RuntimeError("Must specify --name for prompt")
|
|
168
|
+
|
|
169
|
+
if args.type:
|
|
170
|
+
if args.type not in valid_types:
|
|
171
|
+
raise RuntimeError(
|
|
172
|
+
"Type must be one of: " + ", ".join(valid_types)
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
if args.argument:
|
|
176
|
+
arguments = [
|
|
177
|
+
Argument.parse(a)
|
|
178
|
+
for a in args.argument
|
|
179
|
+
]
|
|
180
|
+
else:
|
|
181
|
+
arguments = []
|
|
182
|
+
|
|
183
|
+
set_tool(
|
|
184
|
+
url=args.api_url, id=args.id, name=args.name,
|
|
185
|
+
description=args.description,
|
|
186
|
+
type=args.type,
|
|
187
|
+
arguments=arguments
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
except Exception as e:
|
|
191
|
+
|
|
192
|
+
print("Exception:", e, flush=True)
|
|
193
|
+
|
|
194
|
+
main()
|
|
195
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Dumps out the current agent tool configuration
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
import os
|
|
9
|
+
from trustgraph.api import Api, ConfigKey
|
|
10
|
+
import json
|
|
11
|
+
import tabulate
|
|
12
|
+
import textwrap
|
|
13
|
+
|
|
14
|
+
default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
|
|
15
|
+
|
|
16
|
+
def show_config(url):
|
|
17
|
+
|
|
18
|
+
api = Api(url).config()
|
|
19
|
+
|
|
20
|
+
values = api.get_values(type="mcp")
|
|
21
|
+
|
|
22
|
+
for n, value in enumerate(values):
|
|
23
|
+
|
|
24
|
+
data = json.loads(value.value)
|
|
25
|
+
|
|
26
|
+
table = []
|
|
27
|
+
|
|
28
|
+
table.append(("id", value.key))
|
|
29
|
+
table.append(("name", data["name"]))
|
|
30
|
+
table.append(("url", data["url"]))
|
|
31
|
+
|
|
32
|
+
print()
|
|
33
|
+
print(value.key + ":")
|
|
34
|
+
|
|
35
|
+
print(tabulate.tabulate(
|
|
36
|
+
table,
|
|
37
|
+
tablefmt="pretty",
|
|
38
|
+
maxcolwidths=[None, 70],
|
|
39
|
+
stralign="left"
|
|
40
|
+
))
|
|
41
|
+
|
|
42
|
+
print()
|
|
43
|
+
|
|
44
|
+
def main():
|
|
45
|
+
|
|
46
|
+
parser = argparse.ArgumentParser(
|
|
47
|
+
prog='tg-show-mcp-tools',
|
|
48
|
+
description=__doc__,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
parser.add_argument(
|
|
52
|
+
'-u', '--api-url',
|
|
53
|
+
default=default_url,
|
|
54
|
+
help=f'API URL (default: {default_url})',
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
args = parser.parse_args()
|
|
58
|
+
|
|
59
|
+
try:
|
|
60
|
+
|
|
61
|
+
show_config(
|
|
62
|
+
url=args.api_url,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
except Exception as e:
|
|
66
|
+
|
|
67
|
+
print("Exception:", e, flush=True)
|
|
68
|
+
|
|
69
|
+
main()
|
|
70
|
+
|
|
@@ -46,7 +46,9 @@ setuptools.setup(
|
|
|
46
46
|
scripts=[
|
|
47
47
|
"scripts/tg-add-library-document",
|
|
48
48
|
"scripts/tg-delete-flow-class",
|
|
49
|
+
"scripts/tg-delete-mcp-tool",
|
|
49
50
|
"scripts/tg-delete-kg-core",
|
|
51
|
+
"scripts/tg-delete-tool",
|
|
50
52
|
"scripts/tg-dump-msgpack",
|
|
51
53
|
"scripts/tg-get-flow-class",
|
|
52
54
|
"scripts/tg-get-kg-core",
|
|
@@ -56,6 +58,7 @@ setuptools.setup(
|
|
|
56
58
|
"scripts/tg-invoke-document-rag",
|
|
57
59
|
"scripts/tg-invoke-graph-rag",
|
|
58
60
|
"scripts/tg-invoke-llm",
|
|
61
|
+
"scripts/tg-invoke-mcp-tool",
|
|
59
62
|
"scripts/tg-invoke-prompt",
|
|
60
63
|
"scripts/tg-load-doc-embeds",
|
|
61
64
|
"scripts/tg-load-kg-core",
|
|
@@ -67,8 +70,10 @@ setuptools.setup(
|
|
|
67
70
|
"scripts/tg-put-kg-core",
|
|
68
71
|
"scripts/tg-remove-library-document",
|
|
69
72
|
"scripts/tg-save-doc-embeds",
|
|
73
|
+
"scripts/tg-set-mcp-tool",
|
|
70
74
|
"scripts/tg-set-prompt",
|
|
71
75
|
"scripts/tg-set-token-costs",
|
|
76
|
+
"scripts/tg-set-tool",
|
|
72
77
|
"scripts/tg-show-config",
|
|
73
78
|
"scripts/tg-show-flow-classes",
|
|
74
79
|
"scripts/tg-show-flow-state",
|
|
@@ -77,6 +82,7 @@ setuptools.setup(
|
|
|
77
82
|
"scripts/tg-show-kg-cores",
|
|
78
83
|
"scripts/tg-show-library-documents",
|
|
79
84
|
"scripts/tg-show-library-processing",
|
|
85
|
+
"scripts/tg-show-mcp-tools",
|
|
80
86
|
"scripts/tg-show-processor-state",
|
|
81
87
|
"scripts/tg-show-prompts",
|
|
82
88
|
"scripts/tg-show-token-costs",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.1.7"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: trustgraph-cli
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.7
|
|
4
4
|
Summary: TrustGraph provides a means to run a pipeline of flexible AI processing components in a flexible means to achieve a processing pipeline.
|
|
5
5
|
Home-page: https://github.com/trustgraph-ai/trustgraph
|
|
6
|
-
Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v1.1.
|
|
6
|
+
Download-URL: https://github.com/trustgraph-ai/trustgraph/archive/refs/tags/v1.1.7.tar.gz
|
|
7
7
|
Author: trustgraph.ai
|
|
8
8
|
Author-email: security@trustgraph.ai
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -3,6 +3,8 @@ setup.py
|
|
|
3
3
|
scripts/tg-add-library-document
|
|
4
4
|
scripts/tg-delete-flow-class
|
|
5
5
|
scripts/tg-delete-kg-core
|
|
6
|
+
scripts/tg-delete-mcp-tool
|
|
7
|
+
scripts/tg-delete-tool
|
|
6
8
|
scripts/tg-dump-msgpack
|
|
7
9
|
scripts/tg-get-flow-class
|
|
8
10
|
scripts/tg-get-kg-core
|
|
@@ -12,6 +14,7 @@ scripts/tg-invoke-agent
|
|
|
12
14
|
scripts/tg-invoke-document-rag
|
|
13
15
|
scripts/tg-invoke-graph-rag
|
|
14
16
|
scripts/tg-invoke-llm
|
|
17
|
+
scripts/tg-invoke-mcp-tool
|
|
15
18
|
scripts/tg-invoke-prompt
|
|
16
19
|
scripts/tg-load-doc-embeds
|
|
17
20
|
scripts/tg-load-kg-core
|
|
@@ -23,8 +26,10 @@ scripts/tg-put-flow-class
|
|
|
23
26
|
scripts/tg-put-kg-core
|
|
24
27
|
scripts/tg-remove-library-document
|
|
25
28
|
scripts/tg-save-doc-embeds
|
|
29
|
+
scripts/tg-set-mcp-tool
|
|
26
30
|
scripts/tg-set-prompt
|
|
27
31
|
scripts/tg-set-token-costs
|
|
32
|
+
scripts/tg-set-tool
|
|
28
33
|
scripts/tg-show-config
|
|
29
34
|
scripts/tg-show-flow-classes
|
|
30
35
|
scripts/tg-show-flow-state
|
|
@@ -33,6 +38,7 @@ scripts/tg-show-graph
|
|
|
33
38
|
scripts/tg-show-kg-cores
|
|
34
39
|
scripts/tg-show-library-documents
|
|
35
40
|
scripts/tg-show-library-processing
|
|
41
|
+
scripts/tg-show-mcp-tools
|
|
36
42
|
scripts/tg-show-processor-state
|
|
37
43
|
scripts/tg-show-prompts
|
|
38
44
|
scripts/tg-show-token-costs
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.1.5"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|