-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathconfig.example-payload-threshold.toml
More file actions
80 lines (73 loc) · 3.11 KB
/
config.example-payload-threshold.toml
File metadata and controls
80 lines (73 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Example MCP Gateway Configuration with Payload Size Threshold
# This demonstrates the configurable payload size threshold feature
#
# Configuration Priority (highest to lowest):
# 1. Command-line flag: --payload-size-threshold 2048
# 2. Environment variable: MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD=2048
# 3. Config file: payload_size_threshold = 2048
# 4. Default: 524288 bytes (512KB)
[gateway]
port = 3000
api_key = "your-api-key-here"
# Payload directory for storing large tool responses
# Can also be set via:
# - Flag: --payload-dir /custom/path
# - Env: MCP_GATEWAY_PAYLOAD_DIR=/custom/path
# Default: /tmp/jq-payloads
payload_dir = "/tmp/jq-payloads"
# Payload path prefix for remapping file paths returned to clients
# When set, payloadPath uses this prefix instead of the actual filesystem path
# This allows agents in containers to access payload files via mounted volumes
#
# Can also be set via:
# - Flag: --payload-path-prefix /workspace/payloads
# - Env: MCP_GATEWAY_PAYLOAD_PATH_PREFIX=/workspace/payloads
# Default: (empty - use actual filesystem path)
#
# Example:
# Gateway saves to: /tmp/jq-payloads/session123/query456/payload.json
# Returns to client: /workspace/payloads/session123/query456/payload.json
# Agent mounts: -v /tmp/jq-payloads:/workspace/payloads
# payload_path_prefix = "/workspace/payloads"
# Payload size threshold (in bytes) for storing responses to disk
# Payloads LARGER than this threshold are stored to disk and return metadata
# Payloads SMALLER than or equal to this threshold are returned inline
#
# Can also be set via:
# - Flag: --payload-size-threshold 2048
# - Env: MCP_GATEWAY_PAYLOAD_SIZE_THRESHOLD=2048
# Default: 524288 bytes (512KB)
#
# Examples:
# payload_size_threshold = 262144 # 256KB - more aggressive file storage
# payload_size_threshold = 524288 # 512KB - default, balances inline vs disk storage
# payload_size_threshold = 1048576 # 1MB - minimize disk storage for most use cases
payload_size_threshold = 524288
[servers.github]
command = "docker"
args = ["run", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "-i", "ghcr.io/github/github-mcp-server:latest"]
[servers.filesystem]
command = "docker"
args = ["run", "--rm", "-i", "ghcr.io/github/filesystem-mcp-server:latest"]
# How it works:
#
# 1. Tool returns response data
# 2. Middleware marshals data to JSON
# 3. If JSON size <= payload_size_threshold:
# - Return response inline (no file storage)
# - Original data preserved
# 4. If JSON size > payload_size_threshold:
# - Save full payload to {payload_dir}/{sessionID}/{queryID}/payload.json
# - Return metadata response with:
# * queryID: unique query identifier
# * payloadPath: full path to saved file
# * preview: first 500 characters
# * schema: jq-inferred schema of the data
# * originalSize: size in bytes
# * truncated: whether preview was truncated
#
# Benefits:
# - Small responses (errors, status messages, simple data) are fast and inline
# - Large responses (file contents, lists, search results) are saved to disk
# - Clients can access full payloads via filesystem when needed
# - Reduces memory pressure and network overhead