pyTigerGraph-mcp 1.0.0__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.
- pytigergraph_mcp-1.0.0/LICENSE +120 -0
- pytigergraph_mcp-1.0.0/PKG-INFO +436 -0
- pytigergraph_mcp-1.0.0/README.md +401 -0
- pytigergraph_mcp-1.0.0/pyTigerGraph_mcp.egg-info/PKG-INFO +436 -0
- pytigergraph_mcp-1.0.0/pyTigerGraph_mcp.egg-info/SOURCES.txt +42 -0
- pytigergraph_mcp-1.0.0/pyTigerGraph_mcp.egg-info/dependency_links.txt +1 -0
- pytigergraph_mcp-1.0.0/pyTigerGraph_mcp.egg-info/entry_points.txt +2 -0
- pytigergraph_mcp-1.0.0/pyTigerGraph_mcp.egg-info/requires.txt +13 -0
- pytigergraph_mcp-1.0.0/pyTigerGraph_mcp.egg-info/top_level.txt +1 -0
- pytigergraph_mcp-1.0.0/pyproject.toml +49 -0
- pytigergraph_mcp-1.0.0/setup.cfg +4 -0
- pytigergraph_mcp-1.0.0/tests/test_connection_manager.py +363 -0
- pytigergraph_mcp-1.0.0/tests/test_connection_tools.py +119 -0
- pytigergraph_mcp-1.0.0/tests/test_data_tools.py +386 -0
- pytigergraph_mcp-1.0.0/tests/test_datasource_tools.py +206 -0
- pytigergraph_mcp-1.0.0/tests/test_discovery_tools.py +74 -0
- pytigergraph_mcp-1.0.0/tests/test_edge_tools.py +269 -0
- pytigergraph_mcp-1.0.0/tests/test_gsql_tools.py +117 -0
- pytigergraph_mcp-1.0.0/tests/test_node_tools.py +291 -0
- pytigergraph_mcp-1.0.0/tests/test_query_tools.py +288 -0
- pytigergraph_mcp-1.0.0/tests/test_response_formatter.py +148 -0
- pytigergraph_mcp-1.0.0/tests/test_schema_tools.py +390 -0
- pytigergraph_mcp-1.0.0/tests/test_statistics_tools.py +147 -0
- pytigergraph_mcp-1.0.0/tests/test_vector_tools.py +536 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/__init__.py +34 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/connection_manager.py +298 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/main.py +50 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/response_formatter.py +315 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/server.py +285 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/tool_metadata.py +528 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/tool_names.py +114 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/tools/__init__.py +309 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/tools/connection_tools.py +104 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/tools/data_tools.py +638 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/tools/datasource_tools.py +334 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/tools/discovery_tools.py +611 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/tools/edge_tools.py +706 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/tools/gsql_tools.py +560 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/tools/node_tools.py +1003 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/tools/query_tools.py +773 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/tools/schema_tools.py +925 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/tools/statistics_tools.py +332 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/tools/tool_registry.py +182 -0
- pytigergraph_mcp-1.0.0/tigergraph_mcp/tools/vector_tools.py +1140 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship made available under
|
|
36
|
+
the License, as indicated by a copyright notice that is included in
|
|
37
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
48
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
49
|
+
authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
+
of this definition, "submitted" means any form of electronic, verbal,
|
|
51
|
+
or written communication sent to the Licensor or its representatives,
|
|
52
|
+
including but not limited to communication on electronic mailing lists,
|
|
53
|
+
source code control systems, and issue tracking systems that are managed
|
|
54
|
+
by, or on behalf of, the Licensor for the purpose of discussing and
|
|
55
|
+
improving the Work, but excluding communication that is conspicuously
|
|
56
|
+
marked or designated in writing by the copyright owner as "Not a
|
|
57
|
+
Contribution."
|
|
58
|
+
|
|
59
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
60
|
+
whom a Contribution has been received by the Licensor and included
|
|
61
|
+
within the Work.
|
|
62
|
+
|
|
63
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
64
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
65
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
66
|
+
copyright license to reproduce, prepare Derivative Works of, publicly
|
|
67
|
+
display, publicly perform, sublicense, and distribute the Work and
|
|
68
|
+
such Derivative Works in Source or Object form.
|
|
69
|
+
|
|
70
|
+
3. Grant of Patent License. Subject to the terms and conditions of this
|
|
71
|
+
License, each Contributor hereby grants to You a perpetual, worldwide,
|
|
72
|
+
non-exclusive, no-charge, royalty-free, irrevocable patent license to
|
|
73
|
+
make, have made, use, offer to sell, sell, import, and otherwise
|
|
74
|
+
transfer the Work.
|
|
75
|
+
|
|
76
|
+
4. Redistribution. You may reproduce and distribute copies of the Work
|
|
77
|
+
or Derivative Works thereof in any medium, with or without
|
|
78
|
+
modifications, and in Source or Object form, provided that You meet
|
|
79
|
+
the following conditions:
|
|
80
|
+
|
|
81
|
+
(a) You must give any other recipients of the Work or Derivative Works
|
|
82
|
+
a copy of this License; and
|
|
83
|
+
|
|
84
|
+
(b) You must cause any modified files to carry prominent notices
|
|
85
|
+
stating that You changed the files; and
|
|
86
|
+
|
|
87
|
+
(c) You must retain, in the Source form of any Derivative Works that
|
|
88
|
+
You distribute, all copyright, patent, trademark, and attribution
|
|
89
|
+
notices from the Source form of the Work; and
|
|
90
|
+
|
|
91
|
+
(d) If the Work includes a "NOTICE" text file, include a readable copy
|
|
92
|
+
of the attribution notices contained within such NOTICE file.
|
|
93
|
+
|
|
94
|
+
5. Submission of Contributions. Any Contribution intentionally submitted
|
|
95
|
+
for inclusion in the Work shall be under the terms of this License,
|
|
96
|
+
without any additional terms or conditions.
|
|
97
|
+
|
|
98
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
99
|
+
names, trademarks, service marks, or product names of the Licensor.
|
|
100
|
+
|
|
101
|
+
7. Disclaimer of Warranty. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT
|
|
102
|
+
WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
|
|
103
|
+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
|
|
104
|
+
AND NONINFRINGEMENT.
|
|
105
|
+
|
|
106
|
+
8. Limitation of Liability. IN NO EVENT SHALL ANY CONTRIBUTOR BE LIABLE
|
|
107
|
+
FOR ANY DAMAGES.
|
|
108
|
+
|
|
109
|
+
9. Accepting Warranty or Additional Liability. While redistributing the
|
|
110
|
+
Work, You may offer support, warranty, indemnity, or other liability
|
|
111
|
+
obligations consistent with this License. However, in accepting such
|
|
112
|
+
obligations, You may offer such conditions only on Your own behalf.
|
|
113
|
+
|
|
114
|
+
Copyright 2025 TigerGraph Inc.
|
|
115
|
+
|
|
116
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
117
|
+
you may not use this file except in compliance with the License.
|
|
118
|
+
You may obtain a copy of the License at
|
|
119
|
+
|
|
120
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyTigerGraph-mcp
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Model Context Protocol (MCP) server for TigerGraph
|
|
5
|
+
Author-email: "TigerGraph Inc." <support@tigergraph.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Source, https://github.com/tigergraph/tigergraph-mcp
|
|
8
|
+
Project-URL: Bug Reports, https://github.com/tigergraph/tigergraph-mcp/issues
|
|
9
|
+
Project-URL: Documentation, https://docs.tigergraph.com/pytigergraph/current/intro/
|
|
10
|
+
Keywords: TigerGraph,MCP,Model Context Protocol,AI,Graph Database
|
|
11
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Database
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: pyTigerGraph>=2.0.1
|
|
24
|
+
Requires-Dist: mcp>=1.0.0
|
|
25
|
+
Requires-Dist: pydantic>=2.0.0
|
|
26
|
+
Requires-Dist: click
|
|
27
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
28
|
+
Provides-Extra: llm
|
|
29
|
+
Requires-Dist: langchain>=0.3.0; extra == "llm"
|
|
30
|
+
Requires-Dist: langchain-core>=0.3.0; extra == "llm"
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# pyTigerGraph-mcp
|
|
37
|
+
|
|
38
|
+
Model Context Protocol (MCP) server for TigerGraph — lets AI agents interact with TigerGraph through the MCP standard. All tools use pyTigerGraph's async APIs for optimal performance.
|
|
39
|
+
|
|
40
|
+
## Table of Contents
|
|
41
|
+
|
|
42
|
+
- [Requirements](#requirements)
|
|
43
|
+
- [Installation](#installation)
|
|
44
|
+
- [Getting Started](#getting-started)
|
|
45
|
+
- [Usage](#usage)
|
|
46
|
+
- [Running the MCP Server](#running-the-mcp-server)
|
|
47
|
+
- [Configuration](#configuration)
|
|
48
|
+
- [Multiple Connection Profiles](#multiple-connection-profiles)
|
|
49
|
+
- [Using with Existing Connection](#using-with-existing-connection)
|
|
50
|
+
- [Client Examples](#client-examples)
|
|
51
|
+
- [Using MultiServerMCPClient](#using-multiserverMCPclient)
|
|
52
|
+
- [Using MCP Client SDK Directly](#using-mcp-client-sdk-directly)
|
|
53
|
+
- [Available Tools](#available-tools)
|
|
54
|
+
- [LLM-Friendly Features](#llm-friendly-features)
|
|
55
|
+
- [Structured Responses](#structured-responses)
|
|
56
|
+
- [Rich Tool Descriptions](#rich-tool-descriptions)
|
|
57
|
+
- [Token Optimization](#token-optimization)
|
|
58
|
+
- [Tool Discovery](#tool-discovery)
|
|
59
|
+
- [Notes](#notes)
|
|
60
|
+
|
|
61
|
+
## Requirements
|
|
62
|
+
|
|
63
|
+
- **Python 3.10, 3.11, or 3.12**
|
|
64
|
+
- **TigerGraph 4.1 or later** — Install from the [TigerGraph Downloads page](https://dl.tigergraph.com/) or use [TigerGraph Savanna](https://savanna.tgcloud.io/) for a managed cloud instance.
|
|
65
|
+
|
|
66
|
+
> **Recommended: TigerGraph 4.2+** to enable TigerVector and advanced hybrid retrieval features.
|
|
67
|
+
|
|
68
|
+
## Installation
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pip install pyTigerGraph-mcp
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This installs:
|
|
75
|
+
- `pyTigerGraph>=2.0.1` — the TigerGraph Python SDK
|
|
76
|
+
- `mcp>=1.0.0` — the MCP SDK
|
|
77
|
+
- `pydantic>=2.0.0` — for data validation
|
|
78
|
+
- `click` — for the CLI entry point
|
|
79
|
+
- `python-dotenv>=1.0.0` — for loading `.env` files
|
|
80
|
+
|
|
81
|
+
To enable the `tigergraph__generate_gsql` and `tigergraph__generate_cypher` tools (LLM-powered query generation):
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install "pyTigerGraph-mcp[llm]"
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
> **Migrating from `pyTigerGraph[mcp]`?** `pip install pyTigerGraph[mcp]` now installs `pyTigerGraph-mcp` automatically. Update your imports from `pyTigerGraph.mcp` to `tigergraph_mcp`.
|
|
88
|
+
|
|
89
|
+
## Getting Started
|
|
90
|
+
|
|
91
|
+
TigerGraph-MCP supports multiple AI agent frameworks. Choose the one that fits your workflow:
|
|
92
|
+
|
|
93
|
+
### LangGraph (Recommended)
|
|
94
|
+
|
|
95
|
+
LangGraph is ideal for building stateful, agent-based workflows with complex tool chaining. Setup guide and full chatbot example:
|
|
96
|
+
|
|
97
|
+
- [LangGraph Setup](docs/langgraph_setup.md)
|
|
98
|
+
- [Chatbot example code](examples/chatbot_langgraph/)
|
|
99
|
+
- [Example transcripts](docs/chatbot_langgraph_examples/)
|
|
100
|
+
|
|
101
|
+
### CrewAI
|
|
102
|
+
|
|
103
|
+
CrewAI provides a simpler starting point for basic agentic workflows with a web-based UI:
|
|
104
|
+
|
|
105
|
+
- [CrewAI Setup](docs/crewai_setup.md)
|
|
106
|
+
- [Chatbot example code](examples/chatbot_crewai/)
|
|
107
|
+
|
|
108
|
+
### GitHub Copilot Chat (VS Code)
|
|
109
|
+
|
|
110
|
+
For quick tasks or straightforward tool invocations directly in your editor:
|
|
111
|
+
|
|
112
|
+
- [Copilot Chat Setup](docs/copilot_setup.md)
|
|
113
|
+
|
|
114
|
+
## Usage
|
|
115
|
+
|
|
116
|
+
### Running the MCP Server
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
tigergraph-mcp
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
With a custom `.env` file:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
tigergraph-mcp --env-file /path/to/.env
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
With verbose logging:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
tigergraph-mcp -v # INFO level
|
|
132
|
+
tigergraph-mcp -vv # DEBUG level
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Or programmatically:
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
from tigergraph_mcp import serve
|
|
139
|
+
import asyncio
|
|
140
|
+
|
|
141
|
+
asyncio.run(serve())
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Configuration
|
|
145
|
+
|
|
146
|
+
The MCP server reads connection configuration from environment variables. You can set these either directly or in a `.env` file.
|
|
147
|
+
|
|
148
|
+
#### Using a .env File (Recommended)
|
|
149
|
+
|
|
150
|
+
Create a `.env` file in your project directory:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# .env — Username/Password authentication
|
|
154
|
+
TG_HOST=http://localhost
|
|
155
|
+
TG_GRAPHNAME=MyGraph # Optional — can be omitted if the database has multiple graphs
|
|
156
|
+
TG_USERNAME=tigergraph
|
|
157
|
+
TG_PASSWORD=tigergraph
|
|
158
|
+
TG_RESTPP_PORT=9000
|
|
159
|
+
TG_GS_PORT=14240
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Or use an API token instead of username/password:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# .env — API Token authentication
|
|
166
|
+
TG_HOST=http://localhost
|
|
167
|
+
TG_GRAPHNAME=MyGraph
|
|
168
|
+
TG_API_TOKEN=your_api_token_here
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
When `TG_API_TOKEN` (or `TG_JWT_TOKEN`) is set, the server uses token-based authentication (`Authorization: Bearer <token>`) and ignores username/password. You can obtain a token via `pyTigerGraph`'s `getToken()` method or from the TigerGraph Admin Portal.
|
|
172
|
+
|
|
173
|
+
The server loads the `.env` file automatically. Environment variables take precedence over `.env` values.
|
|
174
|
+
|
|
175
|
+
#### Environment Variables
|
|
176
|
+
|
|
177
|
+
| Variable | Default | Description |
|
|
178
|
+
|---|---|---|
|
|
179
|
+
| `TG_HOST` | `http://127.0.0.1` | TigerGraph host |
|
|
180
|
+
| `TG_GRAPHNAME` | _(empty)_ | Graph name (optional) |
|
|
181
|
+
| `TG_USERNAME` | `tigergraph` | Username |
|
|
182
|
+
| `TG_PASSWORD` | `tigergraph` | Password |
|
|
183
|
+
| `TG_SECRET` | _(empty)_ | GSQL secret (optional) |
|
|
184
|
+
| `TG_API_TOKEN` | _(empty)_ | API token (optional) |
|
|
185
|
+
| `TG_JWT_TOKEN` | _(empty)_ | JWT token (optional) |
|
|
186
|
+
| `TG_RESTPP_PORT` | `9000` | REST++ port |
|
|
187
|
+
| `TG_GS_PORT` | `14240` | GSQL port |
|
|
188
|
+
| `TG_SSL_PORT` | `443` | SSL port |
|
|
189
|
+
| `TG_TGCLOUD` | `false` | Whether using TigerGraph Cloud |
|
|
190
|
+
| `TG_CERT_PATH` | _(empty)_ | Path to certificate (optional) |
|
|
191
|
+
|
|
192
|
+
### Multiple Connection Profiles
|
|
193
|
+
|
|
194
|
+
Define named profiles in your `.env` to work with multiple TigerGraph environments without changing any code.
|
|
195
|
+
|
|
196
|
+
#### Defining profiles
|
|
197
|
+
|
|
198
|
+
Each named profile uses a `<PROFILE>_` prefix on the standard `TG_*` variables. Only variables that differ from the default need to be set.
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# .env
|
|
202
|
+
|
|
203
|
+
# Default profile (no prefix) — password auth
|
|
204
|
+
TG_HOST=http://localhost
|
|
205
|
+
TG_USERNAME=tigergraph
|
|
206
|
+
TG_PASSWORD=tigergraph
|
|
207
|
+
TG_GRAPHNAME=MyGraph
|
|
208
|
+
|
|
209
|
+
# Staging profile — token auth
|
|
210
|
+
STAGING_TG_HOST=https://staging.example.com
|
|
211
|
+
STAGING_TG_API_TOKEN=staging_token_here
|
|
212
|
+
STAGING_TG_TGCLOUD=true
|
|
213
|
+
|
|
214
|
+
# Production profile — password auth
|
|
215
|
+
PROD_TG_HOST=https://prod.example.com
|
|
216
|
+
PROD_TG_USERNAME=admin
|
|
217
|
+
PROD_TG_PASSWORD=prod_secret
|
|
218
|
+
PROD_TG_GRAPHNAME=ProdGraph
|
|
219
|
+
PROD_TG_TGCLOUD=true
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Profiles are discovered automatically at startup. Any variable matching `<PROFILE>_TG_HOST` registers a new profile. Values not set for a named profile fall back to the default profile's values.
|
|
223
|
+
|
|
224
|
+
#### Selecting the active profile
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# Switch to staging for this run
|
|
228
|
+
TG_PROFILE=staging tigergraph-mcp
|
|
229
|
+
|
|
230
|
+
# Or set permanently in .env
|
|
231
|
+
TG_PROFILE=prod
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
If `TG_PROFILE` is not set, the default profile is used.
|
|
235
|
+
|
|
236
|
+
### Using with Existing Connection
|
|
237
|
+
|
|
238
|
+
```python
|
|
239
|
+
from pyTigerGraph import AsyncTigerGraphConnection
|
|
240
|
+
from tigergraph_mcp import ConnectionManager
|
|
241
|
+
|
|
242
|
+
async with AsyncTigerGraphConnection(
|
|
243
|
+
host="http://localhost",
|
|
244
|
+
graphname="MyGraph",
|
|
245
|
+
username="tigergraph",
|
|
246
|
+
password="tigergraph",
|
|
247
|
+
) as conn:
|
|
248
|
+
ConnectionManager.set_default_connection(conn)
|
|
249
|
+
# ... run MCP tools ...
|
|
250
|
+
# HTTP connection pool is released on exit
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
## Client Examples
|
|
254
|
+
|
|
255
|
+
### Using MultiServerMCPClient
|
|
256
|
+
|
|
257
|
+
```python
|
|
258
|
+
from langchain_mcp_adapters import MultiServerMCPClient
|
|
259
|
+
from pathlib import Path
|
|
260
|
+
from dotenv import dotenv_values
|
|
261
|
+
import asyncio
|
|
262
|
+
|
|
263
|
+
env_dict = dotenv_values(dotenv_path=Path(".env").expanduser().resolve())
|
|
264
|
+
|
|
265
|
+
client = MultiServerMCPClient(
|
|
266
|
+
{
|
|
267
|
+
"tigergraph-mcp-server": {
|
|
268
|
+
"transport": "stdio",
|
|
269
|
+
"command": "tigergraph-mcp",
|
|
270
|
+
"args": ["-vv"],
|
|
271
|
+
"env": env_dict,
|
|
272
|
+
},
|
|
273
|
+
}
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
tools = asyncio.run(client.get_tools())
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Using MCP Client SDK Directly
|
|
280
|
+
|
|
281
|
+
```python
|
|
282
|
+
import asyncio
|
|
283
|
+
from mcp import ClientSession, StdioServerParameters
|
|
284
|
+
from mcp.client.stdio import stdio_client
|
|
285
|
+
|
|
286
|
+
async def call_tool():
|
|
287
|
+
server_params = StdioServerParameters(
|
|
288
|
+
command="tigergraph-mcp",
|
|
289
|
+
args=["-vv"],
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
async with stdio_client(server_params) as (read, write):
|
|
293
|
+
async with ClientSession(read, write) as session:
|
|
294
|
+
await session.initialize()
|
|
295
|
+
|
|
296
|
+
tools = await session.list_tools()
|
|
297
|
+
print(f"Available tools: {[t.name for t in tools.tools]}")
|
|
298
|
+
|
|
299
|
+
result = await session.call_tool(
|
|
300
|
+
"tigergraph__list_graphs",
|
|
301
|
+
arguments={}
|
|
302
|
+
)
|
|
303
|
+
for content in result.content:
|
|
304
|
+
print(content.text)
|
|
305
|
+
|
|
306
|
+
asyncio.run(call_tool())
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Available Tools
|
|
310
|
+
|
|
311
|
+
### Global Schema Operations
|
|
312
|
+
- `tigergraph__get_global_schema` — Get the complete global schema via GSQL `LS`
|
|
313
|
+
|
|
314
|
+
### Graph Operations
|
|
315
|
+
- `tigergraph__list_graphs` — List all graph names in the database
|
|
316
|
+
- `tigergraph__create_graph` — Create a new graph with schema
|
|
317
|
+
- `tigergraph__drop_graph` — Drop a graph and its schema
|
|
318
|
+
- `tigergraph__clear_graph_data` — Clear all data from a graph (keeps schema)
|
|
319
|
+
|
|
320
|
+
### Schema Operations
|
|
321
|
+
- `tigergraph__get_graph_schema` — Get schema as structured JSON
|
|
322
|
+
- `tigergraph__show_graph_details` — Show schema, queries, loading jobs, and data sources
|
|
323
|
+
|
|
324
|
+
### Node Operations
|
|
325
|
+
- `tigergraph__add_node` / `tigergraph__add_nodes`
|
|
326
|
+
- `tigergraph__get_node` / `tigergraph__get_nodes`
|
|
327
|
+
- `tigergraph__delete_node` / `tigergraph__delete_nodes`
|
|
328
|
+
- `tigergraph__has_node`
|
|
329
|
+
- `tigergraph__get_node_edges`
|
|
330
|
+
|
|
331
|
+
### Edge Operations
|
|
332
|
+
- `tigergraph__add_edge` / `tigergraph__add_edges`
|
|
333
|
+
- `tigergraph__get_edge` / `tigergraph__get_edges`
|
|
334
|
+
- `tigergraph__delete_edge` / `tigergraph__delete_edges`
|
|
335
|
+
- `tigergraph__has_edge`
|
|
336
|
+
|
|
337
|
+
### Query Operations
|
|
338
|
+
- `tigergraph__run_query` — Run an interpreted query
|
|
339
|
+
- `tigergraph__run_installed_query` — Run an installed query
|
|
340
|
+
- `tigergraph__install_query` / `tigergraph__drop_query`
|
|
341
|
+
- `tigergraph__show_query` / `tigergraph__get_query_metadata` / `tigergraph__is_query_installed`
|
|
342
|
+
- `tigergraph__get_neighbors`
|
|
343
|
+
|
|
344
|
+
### Loading Job Operations
|
|
345
|
+
- `tigergraph__create_loading_job`
|
|
346
|
+
- `tigergraph__run_loading_job_with_file` / `tigergraph__run_loading_job_with_data`
|
|
347
|
+
- `tigergraph__get_loading_jobs` / `tigergraph__get_loading_job_status`
|
|
348
|
+
- `tigergraph__drop_loading_job`
|
|
349
|
+
|
|
350
|
+
### Statistics Operations
|
|
351
|
+
- `tigergraph__get_vertex_count` / `tigergraph__get_edge_count`
|
|
352
|
+
- `tigergraph__get_node_degree`
|
|
353
|
+
|
|
354
|
+
### GSQL Operations
|
|
355
|
+
- `tigergraph__gsql` — Execute raw GSQL
|
|
356
|
+
- `tigergraph__generate_gsql` — Generate GSQL from natural language (requires `[llm]`)
|
|
357
|
+
- `tigergraph__generate_cypher` — Generate openCypher from natural language (requires `[llm]`)
|
|
358
|
+
|
|
359
|
+
### Vector Schema Operations
|
|
360
|
+
- `tigergraph__add_vector_attribute` / `tigergraph__drop_vector_attribute`
|
|
361
|
+
- `tigergraph__list_vector_attributes` / `tigergraph__get_vector_index_status`
|
|
362
|
+
|
|
363
|
+
### Vector Data Operations
|
|
364
|
+
- `tigergraph__upsert_vectors`
|
|
365
|
+
- `tigergraph__load_vectors_from_csv` / `tigergraph__load_vectors_from_json`
|
|
366
|
+
- `tigergraph__search_top_k_similarity` / `tigergraph__fetch_vector`
|
|
367
|
+
|
|
368
|
+
### Data Source Operations
|
|
369
|
+
- `tigergraph__create_data_source` / `tigergraph__update_data_source`
|
|
370
|
+
- `tigergraph__get_data_source` / `tigergraph__drop_data_source`
|
|
371
|
+
- `tigergraph__get_all_data_sources` / `tigergraph__drop_all_data_sources`
|
|
372
|
+
- `tigergraph__preview_sample_data`
|
|
373
|
+
|
|
374
|
+
### Discovery & Navigation
|
|
375
|
+
- `tigergraph__discover_tools` — Search for tools by description or keywords
|
|
376
|
+
- `tigergraph__get_workflow` — Get step-by-step workflow templates
|
|
377
|
+
- `tigergraph__get_tool_info` — Get detailed information about a specific tool
|
|
378
|
+
|
|
379
|
+
## LLM-Friendly Features
|
|
380
|
+
|
|
381
|
+
### Structured Responses
|
|
382
|
+
|
|
383
|
+
Every tool returns a consistent JSON structure:
|
|
384
|
+
|
|
385
|
+
```json
|
|
386
|
+
{
|
|
387
|
+
"success": true,
|
|
388
|
+
"operation": "get_node",
|
|
389
|
+
"summary": "Found vertex 'p123' of type 'Person'",
|
|
390
|
+
"data": { ... },
|
|
391
|
+
"suggestions": ["View connected edges: get_node_edges(...)"],
|
|
392
|
+
"metadata": { "graph_name": "MyGraph" }
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
Error responses include actionable recovery hints:
|
|
397
|
+
|
|
398
|
+
```json
|
|
399
|
+
{
|
|
400
|
+
"success": false,
|
|
401
|
+
"operation": "get_node",
|
|
402
|
+
"error": "Vertex not found",
|
|
403
|
+
"suggestions": ["Verify the vertex_id is correct"]
|
|
404
|
+
}
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### Rich Tool Descriptions
|
|
408
|
+
|
|
409
|
+
Each tool includes detailed descriptions with use cases, common workflows, tips, warnings, and related tools.
|
|
410
|
+
|
|
411
|
+
### Token Optimization
|
|
412
|
+
|
|
413
|
+
Responses are designed for efficient LLM token usage — no echoing of input parameters, only new information (results, counts, boolean answers).
|
|
414
|
+
|
|
415
|
+
### Tool Discovery
|
|
416
|
+
|
|
417
|
+
```python
|
|
418
|
+
# Find the right tool
|
|
419
|
+
result = await session.call_tool("tigergraph__discover_tools",
|
|
420
|
+
arguments={"query": "how to add data to the graph"})
|
|
421
|
+
|
|
422
|
+
# Get a workflow template
|
|
423
|
+
result = await session.call_tool("tigergraph__get_workflow",
|
|
424
|
+
arguments={"workflow_type": "data_loading"})
|
|
425
|
+
|
|
426
|
+
# Get detailed tool info
|
|
427
|
+
result = await session.call_tool("tigergraph__get_tool_info",
|
|
428
|
+
arguments={"tool_name": "tigergraph__add_node"})
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
## Notes
|
|
432
|
+
|
|
433
|
+
- **Transport**: stdio by default
|
|
434
|
+
- **Error Detection**: GSQL operations include error detection for syntax and semantic errors
|
|
435
|
+
- **Connection Management**: Connections are pooled by profile and reused across requests; pool is released at server shutdown
|
|
436
|
+
- **Performance**: Persistent HTTP connection pool per profile; async non-blocking I/O; `v.outdegree()` for O(1) degree counting; batch operations for multiple vertices/edges
|