Skip to content

[codex] Add MCP bridge auth token - #5

Merged
CompleteDotTech merged 1 commit into
codex/save-snapshotsfrom
codex/mcp-auth-token-clean
May 9, 2026
Merged

[codex] Add MCP bridge auth token#5
CompleteDotTech merged 1 commit into
codex/save-snapshotsfrom
codex/mcp-auth-token-clean

Conversation

@CompleteDotTech

Copy link
Copy Markdown
Owner

Summary

Adds optional auth-token support to the Python MCP bridge without changing the game/mod HTTP server behavior.

Changes

  • Loads bridge settings from mcp/.env or the process environment while preserving environment-variable precedence.
  • Sends STS2_MCP_AUTH_TOKEN as an Authorization: Bearer ... header on all bridge HTTP requests when configured.
  • Documents the new bridge setting and ignores local .env files so tokens are not committed.
  • Adds focused MCP bridge tests for dotenv precedence and auth header injection.

Validation

  • uv run --directory mcp python ../scripts/test_mcp_server.py
  • uv run --directory mcp python -m py_compile server.py ../scripts/test_mcp_server.py
  • uv run --directory mcp python server.py --help
  • git diff --cached --check

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread mcp/server.py Outdated
Comment on lines +32 to +33
if "#" in value:
value = value.split("#", 1)[0].rstrip()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
if "#" in value:
value = value.split("#", 1)[0].rstrip()
if " #" in value:
value = value.split(" #", 1)[0].rstrip()

@CompleteDotTech
CompleteDotTech force-pushed the codex/save-snapshots branch from d57bb88 to 9dbe3ec Compare May 9, 2026 18:36
@CompleteDotTech
CompleteDotTech force-pushed the codex/mcp-auth-token-clean branch from 4338344 to 7179d39 Compare May 9, 2026 18:41
@CompleteDotTech
CompleteDotTech marked this pull request as ready for review May 9, 2026 18:46
@CompleteDotTech
CompleteDotTech merged commit ff8a9b8 into codex/save-snapshots May 9, 2026
@CompleteDotTech
CompleteDotTech deleted the codex/mcp-auth-token-clean branch May 9, 2026 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant