Skip to content

Commit f40f92d

Browse files
committed
GML-2026 add mcp tool support
1 parent 84bdf20 commit f40f92d

36 files changed

Lines changed: 8311 additions & 62 deletions

pyTigerGraph/__init__.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22
from pyTigerGraph.pytgasync.pyTigerGraph import AsyncTigerGraphConnection
33
from pyTigerGraph.common.exception import TigerGraphException
44

5-
__version__ = "1.9.1"
5+
__version__ = "2.0.0"
66

77
__license__ = "Apache 2"
8+
9+
# Optional MCP support
10+
try:
11+
from pyTigerGraph.mcp import serve, MCPServer, get_connection, ConnectionManager
12+
__all__ = [
13+
"TigerGraphConnection",
14+
"AsyncTigerGraphConnection",
15+
"TigerGraphException",
16+
"serve",
17+
"MCPServer",
18+
"get_connection",
19+
"ConnectionManager",
20+
]
21+
except ImportError:
22+
# MCP dependencies not installed
23+
__all__ = [
24+
"TigerGraphConnection",
25+
"AsyncTigerGraphConnection",
26+
"TigerGraphException",
27+
]

pyTigerGraph/common/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def __init__(self, host: str = "http://127.0.0.1", graphname: str = "",
179179
else:
180180
self.restppPort = restppPort
181181
self.restppUrl = self.host + ":" + self.restppPort
182-
182+
183183
self.gsPort = gsPort
184184
if self.tgCloud and (gsPort == "14240" or gsPort == "443"):
185185
self.gsPort = sslPort
@@ -375,7 +375,7 @@ def customizeHeader(self, timeout: int = 16_000, responseSize: int = 3.2e+7):
375375
"""
376376
self.responseConfigHeader = {
377377
"GSQL-TIMEOUT": str(timeout), "RESPONSE-LIMIT": str(responseSize)}
378-
378+
379379
def _parse_get_ver(self, version, component, full):
380380
ret = ""
381381
for v in version:

pyTigerGraph/common/loading.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def _prep_run_loading_job(gsUrl: str,
4949
'''url builder for runLoadingJob()'''
5050
url = gsUrl + "/gsql/v1/loading-jobs/run?graph=" + graphname
5151
data = {}
52-
52+
5353
data["name"] = jobName
5454
data["dataSources"] = [data_source_config]
5555

@@ -65,7 +65,7 @@ def _prep_run_loading_job(gsUrl: str,
6565
data["maxNumError"] = maxNumError
6666
if maxPercentError:
6767
data["maxPercentError"] = maxPercentError
68-
68+
6969
return url, data
7070

7171
def _prep_abort_loading_jobs(gsUrl: str, graphname: str, jobIds: list[str], pauseJob: bool):

pyTigerGraph/gds/dataloaders.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ def _read_data(
676676
logger.error("Error parsing data: {}".format(raw))
677677
logger.error("Parameters:\n in_format={}\n out_format={}\n v_in_feats={}\n v_out_labels={}\n v_extra_feats={}\n v_attr_types={}\n e_in_feats={}\n e_out_labels={}\n e_extra_feats={}\n e_attr_types={}\n delimiter={}\n".format(
678678
in_format, out_format, v_in_feats, v_out_labels, v_extra_feats, v_attr_types, e_in_feats, e_out_labels, e_extra_feats, e_attr_types, delimiter))
679-
679+
680680
in_q.task_done()
681681

682682
@staticmethod
@@ -766,7 +766,7 @@ def add_attributes(attr_names: list, attr_types: dict, attr_df: pd.DataFrame,
766766
data = graph.ndata
767767

768768
data[feat_name] = attr_to_tensor(attr_names, attr_types, attr_df)
769-
769+
770770
def add_sep_attr(attr_names: list, attr_types: dict, attr_df: pd.DataFrame,
771771
graph, is_hetero: bool, mode: str,
772772
target: 'Literal["edge", "vertex"]', vetype: str = None) -> None:
@@ -864,7 +864,7 @@ def add_sep_attr(attr_names: list, attr_types: dict, attr_df: pd.DataFrame,
864864
)
865865
elif mode == "spektral":
866866
data[col] = attr_df[col].astype(dtype)
867-
867+
868868
# Read in vertex and edge CSVs as dataframes
869869
vertices, edges = None, None
870870
if in_format == "vertex":
@@ -1422,7 +1422,7 @@ def _generate_attribute_string(self, schema_type, attr_names, attr_types) -> str
14221422
for attr in attr_names
14231423
)
14241424
return print_attr
1425-
1425+
14261426
def metadata(self, additional_v_types=None, additional_e_types=None) -> Tuple[list, list]:
14271427
v_types = self._vtypes
14281428
if additional_v_types:
@@ -1439,7 +1439,7 @@ def metadata(self, additional_v_types=None, additional_e_types=None) -> Tuple[li
14391439
elif isinstance(additional_e_types, tuple):
14401440
edges.append(additional_e_types)
14411441
return (v_types, edges)
1442-
1442+
14431443
def fetch(self, payload: dict) -> None:
14441444
"""Fetch the specific data instances for inference/prediction.
14451445
@@ -2478,7 +2478,7 @@ def _start(self) -> None:
24782478
self._exit_event = Event()
24792479

24802480
self._start_request(False, "vertex")
2481-
2481+
24822482
# Start reading thread.
24832483
if not self.is_hetero:
24842484
v_attr_types = next(iter(self._v_schema.values()))
@@ -3513,7 +3513,7 @@ def __init__(
35133513
for tok in self.baseTokens + ancs:
35143514
self.idToIdx[str(tok)] = self.curIdx
35153515
self.curIdx += 1
3516-
3516+
35173517
self.num_tokens = len(self.idToIdx.keys())
35183518

35193519
def saveTokens(self, filename) -> None:
@@ -3670,7 +3670,7 @@ def _start(self) -> None:
36703670
self._exit_event = Event()
36713671

36723672
self._start_request(False, "vertex")
3673-
3673+
36743674
# Start reading thread.
36753675
if not self.is_hetero:
36763676
v_attr_types = next(iter(self._v_schema.values()))
@@ -3782,7 +3782,7 @@ def precompute(self) -> None:
37823782
resp = self._graph.runInstalledQuery(
37833783
self.query_name, params=_payload, timeout=self.timeout, usePost=True
37843784
)
3785-
3785+
37863786

37873787
class HGTLoader(BaseLoader):
37883788
"""HGTLoader

pyTigerGraph/gds/gds.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __init__(self, conn: "TigerGraphConnection") -> None:
4646
Args:
4747
conn (TigerGraphConnection):
4848
Accept a TigerGraphConnection to run queries with
49-
49+
5050
Returns:
5151
None
5252
"""
@@ -231,7 +231,7 @@ def neighborLoader(
231231
If specify both parameters, `batch_size` takes priority.
232232
. It picks a specified number (`num_neighbors`) of neighbors of each seed at random.
233233
. It picks the same number of neighbors for each neighbor, and repeats this process until it finished performing a specified number of hops (`num_hops`).
234-
234+
235235
This generates one subgraph.
236236
As you loop through this data loader, every vertex will at some point be chosen as a seed and you will get the subgraph
237237
expanded from the seeds.
@@ -949,7 +949,7 @@ def edgeNeighborLoader(
949949
If specify both parameters, `batch_size` takes priority.
950950
. Starting from the vertices attached to the seed edges, it picks a specified number (`num_neighbors`) of neighbors of each vertex at random.
951951
. It picks the same number of neighbors for each neighbor, and repeats this process until it finished performing a specified number of hops (`num_hops`).
952-
952+
953953
This generates one subgraph.
954954
As you loop through this data loader, every edge will at some point be chosen as a seed and you will get the subgraph
955955
expanded from the seeds.
@@ -1379,7 +1379,7 @@ def hgtLoader(
13791379
If specify both parameters, `batch_size` takes priority.
13801380
. It picks a specified number of neighbors of each type (as specified by the dict `num_neighbors`) of each seed at random.
13811381
. It picks the specified number of neighbors of every type for each neighbor, and repeats this process until it finished performing a specified number of hops (`num_hops`).
1382-
1382+
13831383
This generates one subgraph.
13841384
As you loop through this data loader, every vertex will at some point be chosen as a seed and you will get the subgraph
13851385
expanded from the seeds.
@@ -1565,7 +1565,7 @@ def hgtLoader(
15651565
if reinstall_query:
15661566
loader.reinstall_query()
15671567
return loader
1568-
1568+
15691569
def featurizer(
15701570
self,
15711571
repo: str = None,
@@ -1650,7 +1650,7 @@ def edgeSplitter(self, e_types: List[str] = None, timeout: int = 600000, **split
16501650
Make sure to create the appropriate attributes in the graph before using these functions.
16511651
16521652
Usage:
1653-
1653+
16541654
* A random 60% of edges will have their attribute "attr_name" set to True, and
16551655
others False. `attr_name` can be any attribute that exists in the database (same below).
16561656
Example:

pyTigerGraph/gds/splitters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class RandomVertexSplitter(BaseRandomSplitter):
142142
v_types (List[str], optional):
143143
List of vertex types to split. If not provided, all vertex types are used.
144144
timeout (int, optional):
145-
Timeout value for the operation. Defaults to 600000.
145+
Timeout value for the operation in milliseconds. Defaults to 600000 (10 minutes).
146146
"""
147147

148148
def __init__(
@@ -229,7 +229,7 @@ class RandomEdgeSplitter(BaseRandomSplitter):
229229
e_types (List[str], optional):
230230
List of edge types to split. If not provided, all edge types are used.
231231
timeout (int, optional):
232-
Timeout value for the operation. Defaults to 600000.
232+
Timeout value for the operation in milliseconds. Defaults to 600000 (10 minutes).
233233
"""
234234

235235
def __init__(

0 commit comments

Comments
 (0)