Skip to content

Commit 22a6707

Browse files
authored
docs: reconcile env-variable semantics and server config docs with implementation (#5475)
## Bug Fix ### What was the bug? Nightly reconciliation found multiple doc/implementation mismatches: `MCP_GATEWAY_PORT/DOMAIN/API_KEY` were documented as automatic config overrides (they are not), `tool_response_filters` was undocumented, and contributor/example docs were missing or inaccurate in a few high-impact spots. ### How did you fix it? - **Environment variable behavior clarified (`AGENTS.md`)** - Updated `MCP_GATEWAY_PORT`, `MCP_GATEWAY_DOMAIN`, and `MCP_GATEWAY_API_KEY` descriptions to match actual runtime behavior (validation/container checks vs. automatic gateway field override). - Clarified `MCP_GATEWAY_PORT` vs plain `PORT` semantics in the note at the end of the environment variable section. - **Missing server field documentation added (`docs/CONFIGURATION.md`)** - Added `tool_response_filters` under server configuration fields. - Documented expected shape (`map[toolName]jqExpression`) and startup validation behavior for jq expressions. - **Configuration example coverage expanded (`config.example.toml`)** - Added commented examples for: - `tool_response_filters` - `connect_timeout` - per-server `tool_timeout` - `rate_limit_threshold` - `rate_limit_cooldown` - HTTP `auth` (`github-oidc`) - `working_directory` - `registry` - **Contributor docs corrected (`CONTRIBUTING.md`)** - Added missing direct dependency `github.com/spf13/pflag`. - Corrected project tree root label from `awmg/` to `gh-aw-mcpg/`. ### Testing Docs-only change; no production logic changes. ```toml # Example now documented in config.example.toml [servers.github.tool_response_filters] search_code = ".results[:20]" get_file_contents = "{path: .path, sha: .sha}" ```
2 parents 4d2c758 + 255bc8b commit 22a6707

4 files changed

Lines changed: 39 additions & 5 deletions

File tree

AGENTS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,9 @@ DEBUG_COLORS=0 DEBUG=* ./awmg --config config.toml
376376
- `GITHUB_SERVER_URL` - GitHub server URL; proxy auto-derives API endpoint: `*.ghe.com``copilot-api.*.ghe.com`, GHES → `<host>/api/v3`, `github.com``api.github.com`
377377
- `ACTIONS_ID_TOKEN_REQUEST_URL` - GitHub Actions OIDC token endpoint URL; required for `github-oidc` auth type
378378
- `ACTIONS_ID_TOKEN_REQUEST_TOKEN` - GitHub Actions OIDC request token; required for `github-oidc` auth type
379-
- `MCP_GATEWAY_PORT` - Gateway listen port (overrides config `port` field; validated 1-65535)
380-
- `MCP_GATEWAY_DOMAIN` - Gateway domain name (overrides config `domain` field)
381-
- `MCP_GATEWAY_API_KEY` - Gateway API key (overrides config `api_key` field)
379+
- `MCP_GATEWAY_PORT` - Used by environment validation (`--validate-env`) for container port-mapping checks (validated 1-65535); does not override the gateway listen address
380+
- `MCP_GATEWAY_DOMAIN` - Used by environment validation (`--validate-env`) and containerized startup checks; to set config values use `gateway.domain` (or `"${MCP_GATEWAY_DOMAIN}"` in JSON stdin config)
381+
- `MCP_GATEWAY_API_KEY` - Used by environment validation (`--validate-env`) and containerized startup checks; to enable auth set `gateway.apiKey` (commonly `"${MCP_GATEWAY_API_KEY}"` in JSON stdin config)
382382
- `DEBUG` - Enable debug logging (e.g., `DEBUG=*`, `DEBUG=server:*,launcher:*`)
383383
- `DEBUG_COLORS` - Control colored output (0 to disable, auto-disabled when piping)
384384
- `MCP_GATEWAY_LOG_DIR` - Log file directory (sets default for `--log-dir` flag, default: `/tmp/gh-aw/mcp-logs`)
@@ -403,7 +403,7 @@ DEBUG_COLORS=0 DEBUG=* ./awmg --config config.toml
403403
- `MCP_GATEWAY_HMAC_SECRET` - Shared HMAC-SHA256 secret for request signing and replay protection; when set, requests to MCP handlers must carry valid `X-MCP-Timestamp`, `X-MCP-Nonce`, and `X-MCP-Signature` headers (sets default for `--hmac-secret`)
404404
- `RUNNING_IN_CONTAINER` - Set to `"true"` to force container detection when `/.dockerenv` and cgroup detection are unavailable
405405

406-
**Note:** `PORT`, `HOST`, and `MODE` are not read by the `awmg` binary directly. However, `run.sh` does use `HOST` (default: `0.0.0.0`) and `MODE` (default: `--routed`) to set the bind address and routing mode. Use the `--listen` and `--routed`/`--unified` flags when running `awmg` directly.
406+
**Note:** `MCP_GATEWAY_PORT` is read by the `awmg` binary for environment validation (`--validate-env`) only. Plain `PORT`, `HOST`, and `MODE` are not read by `awmg` directly. However, `run.sh` uses `PORT`, `HOST` (default: `0.0.0.0`), and `MODE` (default: `--routed`) to set the bind address and routing mode. Use the `--listen` and `--routed`/`--unified` flags when running `awmg` directly.
407407

408408
**File Logging:**
409409
- Operational logs are always written to log files in the configured log directory

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ make clean
247247
## Project Structure
248248

249249
```
250-
awmg/
250+
gh-aw-mcpg/
251251
├── main.go # Entry point
252252
├── go.mod # Dependencies
253253
├── Dockerfile # Container image
@@ -425,6 +425,7 @@ DEBUG=server:* ./awmg --config config.toml # Enable specific package
425425
The project uses:
426426

427427
- `github.com/spf13/cobra` - CLI framework
428+
- `github.com/spf13/pflag` - POSIX/GNU-style flag parsing used by tracing and CLI integrations
428429
- `github.com/BurntSushi/toml` - TOML parser
429430
- `github.com/modelcontextprotocol/go-sdk` - MCP protocol implementation
430431
- `github.com/itchyny/gojq` - JQ schema processing

config.example.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ GITHUB_PERSONAL_ACCESS_TOKEN = "" # Pass through from host
7575
# tools = ["*"] # Allow all tools (default)
7676
# tools = ["read_file", "list_files"] # Allow specific tools only
7777

78+
# Optional: Per-tool response filters (jq expressions)
79+
# Transforms tool response payloads before they are returned and before large-payload
80+
# preview/schema processing runs.
81+
# [servers.github.tool_response_filters]
82+
# search_code = ".results[:20]"
83+
# get_file_contents = "{path: .path, sha: .sha}"
84+
7885
# Optional: Guard policies for access control at the MCP gateway level
7986
# The structure is server-specific. For GitHub MCP server, this controls repository access.
8087
# Example: Restrict access to specific GitHub organization and repositories
@@ -143,6 +150,11 @@ args = [
143150
# (The [gateway.opentelemetry] and [gateway.tracing] sections DO support ${VAR} expansion.)
144151
[servers.custom]
145152
command = "docker"
153+
# Optional: Working directory for server process (currently parsed but not used by launcher)
154+
# working_directory = "/workspace"
155+
#
156+
# Optional: Informational URI to this server entry in an MCP registry
157+
# registry = "https://example.com/mcp-registry/servers/custom"
146158
args = [
147159
"run",
148160
"--rm",
@@ -157,11 +169,21 @@ args = [
157169
# [servers.http-example]
158170
# type = "http"
159171
# url = "https://example.com/mcp"
172+
# connect_timeout = 45 # Optional: Per-transport connect timeout in seconds (default: 30)
173+
# tool_timeout = 600 # Optional: Per-server tool timeout in seconds (default: gateway.tool_timeout)
174+
# rate_limit_threshold = 3 # Optional: Consecutive rate-limit errors before circuit opens
175+
# rate_limit_cooldown = 60 # Optional: Seconds before OPEN→HALF-OPEN probe
176+
# registry = "https://example.com/mcp-registry/servers/http-example"
160177
#
161178
# Optional: HTTP headers for authentication
162179
# [servers.http-example.headers]
163180
# Authorization = "Bearer token123"
164181
# X-API-Key = "api-key-123"
182+
#
183+
# Optional: GitHub Actions OIDC auth for upstream HTTP server
184+
# [servers.http-example.auth]
185+
# type = "github-oidc"
186+
# audience = "https://example.com/mcp"
165187

166188
# ============================================================================
167189
# Advanced Options

docs/CONFIGURATION.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,17 @@ Run `./awmg --help` for full CLI options. Key flags:
166166
- Use `["*"]` (wildcard) to allow all tools (default behavior when field is omitted)
167167
- Example: `["get_file_contents", "search_code"]` (only these tools are accessible)
168168

169+
- **`tool_response_filters`** (optional): Per-tool jq expressions that transform tool response data before it is returned to the agent and before large-payload preview/schema processing runs
170+
- Map key: tool name; map value: jq expression string
171+
- Expressions are validated at startup (compile check); invalid jq causes startup/config validation failure
172+
- Example:
173+
```json
174+
"tool_response_filters": {
175+
"search_code": ".results[:20]",
176+
"get_file_contents": "{path: .path, sha: .sha, content: .content}"
177+
}
178+
```
179+
169180
- **`registry`** (optional): Informational URI to the server's entry in an MCP registry
170181
- Used for documentation and discoverability purposes only; not used at runtime
171182

0 commit comments

Comments
 (0)