[codex] Add MCP bridge auth token - #5
Conversation
c2580d9 to
d57bb88
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces support for loading environment variables from .env files and implements Bearer token authentication for the MCP server's HTTP client. The changes include a custom .env parser, updates to the httpx client configuration, and corresponding test cases. Feedback was provided regarding the .env parsing logic, specifically suggesting a more robust way to handle inline comments to avoid truncating tokens that contain a # character.
| if "#" in value: | ||
| value = value.split("#", 1)[0].rstrip() |
There was a problem hiding this comment.
The current logic for stripping inline comments is quite aggressive and will truncate any value containing a # character, even if it's part of the token itself (e.g., STS2_MCP_AUTH_TOKEN=my#token). Standard .env parsers typically require at least one whitespace character before the # to treat it as an inline comment. Consider requiring a space to avoid accidental truncation of valid tokens.
| if "#" in value: | |
| value = value.split("#", 1)[0].rstrip() | |
| if " #" in value: | |
| value = value.split(" #", 1)[0].rstrip() |
d57bb88 to
9dbe3ec
Compare
4338344 to
7179d39
Compare
Summary
Adds optional auth-token support to the Python MCP bridge without changing the game/mod HTTP server behavior.
Changes
mcp/.envor the process environment while preserving environment-variable precedence.STS2_MCP_AUTH_TOKENas anAuthorization: Bearer ...header on all bridge HTTP requests when configured..envfiles so tokens are not committed.Validation
uv run --directory mcp python ../scripts/test_mcp_server.pyuv run --directory mcp python -m py_compile server.py ../scripts/test_mcp_server.pyuv run --directory mcp python server.py --helpgit diff --cached --check