Skip to content

Conversation

@alexei-led
Copy link
Owner

Summary

  • Auto-detect Docker environment using /.dockerenv and /proc/self/cgroup
  • Bind SSE server to 0.0.0.0 in Docker (required for port mapping)
  • Bind SSE server to 127.0.0.1 on host (secure localhost-only)

Problem

When running the MCP server in Docker with SSE transport, the server bound to 127.0.0.1:8000 inside the container. This made it inaccessible from the host even with port mapping (-p 8001:8000).

Solution

Smart host binding based on environment detection:

Environment Host Binding Rationale
Docker 0.0.0.0 Required for port mapping to work
Host (uvx) 127.0.0.1 Secure, localhost-only access

Security Considerations

  • Host (uvx with sandbox): Binds to localhost only - prevents accidental network exposure
  • Docker: Binds to all interfaces but Docker's network namespace provides isolation; users can further restrict via -p 127.0.0.1:8000:8000

Test plan

  • uvx SSE binds to 127.0.0.1:8000
  • Docker SSE binds to 0.0.0.0:8000
  • Docker SSE accessible from host via port mapping
  • All 218 unit tests pass
  • Lint/format checks pass

Auto-detect Docker environment and bind SSE server appropriately:
- Docker: 0.0.0.0 (required for port mapping to work)
- Host: 127.0.0.1 (secure localhost-only binding)

This fixes SSE transport being inaccessible when running in Docker
containers even with port mapping configured.
@codecov
Copy link

codecov bot commented Nov 30, 2025

Codecov Report

❌ Patch coverage is 11.11111% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.40%. Comparing base (c8db24c) to head (d7bae4d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/aws_mcp_server/config.py 11.11% 8 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #27      +/-   ##
==========================================
- Coverage   91.29%   90.40%   -0.89%     
==========================================
  Files           8        8              
  Lines         804      813       +9     
==========================================
+ Hits          734      735       +1     
- Misses         70       78       +8     
Files with missing lines Coverage Δ
src/aws_mcp_server/config.py 60.00% <11.11%> (-40.00%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alexei-led alexei-led merged commit bd0011b into main Nov 30, 2025
3 of 4 checks passed
@alexei-led alexei-led deleted the fix/docker-sse-binding branch November 30, 2025 20:55
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.

2 participants