You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Each thread gets its own `requests.Session` backed by a private connection pool. This eliminates the `_cookies_lock` contention that a shared session causes under concurrent load.
144
-
- Install `pyTigerGraph[fast]` to activate the `orjson` backend and significantly reduce GIL contention between threads during JSON parsing.
143
+
- Each thread gets its own dedicated HTTP session and connection pool, so concurrent threads never block each other.
144
+
- Install `pyTigerGraph[fast]` to activate the `orjson` backend and reduce JSON parsing overhead under concurrent load.
145
145
- Use `ThreadPoolExecutor` to run queries in parallel:
146
146
147
147
```python
148
148
from concurrent.futures import ThreadPoolExecutor, as_completed
149
149
150
150
with TigerGraphConnection(...) as conn:
151
151
with ThreadPoolExecutor(max_workers=16) as executor:
152
-
futures ={executor.submit(conn.runInstalledQuery, "q", {"p": v}): v for v in values}
152
+
futures =[executor.submit(conn.runInstalledQuery, "q", {"p": v})for v in values]
The server will automatically load the `.env` file if it exists. Environment variables take precedence over `.env` file values.
@@ -104,7 +104,52 @@ The following environment variables are supported:
104
104
-`TG_SSL_PORT` - SSL port (default: 443)
105
105
-`TG_TGCLOUD` - Whether using TigerGraph Cloud (default: False)
106
106
-`TG_CERT_PATH` - Path to certificate (optional)
107
-
-`TG_CONN_LIMIT` - Max keep-alive HTTP connections in the async client pool (default: 10). Should be ≥ the number of concurrent MCP tool calls you expect. Named profiles use `<PROFILE>_TG_CONN_LIMIT`.
107
+
108
+
### Multiple Connection Profiles
109
+
110
+
If you work with more than one TigerGraph environment — for example, development, staging, and production — you can define named profiles in your `.env` file and switch between them without changing any code.
111
+
112
+
#### Defining profiles
113
+
114
+
Each named profile uses a `<PROFILE>_` prefix on the standard `TG_*` variables. Only the variables that differ from the default need to be set.
115
+
116
+
```bash
117
+
# .env
118
+
119
+
# Default profile (no prefix) — used when TG_PROFILE is not set
120
+
TG_HOST=http://localhost
121
+
TG_USERNAME=tigergraph
122
+
TG_PASSWORD=tigergraph
123
+
TG_GRAPHNAME=MyGraph
124
+
125
+
# Staging profile
126
+
STAGING_TG_HOST=https://staging.example.com
127
+
STAGING_TG_PASSWORD=staging_secret
128
+
STAGING_TG_TGCLOUD=true
129
+
130
+
# Production profile
131
+
PROD_TG_HOST=https://prod.example.com
132
+
PROD_TG_USERNAME=admin
133
+
PROD_TG_PASSWORD=prod_secret
134
+
PROD_TG_GRAPHNAME=ProdGraph
135
+
PROD_TG_TGCLOUD=true
136
+
```
137
+
138
+
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.
139
+
140
+
#### Selecting the active profile
141
+
142
+
Pass `TG_PROFILE` as an environment variable or add it to your `.env`:
143
+
144
+
```bash
145
+
# Switch to the staging profile for this run
146
+
TG_PROFILE=staging tigergraph-mcp
147
+
148
+
# Or set it permanently in .env
149
+
TG_PROFILE=prod
150
+
```
151
+
152
+
If `TG_PROFILE` is not set, the default profile (unprefixed `TG_*` variables) is used.
108
153
109
154
### Using with Existing Connection
110
155
@@ -136,7 +181,6 @@ async with AsyncTigerGraphConnection(
136
181
graphname="MyGraph",
137
182
username="tigergraph",
138
183
password="tigergraph",
139
-
connLimit=10, # set >= number of concurrent MCP tool calls (default: 10)
140
184
) as conn:
141
185
# Set as default for MCP tools
142
186
ConnectionManager.set_default_connection(conn)
@@ -396,8 +440,8 @@ result = await session.call_tool(
396
440
397
441
-**Transport**: The MCP server uses stdio transport by default
398
442
-**Error Detection**: GSQL operations include error detection for syntax and semantic errors (since `conn.gsql()` does not raise Python exceptions for GSQL failures)
399
-
-**Connection Management**: Connections are pooled by profile — each profile's `AsyncTigerGraphConnection` holds a persistent HTTP connection pool (sized by `TG_CONN_LIMIT`, default 10). The pool is automatically released at server shutdown via `ConnectionManager.close_all()`. To adjust pool size per profile, set `<PROFILE>_TG_CONN_LIMIT`.
400
-
-**Performance**: Persistent HTTP connection pool per profile (no TCP handshake per request); async non-blocking I/O; `v.outdegree()` for O(1) degree counting; batch operations for multiple vertices/edges
443
+
-**Connection Management**: Connections are pooled by profile and reused across requests — no TCP handshake overhead per tool call. The pool is released automatically at server shutdown.
444
+
-**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
0 commit comments