trustgraph-cli 1.1.1__tar.gz → 1.7.2__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.

Files changed (89) hide show
  1. trustgraph_cli-1.7.2/PKG-INFO +20 -0
  2. trustgraph_cli-1.7.2/pyproject.toml +100 -0
  3. trustgraph_cli-1.7.2/trustgraph/cli/__init__.py +1 -0
  4. trustgraph-cli-1.1.1/scripts/tg-add-library-document → trustgraph_cli-1.7.2/trustgraph/cli/add_library_document.py +2 -4
  5. trustgraph_cli-1.7.2/trustgraph/cli/delete_collection.py +72 -0
  6. trustgraph_cli-1.7.2/trustgraph/cli/delete_config_item.py +69 -0
  7. trustgraph-cli-1.1.1/scripts/tg-delete-flow-class → trustgraph_cli-1.7.2/trustgraph/cli/delete_flow_class.py +2 -4
  8. trustgraph-cli-1.1.1/scripts/tg-delete-kg-core → trustgraph_cli-1.7.2/trustgraph/cli/delete_kg_core.py +3 -5
  9. trustgraph_cli-1.7.2/trustgraph/cli/delete_mcp_tool.py +93 -0
  10. trustgraph_cli-1.7.2/trustgraph/cli/delete_tool.py +98 -0
  11. trustgraph-cli-1.1.1/scripts/tg-dump-msgpack → trustgraph_cli-1.7.2/trustgraph/cli/dump_msgpack.py +2 -4
  12. trustgraph_cli-1.7.2/trustgraph/cli/dump_queues.py +362 -0
  13. trustgraph_cli-1.7.2/trustgraph/cli/get_config_item.py +86 -0
  14. trustgraph-cli-1.1.1/scripts/tg-get-flow-class → trustgraph_cli-1.7.2/trustgraph/cli/get_flow_class.py +2 -4
  15. trustgraph-cli-1.1.1/scripts/tg-get-kg-core → trustgraph_cli-1.7.2/trustgraph/cli/get_kg_core.py +14 -5
  16. trustgraph-cli-1.1.1/scripts/tg-graph-to-turtle → trustgraph_cli-1.7.2/trustgraph/cli/graph_to_turtle.py +2 -4
  17. trustgraph_cli-1.7.2/trustgraph/cli/init_pulsar_manager.py +11 -0
  18. trustgraph-cli-1.1.1/scripts/tg-init-trustgraph → trustgraph_cli-1.7.2/trustgraph/cli/init_trustgraph.py +23 -5
  19. trustgraph_cli-1.7.2/trustgraph/cli/invoke_agent.py +285 -0
  20. trustgraph-cli-1.1.1/scripts/tg-invoke-document-rag → trustgraph_cli-1.7.2/trustgraph/cli/invoke_document_rag.py +55 -15
  21. trustgraph-cli-1.1.1/scripts/tg-invoke-graph-rag → trustgraph_cli-1.7.2/trustgraph/cli/invoke_graph_rag.py +64 -17
  22. trustgraph_cli-1.7.2/trustgraph/cli/invoke_llm.py +103 -0
  23. trustgraph_cli-1.7.2/trustgraph/cli/invoke_mcp_tool.py +78 -0
  24. trustgraph_cli-1.7.2/trustgraph/cli/invoke_nlp_query.py +111 -0
  25. trustgraph_cli-1.7.2/trustgraph/cli/invoke_objects_query.py +201 -0
  26. trustgraph-cli-1.1.1/scripts/tg-invoke-prompt → trustgraph_cli-1.7.2/trustgraph/cli/invoke_prompt.py +44 -11
  27. trustgraph_cli-1.7.2/trustgraph/cli/invoke_structured_query.py +173 -0
  28. trustgraph_cli-1.7.2/trustgraph/cli/list_collections.py +86 -0
  29. trustgraph_cli-1.7.2/trustgraph/cli/list_config_items.py +73 -0
  30. trustgraph-cli-1.1.1/scripts/tg-load-doc-embeds → trustgraph_cli-1.7.2/trustgraph/cli/load_doc_embeds.py +0 -2
  31. trustgraph-cli-1.1.1/scripts/tg-load-kg-core → trustgraph_cli-1.7.2/trustgraph/cli/load_kg_core.py +4 -6
  32. trustgraph_cli-1.7.2/trustgraph/cli/load_knowledge.py +213 -0
  33. trustgraph-cli-1.1.1/scripts/tg-load-pdf → trustgraph_cli-1.7.2/trustgraph/cli/load_pdf.py +2 -4
  34. trustgraph-cli-1.1.1/scripts/tg-load-sample-documents → trustgraph_cli-1.7.2/trustgraph/cli/load_sample_documents.py +12 -6
  35. trustgraph_cli-1.7.2/trustgraph/cli/load_structured_data.py +1070 -0
  36. trustgraph-cli-1.1.1/scripts/tg-load-text → trustgraph_cli-1.7.2/trustgraph/cli/load_text.py +2 -5
  37. trustgraph_cli-1.7.2/trustgraph/cli/load_turtle.py +166 -0
  38. trustgraph_cli-1.7.2/trustgraph/cli/put_config_item.py +88 -0
  39. trustgraph-cli-1.1.1/scripts/tg-put-flow-class → trustgraph_cli-1.7.2/trustgraph/cli/put_flow_class.py +12 -6
  40. trustgraph-cli-1.1.1/scripts/tg-put-kg-core → trustgraph_cli-1.7.2/trustgraph/cli/put_kg_core.py +14 -5
  41. trustgraph-cli-1.1.1/scripts/tg-remove-library-document → trustgraph_cli-1.7.2/trustgraph/cli/remove_library_document.py +12 -7
  42. trustgraph-cli-1.1.1/scripts/tg-save-doc-embeds → trustgraph_cli-1.7.2/trustgraph/cli/save_doc_embeds.py +0 -2
  43. trustgraph_cli-1.7.2/trustgraph/cli/set_collection.py +111 -0
  44. trustgraph_cli-1.7.2/trustgraph/cli/set_mcp_tool.py +136 -0
  45. trustgraph-cli-1.1.1/scripts/tg-set-prompt → trustgraph_cli-1.7.2/trustgraph/cli/set_prompt.py +16 -11
  46. trustgraph-cli-1.1.1/scripts/tg-set-token-costs → trustgraph_cli-1.7.2/trustgraph/cli/set_token_costs.py +11 -6
  47. trustgraph_cli-1.7.2/trustgraph/cli/set_tool.py +276 -0
  48. trustgraph-cli-1.1.1/scripts/tg-show-config → trustgraph_cli-1.7.2/trustgraph/cli/show_config.py +12 -6
  49. trustgraph_cli-1.7.2/trustgraph/cli/show_flow_classes.py +130 -0
  50. trustgraph-cli-1.1.1/scripts/tg-show-flow-state → trustgraph_cli-1.7.2/trustgraph/cli/show_flow_state.py +12 -7
  51. trustgraph_cli-1.7.2/trustgraph/cli/show_flows.py +223 -0
  52. trustgraph-cli-1.1.1/scripts/tg-show-graph → trustgraph_cli-1.7.2/trustgraph/cli/show_graph.py +12 -6
  53. trustgraph-cli-1.1.1/scripts/tg-show-kg-cores → trustgraph_cli-1.7.2/trustgraph/cli/show_kg_cores.py +14 -7
  54. trustgraph-cli-1.1.1/scripts/tg-show-library-documents → trustgraph_cli-1.7.2/trustgraph/cli/show_library_documents.py +14 -7
  55. trustgraph-cli-1.1.1/scripts/tg-show-library-processing → trustgraph_cli-1.7.2/trustgraph/cli/show_library_processing.py +12 -7
  56. trustgraph_cli-1.7.2/trustgraph/cli/show_mcp_tools.py +81 -0
  57. trustgraph_cli-1.7.2/trustgraph/cli/show_parameter_types.py +217 -0
  58. trustgraph-cli-1.1.1/scripts/tg-show-processor-state → trustgraph_cli-1.7.2/trustgraph/cli/show_processor_state.py +2 -4
  59. trustgraph-cli-1.1.1/scripts/tg-show-prompts → trustgraph_cli-1.7.2/trustgraph/cli/show_prompts.py +12 -6
  60. trustgraph-cli-1.1.1/scripts/tg-show-token-costs → trustgraph_cli-1.7.2/trustgraph/cli/show_token_costs.py +12 -6
  61. trustgraph-cli-1.1.1/scripts/tg-show-token-rate → trustgraph_cli-1.7.2/trustgraph/cli/show_token_rate.py +2 -4
  62. trustgraph_cli-1.7.2/trustgraph/cli/show_tools.py +124 -0
  63. trustgraph_cli-1.7.2/trustgraph/cli/start_flow.py +130 -0
  64. trustgraph-cli-1.1.1/scripts/tg-start-library-processing → trustgraph_cli-1.7.2/trustgraph/cli/start_library_processing.py +13 -7
  65. trustgraph-cli-1.1.1/scripts/tg-stop-flow → trustgraph_cli-1.7.2/trustgraph/cli/stop_flow.py +12 -6
  66. trustgraph-cli-1.1.1/scripts/tg-stop-library-processing → trustgraph_cli-1.7.2/trustgraph/cli/stop_library_processing.py +12 -6
  67. trustgraph-cli-1.1.1/scripts/tg-unload-kg-core → trustgraph_cli-1.7.2/trustgraph/cli/unload_kg_core.py +13 -7
  68. trustgraph_cli-1.7.2/trustgraph/cli/verify_system_status.py +492 -0
  69. trustgraph_cli-1.7.2/trustgraph/cli_version.py +1 -0
  70. trustgraph_cli-1.7.2/trustgraph_cli.egg-info/PKG-INFO +20 -0
  71. trustgraph_cli-1.7.2/trustgraph_cli.egg-info/SOURCES.txt +75 -0
  72. trustgraph_cli-1.7.2/trustgraph_cli.egg-info/entry_points.txt +65 -0
  73. {trustgraph-cli-1.1.1 → trustgraph_cli-1.7.2}/trustgraph_cli.egg-info/requires.txt +4 -4
  74. {trustgraph-cli-1.1.1 → trustgraph_cli-1.7.2}/trustgraph_cli.egg-info/top_level.txt +0 -1
  75. trustgraph-cli-1.1.1/PKG-INFO +0 -15
  76. trustgraph-cli-1.1.1/scripts/tg-invoke-agent +0 -173
  77. trustgraph-cli-1.1.1/scripts/tg-invoke-llm +0 -70
  78. trustgraph-cli-1.1.1/scripts/tg-load-turtle +0 -161
  79. trustgraph-cli-1.1.1/scripts/tg-show-flow-classes +0 -69
  80. trustgraph-cli-1.1.1/scripts/tg-show-flows +0 -114
  81. trustgraph-cli-1.1.1/scripts/tg-show-tools +0 -86
  82. trustgraph-cli-1.1.1/scripts/tg-start-flow +0 -72
  83. trustgraph-cli-1.1.1/setup.py +0 -91
  84. trustgraph-cli-1.1.1/trustgraph/cli_version.py +0 -1
  85. trustgraph-cli-1.1.1/trustgraph_cli.egg-info/PKG-INFO +0 -15
  86. trustgraph-cli-1.1.1/trustgraph_cli.egg-info/SOURCES.txt +0 -51
  87. {trustgraph-cli-1.1.1 → trustgraph_cli-1.7.2}/README.md +0 -0
  88. {trustgraph-cli-1.1.1 → trustgraph_cli-1.7.2}/setup.cfg +0 -0
  89. {trustgraph-cli-1.1.1 → trustgraph_cli-1.7.2}/trustgraph_cli.egg-info/dependency_links.txt +0 -0
@@ -0,0 +1,20 @@
1
+ Metadata-Version: 2.4
2
+ Name: trustgraph-cli
3
+ Version: 1.7.2
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
+ Author-email: "trustgraph.ai" <security@trustgraph.ai>
6
+ Project-URL: Homepage, https://github.com/trustgraph-ai/trustgraph
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: trustgraph-base<1.8,>=1.7
12
+ Requires-Dist: requests
13
+ Requires-Dist: pulsar-client
14
+ Requires-Dist: aiohttp
15
+ Requires-Dist: rdflib
16
+ Requires-Dist: tabulate
17
+ Requires-Dist: msgpack
18
+ Requires-Dist: websockets
19
+
20
+ See https://trustgraph.ai/
@@ -0,0 +1,100 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "trustgraph-cli"
7
+ dynamic = ["version"]
8
+ authors = [{name = "trustgraph.ai", email = "security@trustgraph.ai"}]
9
+ description = "TrustGraph provides a means to run a pipeline of flexible AI processing components in a flexible means to achieve a processing pipeline."
10
+ readme = "README.md"
11
+ requires-python = ">=3.8"
12
+ dependencies = [
13
+ "trustgraph-base>=1.7,<1.8",
14
+ "requests",
15
+ "pulsar-client",
16
+ "aiohttp",
17
+ "rdflib",
18
+ "tabulate",
19
+ "msgpack",
20
+ "websockets",
21
+ ]
22
+ classifiers = [
23
+ "Programming Language :: Python :: 3",
24
+ "Operating System :: OS Independent",
25
+ ]
26
+
27
+ [project.urls]
28
+ Homepage = "https://github.com/trustgraph-ai/trustgraph"
29
+
30
+ [project.scripts]
31
+ tg-add-library-document = "trustgraph.cli.add_library_document:main"
32
+ tg-delete-flow-class = "trustgraph.cli.delete_flow_class:main"
33
+ tg-delete-mcp-tool = "trustgraph.cli.delete_mcp_tool:main"
34
+ tg-delete-kg-core = "trustgraph.cli.delete_kg_core:main"
35
+ tg-delete-tool = "trustgraph.cli.delete_tool:main"
36
+ tg-dump-msgpack = "trustgraph.cli.dump_msgpack:main"
37
+ tg-dump-queues = "trustgraph.cli.dump_queues:main"
38
+ tg-get-flow-class = "trustgraph.cli.get_flow_class:main"
39
+ tg-get-kg-core = "trustgraph.cli.get_kg_core:main"
40
+ tg-graph-to-turtle = "trustgraph.cli.graph_to_turtle:main"
41
+ tg-init-trustgraph = "trustgraph.cli.init_trustgraph:main"
42
+ tg-invoke-agent = "trustgraph.cli.invoke_agent:main"
43
+ tg-invoke-document-rag = "trustgraph.cli.invoke_document_rag:main"
44
+ tg-invoke-graph-rag = "trustgraph.cli.invoke_graph_rag:main"
45
+ tg-invoke-llm = "trustgraph.cli.invoke_llm:main"
46
+ tg-invoke-mcp-tool = "trustgraph.cli.invoke_mcp_tool:main"
47
+ tg-invoke-nlp-query = "trustgraph.cli.invoke_nlp_query:main"
48
+ tg-invoke-objects-query = "trustgraph.cli.invoke_objects_query:main"
49
+ tg-invoke-prompt = "trustgraph.cli.invoke_prompt:main"
50
+ tg-invoke-structured-query = "trustgraph.cli.invoke_structured_query:main"
51
+ tg-load-doc-embeds = "trustgraph.cli.load_doc_embeds:main"
52
+ tg-load-kg-core = "trustgraph.cli.load_kg_core:main"
53
+ tg-load-pdf = "trustgraph.cli.load_pdf:main"
54
+ tg-load-sample-documents = "trustgraph.cli.load_sample_documents:main"
55
+ tg-load-text = "trustgraph.cli.load_text:main"
56
+ tg-load-turtle = "trustgraph.cli.load_turtle:main"
57
+ tg-load-knowledge = "trustgraph.cli.load_knowledge:main"
58
+ tg-load-structured-data = "trustgraph.cli.load_structured_data:main"
59
+ tg-put-flow-class = "trustgraph.cli.put_flow_class:main"
60
+ tg-put-kg-core = "trustgraph.cli.put_kg_core:main"
61
+ tg-remove-library-document = "trustgraph.cli.remove_library_document:main"
62
+ tg-save-doc-embeds = "trustgraph.cli.save_doc_embeds:main"
63
+ tg-set-mcp-tool = "trustgraph.cli.set_mcp_tool:main"
64
+ tg-set-prompt = "trustgraph.cli.set_prompt:main"
65
+ tg-set-token-costs = "trustgraph.cli.set_token_costs:main"
66
+ tg-set-tool = "trustgraph.cli.set_tool:main"
67
+ tg-show-config = "trustgraph.cli.show_config:main"
68
+ tg-show-flow-classes = "trustgraph.cli.show_flow_classes:main"
69
+ tg-show-flow-state = "trustgraph.cli.show_flow_state:main"
70
+ tg-show-flows = "trustgraph.cli.show_flows:main"
71
+ tg-show-graph = "trustgraph.cli.show_graph:main"
72
+ tg-show-kg-cores = "trustgraph.cli.show_kg_cores:main"
73
+ tg-show-library-documents = "trustgraph.cli.show_library_documents:main"
74
+ tg-show-library-processing = "trustgraph.cli.show_library_processing:main"
75
+ tg-show-mcp-tools = "trustgraph.cli.show_mcp_tools:main"
76
+ tg-show-parameter-types = "trustgraph.cli.show_parameter_types:main"
77
+ tg-show-processor-state = "trustgraph.cli.show_processor_state:main"
78
+ tg-show-prompts = "trustgraph.cli.show_prompts:main"
79
+ tg-show-token-costs = "trustgraph.cli.show_token_costs:main"
80
+ tg-show-token-rate = "trustgraph.cli.show_token_rate:main"
81
+ tg-show-tools = "trustgraph.cli.show_tools:main"
82
+ tg-start-flow = "trustgraph.cli.start_flow:main"
83
+ tg-unload-kg-core = "trustgraph.cli.unload_kg_core:main"
84
+ tg-start-library-processing = "trustgraph.cli.start_library_processing:main"
85
+ tg-stop-flow = "trustgraph.cli.stop_flow:main"
86
+ tg-stop-library-processing = "trustgraph.cli.stop_library_processing:main"
87
+ tg-verify-system-status = "trustgraph.cli.verify_system_status:main"
88
+ tg-list-config-items = "trustgraph.cli.list_config_items:main"
89
+ tg-get-config-item = "trustgraph.cli.get_config_item:main"
90
+ tg-put-config-item = "trustgraph.cli.put_config_item:main"
91
+ tg-delete-config-item = "trustgraph.cli.delete_config_item:main"
92
+ tg-list-collections = "trustgraph.cli.list_collections:main"
93
+ tg-set-collection = "trustgraph.cli.set_collection:main"
94
+ tg-delete-collection = "trustgraph.cli.delete_collection:main"
95
+
96
+ [tool.setuptools.packages.find]
97
+ include = ["trustgraph*"]
98
+
99
+ [tool.setuptools.dynamic]
100
+ version = {attr = "trustgraph.cli_version.__version__"}
@@ -0,0 +1 @@
1
+ # TrustGraph CLI modules
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env python3
2
-
3
1
  """
4
2
  Loads a document into the library
5
3
  """
@@ -202,5 +200,5 @@ def main():
202
200
 
203
201
  print("Exception:", e, flush=True)
204
202
 
205
- main()
206
-
203
+ if __name__ == "__main__":
204
+ main()
@@ -0,0 +1,72 @@
1
+ """
2
+ Delete a collection and all its data
3
+ """
4
+
5
+ import argparse
6
+ import os
7
+ from trustgraph.api import Api
8
+
9
+ default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
10
+ default_user = "trustgraph"
11
+
12
+ def delete_collection(url, user, collection, confirm):
13
+
14
+ if not confirm:
15
+ response = input(f"Are you sure you want to delete collection '{collection}' and all its data? (y/N): ")
16
+ if response.lower() not in ['y', 'yes']:
17
+ print("Operation cancelled.")
18
+ return
19
+
20
+ api = Api(url).collection()
21
+
22
+ api.delete_collection(user=user, collection=collection)
23
+
24
+ print(f"Collection '{collection}' deleted successfully.")
25
+
26
+ def main():
27
+
28
+ parser = argparse.ArgumentParser(
29
+ prog='tg-delete-collection',
30
+ description=__doc__,
31
+ )
32
+
33
+ parser.add_argument(
34
+ 'collection',
35
+ help='Collection ID to delete'
36
+ )
37
+
38
+ parser.add_argument(
39
+ '-u', '--api-url',
40
+ default=default_url,
41
+ help=f'API URL (default: {default_url})',
42
+ )
43
+
44
+ parser.add_argument(
45
+ '-U', '--user',
46
+ default=default_user,
47
+ help=f'User ID (default: {default_user})'
48
+ )
49
+
50
+ parser.add_argument(
51
+ '-y', '--yes',
52
+ action='store_true',
53
+ help='Skip confirmation prompt'
54
+ )
55
+
56
+ args = parser.parse_args()
57
+
58
+ try:
59
+
60
+ delete_collection(
61
+ url = args.api_url,
62
+ user = args.user,
63
+ collection = args.collection,
64
+ confirm = args.yes
65
+ )
66
+
67
+ except Exception as e:
68
+
69
+ print("Exception:", e, flush=True)
70
+
71
+ if __name__ == "__main__":
72
+ main()
@@ -0,0 +1,69 @@
1
+ """
2
+ Deletes a configuration item
3
+ """
4
+
5
+ import argparse
6
+ import os
7
+ from trustgraph.api import Api
8
+ from trustgraph.api.types import ConfigKey
9
+
10
+ default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
11
+ default_token = os.getenv("TRUSTGRAPH_TOKEN", None)
12
+
13
+ def delete_config_item(url, config_type, key, token=None):
14
+
15
+ api = Api(url, token=token).config()
16
+
17
+ config_key = ConfigKey(type=config_type, key=key)
18
+ api.delete([config_key])
19
+
20
+ print(f"Configuration item deleted: {config_type}/{key}")
21
+
22
+ def main():
23
+
24
+ parser = argparse.ArgumentParser(
25
+ prog='tg-delete-config-item',
26
+ description=__doc__,
27
+ )
28
+
29
+ parser.add_argument(
30
+ '--type',
31
+ required=True,
32
+ help='Configuration type',
33
+ )
34
+
35
+ parser.add_argument(
36
+ '--key',
37
+ required=True,
38
+ help='Configuration key',
39
+ )
40
+
41
+ parser.add_argument(
42
+ '-u', '--api-url',
43
+ default=default_url,
44
+ help=f'API URL (default: {default_url})',
45
+ )
46
+
47
+ parser.add_argument(
48
+ '-t', '--token',
49
+ default=default_token,
50
+ help='Authentication token (default: $TRUSTGRAPH_TOKEN)',
51
+ )
52
+
53
+ args = parser.parse_args()
54
+
55
+ try:
56
+
57
+ delete_config_item(
58
+ url=args.api_url,
59
+ config_type=args.type,
60
+ key=args.key,
61
+ token=args.token,
62
+ )
63
+
64
+ except Exception as e:
65
+
66
+ print("Exception:", e, flush=True)
67
+
68
+ if __name__ == "__main__":
69
+ main()
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env python3
2
-
3
1
  """
4
2
  Deletes a flow class
5
3
  """
@@ -49,5 +47,5 @@ def main():
49
47
 
50
48
  print("Exception:", e, flush=True)
51
49
 
52
- main()
53
-
50
+ if __name__ == "__main__":
51
+ main()
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env python3
2
-
3
1
  """
4
2
  Deletes a flow class
5
3
  """
@@ -21,7 +19,7 @@ def delete_kg_core(url, user, id):
21
19
  def main():
22
20
 
23
21
  parser = argparse.ArgumentParser(
24
- prog='tg-delete-flow-class',
22
+ prog='tg-delete-kg-core',
25
23
  description=__doc__,
26
24
  )
27
25
 
@@ -57,5 +55,5 @@ def main():
57
55
 
58
56
  print("Exception:", e, flush=True)
59
57
 
60
- main()
61
-
58
+ if __name__ == "__main__":
59
+ main()
@@ -0,0 +1,93 @@
1
+ """
2
+ Deletes MCP (Model Control Protocol) tools from the TrustGraph system.
3
+ Removes MCP tool configurations by ID from the 'mcp' configuration group.
4
+ """
5
+
6
+ import argparse
7
+ import os
8
+ from trustgraph.api import Api, ConfigKey
9
+ import textwrap
10
+
11
+ default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
12
+
13
+ def delete_mcp_tool(
14
+ url : str,
15
+ id : str,
16
+ ):
17
+
18
+ api = Api(url).config()
19
+
20
+ # Check if the tool exists first
21
+ try:
22
+ values = api.get([
23
+ ConfigKey(type="mcp", key=id)
24
+ ])
25
+
26
+ if not values or not values[0].value:
27
+ print(f"MCP tool '{id}' not found.")
28
+ return False
29
+
30
+ except Exception as e:
31
+ print(f"MCP tool '{id}' not found.")
32
+ return False
33
+
34
+ # Delete the MCP tool configuration from the 'mcp' group
35
+ try:
36
+ api.delete([
37
+ ConfigKey(type="mcp", key=id)
38
+ ])
39
+
40
+ print(f"MCP tool '{id}' deleted successfully.")
41
+ return True
42
+
43
+ except Exception as e:
44
+ print(f"Error deleting MCP tool '{id}': {e}")
45
+ return False
46
+
47
+ def main():
48
+
49
+ parser = argparse.ArgumentParser(
50
+ prog='tg-delete-mcp-tool',
51
+ description=__doc__,
52
+ epilog=textwrap.dedent('''
53
+ This utility removes MCP tool configurations from the TrustGraph system.
54
+ Once deleted, the tool will no longer be available for use.
55
+
56
+ Examples:
57
+ %(prog)s --id weather
58
+ %(prog)s --id calculator
59
+ %(prog)s --api-url http://localhost:9000/ --id file-reader
60
+ ''').strip(),
61
+ formatter_class=argparse.RawDescriptionHelpFormatter
62
+ )
63
+
64
+ parser.add_argument(
65
+ '-u', '--api-url',
66
+ default=default_url,
67
+ help=f'API URL (default: {default_url})',
68
+ )
69
+
70
+ parser.add_argument(
71
+ '--id',
72
+ required=True,
73
+ help='MCP tool ID to delete',
74
+ )
75
+
76
+ args = parser.parse_args()
77
+
78
+ try:
79
+
80
+ if not args.id:
81
+ raise RuntimeError("Must specify --id for MCP tool to delete")
82
+
83
+ delete_mcp_tool(
84
+ url=args.api_url,
85
+ id=args.id
86
+ )
87
+
88
+ except Exception as e:
89
+
90
+ print("Exception:", e, flush=True)
91
+
92
+ if __name__ == "__main__":
93
+ main()
@@ -0,0 +1,98 @@
1
+ """
2
+ Deletes tools from the TrustGraph system.
3
+ Removes tool configurations by ID from the agent configuration
4
+ and updates the tool index accordingly.
5
+ """
6
+
7
+ import argparse
8
+ import os
9
+ from trustgraph.api import Api, ConfigKey, ConfigValue
10
+ import json
11
+ import textwrap
12
+
13
+ default_url = os.getenv("TRUSTGRAPH_URL", 'http://localhost:8088/')
14
+
15
+ def delete_tool(
16
+ url : str,
17
+ id : str,
18
+ ):
19
+
20
+ api = Api(url).config()
21
+
22
+ # Check if the tool configuration exists
23
+ try:
24
+ tool_values = api.get([
25
+ ConfigKey(type="tool", key=id)
26
+ ])
27
+
28
+ if not tool_values or not tool_values[0].value:
29
+ print(f"Tool configuration for '{id}' not found.")
30
+ return False
31
+
32
+ except Exception as e:
33
+ print(f"Tool configuration for '{id}' not found.")
34
+ return False
35
+
36
+ # Delete the tool configuration and update the index
37
+ try:
38
+
39
+ # Delete the tool configuration
40
+ api.delete([
41
+ ConfigKey(type="tool", key=id)
42
+ ])
43
+
44
+ print(f"Tool '{id}' deleted successfully.")
45
+ return True
46
+
47
+ except Exception as e:
48
+ print(f"Error deleting tool '{id}': {e}")
49
+ return False
50
+
51
+ def main():
52
+
53
+ parser = argparse.ArgumentParser(
54
+ prog='tg-delete-tool',
55
+ description=__doc__,
56
+ epilog=textwrap.dedent('''
57
+ This utility removes tool configurations from the TrustGraph system.
58
+ It removes the tool from both the tool index and deletes the tool
59
+ configuration. Once deleted, the tool will no longer be available for use.
60
+
61
+ Examples:
62
+ %(prog)s --id weather
63
+ %(prog)s --id calculator
64
+ %(prog)s --api-url http://localhost:9000/ --id file-reader
65
+ ''').strip(),
66
+ formatter_class=argparse.RawDescriptionHelpFormatter
67
+ )
68
+
69
+ parser.add_argument(
70
+ '-u', '--api-url',
71
+ default=default_url,
72
+ help=f'API URL (default: {default_url})',
73
+ )
74
+
75
+ parser.add_argument(
76
+ '--id',
77
+ required=True,
78
+ help='Tool ID to delete',
79
+ )
80
+
81
+ args = parser.parse_args()
82
+
83
+ try:
84
+
85
+ if not args.id:
86
+ raise RuntimeError("Must specify --id for tool to delete")
87
+
88
+ delete_tool(
89
+ url=args.api_url,
90
+ id=args.id
91
+ )
92
+
93
+ except Exception as e:
94
+
95
+ print("Exception:", e, flush=True)
96
+
97
+ if __name__ == "__main__":
98
+ main()
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env python3
2
-
3
1
  """
4
2
  This utility reads a knowledge core in msgpack format and outputs its
5
3
  contents in JSON form to standard output. This is useful only as a
@@ -89,5 +87,5 @@ def main():
89
87
  else:
90
88
  dump(**vars(args))
91
89
 
92
- main()
93
-
90
+ if __name__ == "__main__":
91
+ main()