Skip to content

Commit 08f09d2

Browse files
committed
docs: Update CLAUDE.md with new tray-core communication environment variables and API key management details
1 parent d3930fb commit 08f09d2

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

CLAUDE.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,12 @@ MCPProxy supports several environment variables for configuration and security:
355355
- `MCPPROXY_DISABLE_OAUTH` - Disable OAuth for testing
356356
- `HEADLESS` - Run in headless mode (no browser launching)
357357

358+
**Tray-Core Communication**:
359+
- `MCPPROXY_API_KEY` - Shared API key for tray-core authentication (auto-generated if not set)
360+
- `MCPPROXY_TLS_ENABLED` - Enable TLS/HTTPS for both tray and core (automatically passed through)
361+
- `MCPPROXY_TRAY_SKIP_CORE` - Skip core launch in tray app (for development)
362+
- `MCPPROXY_CORE_URL` - Custom core URL for tray to connect to
363+
358364
**Examples**:
359365
```bash
360366
# Start with custom network binding
@@ -504,6 +510,16 @@ open "http://127.0.0.1:8080/ui/?apikey=your-api-key"
504510
- **Optional protection**: Empty API key disables authentication (useful for testing)
505511
- **Protected endpoints**: `/api/v1/*` and `/events` (SSE) require authentication when enabled
506512

513+
#### Tray-Core API Key Coordination
514+
The tray application ensures secure communication with the core process through coordinated API key management:
515+
516+
1. **Environment Variable Priority**: If `MCPPROXY_API_KEY` is set, both tray and core use the same key
517+
2. **Auto-Generation**: If no API key is provided, tray generates one and passes it to core via environment
518+
3. **Core Process Environment**: Tray always passes `MCPPROXY_API_KEY` to the core process it launches
519+
4. **TLS Configuration**: When `MCPPROXY_TLS_ENABLED=true`, it's automatically passed to the core process
520+
521+
This prevents the "API key auto-generated for security" mismatch that would prevent tray-core communication.
522+
507523
### Quarantine System
508524
- **All new servers** added via LLM tools are automatically quarantined
509525
- **Quarantined servers** cannot execute tools until manually approved

cmd/mcpproxy-tray/main.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ func main() {
118118
// Setup API key for secure communication between tray and core
119119
if trayAPIKey == "" {
120120
// Check environment variable first (for consistency with core behavior)
121-
if envAPIKey := os.Getenv("MCPP_API_KEY"); envAPIKey != "" {
121+
if envAPIKey := os.Getenv("MCPPROXY_API_KEY"); envAPIKey != "" {
122122
trayAPIKey = envAPIKey
123123
logger.Info("Using API key from environment variable for tray-core communication",
124-
zap.String("api_key_source", "MCPP_API_KEY environment variable"),
124+
zap.String("api_key_source", "MCPPROXY_API_KEY environment variable"),
125125
zap.String("api_key_prefix", maskAPIKey(trayAPIKey)))
126126
} else {
127127
trayAPIKey = generateAPIKey()
@@ -887,18 +887,23 @@ func (cpl *CoreProcessLauncher) handleShutdown() {
887887
func (cpl *CoreProcessLauncher) buildCoreEnvironment() []string {
888888
env := os.Environ()
889889

890-
// Filter out any existing MCPP_API_KEY to avoid conflicts
890+
// Filter out any existing MCPPROXY_API_KEY to avoid conflicts
891891
filtered := make([]string, 0, len(env))
892892
for _, envVar := range env {
893-
if !strings.HasPrefix(envVar, "MCPP_API_KEY=") {
893+
if !strings.HasPrefix(envVar, "MCPPROXY_API_KEY=") {
894894
filtered = append(filtered, envVar)
895895
}
896896
}
897897

898898
// Add our environment variables
899899
filtered = append(filtered,
900-
"MCPP_ENABLE_TRAY=false",
901-
fmt.Sprintf("MCPP_API_KEY=%s", trayAPIKey))
900+
"MCPPROXY_ENABLE_TRAY=false",
901+
fmt.Sprintf("MCPPROXY_API_KEY=%s", trayAPIKey))
902+
903+
// Pass through TLS configuration if set
904+
if tlsEnabled := strings.TrimSpace(os.Getenv("MCPPROXY_TLS_ENABLED")); tlsEnabled != "" {
905+
filtered = append(filtered, fmt.Sprintf("MCPPROXY_TLS_ENABLED=%s", tlsEnabled))
906+
}
902907

903908
return filtered
904909
}

0 commit comments

Comments
 (0)