Skip to content

Conversation

@crystalin
Copy link

Summary

  • Implemented HTTP/SSE transport mode for remote hosting of Zen MCP Server
  • Added API key authentication using x-api-key header (similar to Claude's remote MCP)
  • Added non-interactive mode for service deployment
  • Created comprehensive remote deployment documentation

Changes

Core Implementation

  • Added HTTP/SSE server (http_server.py) with Starlette/Uvicorn
  • Dual transport modes: stdio (default) and http for remote access
  • API key authentication: Uses x-api-key header with MCP_API_KEY env var
  • Non-interactive mode: --non-interactive flag for systemd/service deployment

Key Features

  • Server can be accessed remotely via URL (e.g., https://your-server.com:8000/sse)
  • Supports multiple concurrent client connections
  • Health check endpoint at /health
  • Automatic SSE endpoint discovery and message routing
  • No CORS support (by design - MCP clients only)

Configuration

  • MCP_API_KEY: API key for authentication
  • MCP_REQUIRE_AUTH: Enable/disable authentication (default: true)
  • MCP_HOST: Host to bind to (default: 127.0.0.1)
  • MCP_PORT: Port to bind to (default: 8000)

Documentation

  • Created docs/remote-deployment.md with setup instructions
  • Updated .env.example with new configuration options
  • Added examples for MCP Inspector testing

Bug Fixes

  • Fixed 404 error on /messages/ endpoint by properly mounting handler
  • Fixed interactive prompt issues that broke service deployment

Usage

# Start in HTTP mode (localhost only)
./run-server.sh --transport http

# Start for remote access
./run-server.sh --transport http --host 0.0.0.0 --port 8000

# Non-interactive mode for services
./run-server.sh --transport http --non-interactive

Testing

  • Tested SSE connection establishment
  • Verified authentication with x-api-key header
  • Confirmed message routing works correctly
  • Validated non-interactive mode for service deployment

🤖 Generated with Claude Code

OhMyApps and others added 30 commits June 25, 2025 16:00
- Created build.sh script for building the Docker image with environment variable checks.
- Added deploy.sh script for deploying the Zen MCP Server with health checks and logging.
- Implemented healthcheck.py to verify server process, Python imports, log directory, and environment variables.
- Developed comprehensive tests for Docker configuration, environment validation, and integration with MCP.
- Included performance tests for Docker image size and startup time.
- Added validation script tests to ensure proper Docker and MCP setup.
…ding

Feat: Local support with utf 8 encoding
Feat: Add comprehensive Docker support and documentation for Zen MCP Server
…cript with API key validation and connectivity checks
…r; update .dockerignore and README. Fix error in API key detection in Docker deployment script.
- Implemented `run-server.ps1` for setting up the Zen MCP server environment, including virtual environment creation, dependency installation, and Docker cleanup.
- Added logging and error handling throughout the setup process.
- Included functions for validating API keys and configuring integration with Claude Desktop and Gemini CLI.
- Created `run_integration_tests.ps1` to execute integration tests with real API calls, including checks for API key availability and environment setup.
- Enhanced output with color-coded messages for better user experience.

Patch directory added for cross-platform patching support (`patch_crossplatform.py`).
Added new confidence values (very_high, almost_certain) to all workflow tools
to provide more granular confidence tracking. Updated enum declarations in:
- analyze.py, codereview.py, debug.py, precommit.py, secaudit.py, testgen.py
- Updated debug.py's get_required_actions to handle new confidence values
- All tools now use consistent 7-value confidence scale
- refactor.py kept its unique scale (exploring/incomplete/partial/complete)

Also fixed model thinking configuration:
- Added very_high and almost_certain to MODEL_THINKING_PREFERENCES
- Set medium thinking for very_high, high thinking for almost_certain
- Updated prompts to clarify certain means 100% local confidence

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
…er initialization order is correct.

Fix run-server.ps1 to handle PowerShell script creation correctly and ensure pip is installed in the uv environment.
- Add HTTP/SSE transport mode alongside existing stdio mode
- Implement http_server.py with Starlette/Uvicorn for remote hosting
- Add authentication middleware with Bearer token support
- Update server.py to support --transport flag for mode selection
- Add web dependencies (starlette, uvicorn, PyJWT, python-multipart)
- Update run-server.sh with new transport options
- Add comprehensive remote deployment documentation
- Include Docker and docker-compose configuration examples
- Update .env.example with HTTP server configuration options
- Maintain full backward compatibility with stdio mode

This enables users to host Zen MCP Server remotely and connect via URL.

Co-Authored-By: Claude <[email protected]>
- Remove Dockerfile, docker-compose.yml, and .dockerignore
- Update remote deployment guide to use PM2 instead of Docker
- Replace Docker references with systemd and PM2 alternatives
- Simplify deployment options for better maintainability

Co-Authored-By: Claude <[email protected]>
- Remove CORSMiddleware from http_server.py
- Remove MCP_CORS_ORIGINS configuration from .env.example
- Update documentation to clarify server is for MCP clients only
- Simplify security model by removing cross-origin concerns

The server is designed for MCP protocol clients, not web browsers.

Co-Authored-By: Claude <[email protected]>
- Added --non-interactive flag to run-server.sh
- Auto-detect non-interactive mode when no TTY available
- Skip all interactive prompts in non-interactive mode:
  - Python installation prompts
  - Claude CLI/Desktop integration prompts
  - Gemini CLI integration prompts
- Fix issue where service startup fails due to interactive prompts
- Update help documentation with new flag and examples

This allows the script to run properly when deployed as a systemd service
or in other non-interactive environments.
- Replace Bearer token authentication with x-api-key header
- Update AuthenticationMiddleware to check x-api-key header
- Change MCP_AUTH_TOKEN to MCP_API_KEY in .env.example
- Update run-server.sh to check for MCP_API_KEY
- Update all documentation to reflect API key usage
- Align with Claude's remote MCP authentication pattern

This provides a more standard API key authentication approach that is
commonly used in API services and matches Claude's implementation.
crystalin and others added 27 commits June 28, 2025 20:21
- Move message handler mounting to lifespan function
- Ensure SSE transport is initialized before mounting
- Remove redundant on_event startup handler
- Fix race condition where handler was mounted before transport existed
- Remove Production Deployment section (systemd, PM2)
- Remove nginx reverse proxy configuration
- Remove Cloud Deployment Examples (AWS, GCP, Heroku)
- Keep only essential remote deployment information
- Simplify documentation to focus on basic HTTP/SSE setup
…ts for health checks

Update the Docker README and create a Docker Deployment guide in the docs folder
…olume persistence

- Introduced tests for Docker deployment scripts to ensure existence, permissions, and proper command usage.
- Added tests for Docker integration with Claude Desktop, validating MCP configuration and command formats.
- Implemented health check tests for Docker, ensuring script functionality and proper configuration in Docker setup.
- Created tests for Docker MCP validation, focusing on command validation and security configurations.
- Developed security tests for Docker configurations, checking for non-root user setups, privilege restrictions, and sensitive data handling.
- Added volume persistence tests to ensure configuration and logs are correctly managed across container runs.
- Updated .dockerignore to exclude sensitive files and added relevant tests for Docker secrets handling.
…tion

feat: Add Docker support and documentation
…teform_compatibility

Feat: Cross-Plateform Compatibily
…ith you blindly and undoing the _correct_ strategy because you were wrong

Fixed run script to ensure pip is installed
Automatically determine MCP client's name
Fixed challenge expectation
Screenshots with and without zen for Challenge tool
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.

4 participants