Skip to content

Commit fe25322

Browse files
Merge pull request #6 from graphops/chris/configurable-timeout
feat: configurable timeout and release script
2 parents 1c46f78 + 78edae3 commit fe25322

File tree

8 files changed

+430
-7
lines changed

8 files changed

+430
-7
lines changed

Cargo.lock

Lines changed: 81 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
[package]
22
name = "subgraph-mcp"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
edition = "2021"
5-
authors = ["sahra"]
5+
authors = ["GraphOps"]
66
license = "Apache-2.0"
77

8+
[lib]
9+
name = "subgraph_mcp"
10+
path = "src/lib.rs"
11+
812
[dependencies]
913
tokio = { version = "1.44.2", features = ["full"] }
1014
reqwest = { version = "0.12.15", features = ["json"] }
@@ -26,3 +30,6 @@ http = "1.3.1"
2630
tracing = "0.1"
2731
once_cell = "1.20"
2832
prometheus-client = { version = "0.23.1" }
33+
34+
[dev-dependencies]
35+
wiremock = "0.6"

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,59 @@ For example, if `pwd` outputs `/Users/user/subgraph-mcp`, the full command path
110110

111111
After adding the configuration, restart Claude Desktop.
112112

113+
#### Request Timeout Configuration (for Local Execution)
114+
115+
The server includes configurable timeout settings for HTTP requests to The Graph's Gateway. This helps handle complex GraphQL queries that may take longer to execute.
116+
117+
**Default Behavior**
118+
119+
By default, the server uses a **120-second timeout** for all HTTP requests to The Graph's Gateway. This provides a good balance between allowing complex queries to complete while preventing indefinite hangs.
120+
121+
**Custom Timeout Configuration**
122+
123+
You can customize the timeout in several ways:
124+
125+
Option 1: Environment Variable (Recommended)
126+
127+
Set the `SUBGRAPH_REQUEST_TIMEOUT_SECONDS` environment variable:
128+
129+
```bash
130+
export SUBGRAPH_REQUEST_TIMEOUT_SECONDS=300 # 5 minutes
131+
```
132+
133+
For Claude Desktop configuration:
134+
135+
```json
136+
{
137+
"mcpServers": {
138+
"subgraph-mcp": {
139+
"command": "/path/to/subgraph-mcp",
140+
"env": {
141+
"GATEWAY_API_KEY": "YOUR_GATEWAY_API_KEY",
142+
"SUBGRAPH_REQUEST_TIMEOUT_SECONDS": "300"
143+
}
144+
}
145+
}
146+
}
147+
```
148+
149+
Option 2: Programmatic Configuration (for developers)
150+
151+
When building applications with the server library:
152+
153+
```rust
154+
use std::time::Duration;
155+
use subgraph_mcp::SubgraphServer;
156+
157+
// Use default timeout (120 seconds)
158+
let server = SubgraphServer::new();
159+
160+
// Use custom timeout
161+
let server = SubgraphServer::with_timeout(Duration::from_secs(300));
162+
```
163+
164+
**Note**: Very long timeouts (>5 minutes) should be used cautiously as they may impact overall application responsiveness.
165+
113166
**Important**: Claude Desktop may not automatically utilize server resources. To ensure proper functionality, manually add `Subgraph Server Instructions` resource to your chat context by clicking on the context menu and adding the resource.
114167

115168
## Available Tools
@@ -263,6 +316,39 @@ The following application-specific metrics are exposed:
263316

264317
Additionally, the `axum-prometheus` library provides standard HTTP request metrics for the metrics server itself (prefixed with `http_`).
265318

319+
## Troubleshooting
320+
321+
### Request Timeout Errors
322+
323+
If you encounter "Request timed out" or "MCP error -32001" errors, this typically indicates that GraphQL queries are taking longer than the configured timeout to complete.
324+
325+
**Solutions:**
326+
327+
**If you're running your own local server instance:**
328+
329+
1. **Increase the timeout** using the `SUBGRAPH_REQUEST_TIMEOUT_SECONDS` environment variable:
330+
```bash
331+
export SUBGRAPH_REQUEST_TIMEOUT_SECONDS=300 # 5 minutes
332+
```
333+
334+
**If you're using the remote hosted service:**
335+
336+
1. **Contact support** - Timeout settings are managed by the hosted service and cannot be customized by end users.
337+
338+
**For all users:**
339+
340+
2. **Check query complexity** - Very complex queries with large result sets may need longer timeouts or query optimization.
341+
342+
3. **Verify The Graph Gateway status** - Occasional timeout issues may be due to temporary Gateway performance issues.
343+
344+
**Default Timeout**: Local server instances use a 120-second timeout by default (increased from 30 seconds in earlier versions). Remote hosted service timeout settings may differ.
345+
346+
### Common Issues
347+
348+
- **"API key not found"**: Ensure your `GATEWAY_API_KEY` environment variable is set correctly
349+
- **"Configuration error"**: Check that your Gateway API key is valid and has appropriate permissions
350+
- **Connection refused**: Verify the server is running and accessible on the configured port
351+
266352
## Contributing
267353

268354
Contributions are welcome! Please feel free to submit a Pull Request.

0 commit comments

Comments
 (0)