Skip to content

Feat/add docker setup support#183

Merged
RyanNg1403 merged 4 commits intomainfrom
feat/add-docker-setup-support
Aug 6, 2025
Merged

Feat/add docker setup support#183
RyanNg1403 merged 4 commits intomainfrom
feat/add-docker-setup-support

Conversation

@RyanNg1403
Copy link
Collaborator

@RyanNg1403 RyanNg1403 commented Aug 6, 2025

Fix MCP Endpoint Routing for Remote Client Access

🔍 Root Cause

Issue #174: MCP Client Connection Problems

MCP clients (Cursor, Windsurf, Claude Code) could not connect to Cipher's MCP endpoints when deployed remotely.

Problems identified:

  1. Hardcoded /api prefix: All API routes were mounted under /api, making MCP endpoints available at /api/mcp instead of the expected /mcp
  2. Misleading logs: Startup messages showed "MCP endpoints available at /mcp/sse and /mcp" but actual paths were /api/mcp/sse and /api/mcp
  3. Client expectations: MCP clients expect standard endpoints at /mcp and /mcp/sse, not prefixed versions

✅ Solution

Core Changes for MCP Routing

Implemented configurable API prefix to enable flexible endpoint routing:

  • Added apiPrefix configuration to ApiServerConfig interface
  • Environment variable support: CIPHER_API_PREFIX="" disables prefix
  • CLI flag support: --api-prefix "" command line option
  • Dynamic route building: All routes now use configurable prefix
  • Fixed startup logs: Show actual endpoint URLs with correct prefix

Usage Examples

Docker Setup for Remote MCP Access

Step 1: Clone and Configure

git clone <repository-url>
cd cipher
cp .env.example .env

Step 2: Set API Keys in .env

# Required: Add at least one API key
OPENAI_API_KEY=sk-your-actual-openai-key-here
# OR
ANTHROPIC_API_KEY=sk-ant-your-actual-anthropic-key-here

# Recommended settings for Docker
NODE_ENV=production
CIPHER_LOG_LEVEL=info
VECTOR_STORE_TYPE=in-memory
STORAGE_DATABASE_TYPE=in-memory
STORAGE_CACHE_TYPE=in-memory

Step 3: Build and Start Docker

# Build and start Cipher
docker-compose up --build -d

# Verify it's running
docker-compose logs -f cipher-api

Expected success logs:

✅ [API Server] Using API prefix: '(none)'
✅ [API Server] MCP SSE endpoints available at /mcp/sse and /mcp
✅ API Server started on 0.0.0.0:3000

Step 4: Test Endpoints

# Health check
curl http://localhost:3000/health

# MCP server listing (should work without /api prefix)
curl http://localhost:3000/mcp/servers/

Step 5: Connect MCP Clients

Cursor Configuration:

{
  "mcpServers": {
    "cipher": {
        "type": "sse",
        "url": "http://localhost:3000/mcp/sse",
        "postUrl": "http://localhost:3000/mcp"
    }
  }
}

Other clients: Use http://localhost:3000/mcp as the MCP endpoint URL.

🎯 Result

MCP Routing Fix

  • Backward Compatible: Default /api prefix behavior preserved
  • Standard MCP Endpoints: CIPHER_API_PREFIX="" enables /mcp paths
  • Remote Deployment Ready: Works with Cursor, Windsurf, Claude Code
  • Accurate Logging: Startup messages show correct endpoint URLs
  • Docker Optimized: Simple single-service deployment

@RyanNg1403 RyanNg1403 mentioned this pull request Aug 6, 2025
1 task
@RyanNg1403 RyanNg1403 merged commit 6e9d498 into main Aug 6, 2025
5 checks passed
@phamleduy04
Copy link
Contributor

phamleduy04 commented Aug 6, 2025

@RyanNg1403 I see you remove the build step on while building docker and rely on host.

  • This wont work with CI/CD since CI/CD don't have a build step before it.
  • This generally not recommend since the node version on host and node version on docker image might be different.
  • You might get “works on my machine” surprises.

@RyanNg1403 RyanNg1403 deleted the feat/add-docker-setup-support branch August 6, 2025 14:02
@RyanNg1403
Copy link
Collaborator Author

@RyanNg1403 I see you remove the build step on while building docker and rely on host.

  • This wont work with CI/CD since CI/CD don't have a build step before it.
  • This generally not recommend since the node version on host and node version on docker image might be different.
  • You might get “works on my machine” surprises.

Note that! I'm working on that right now!

@RyanNg1403 RyanNg1403 mentioned this pull request Aug 7, 2025
Ptah-CT pushed a commit to DerAuctor/ct-cipher that referenced this pull request Oct 2, 2025
…up-support

Feat/add docker setup support
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