This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
VibeCode is a one-command MCP (Model Context Protocol) server that provides automatic persistent domains and OAuth 2.1 authentication. The project creates secure tunnels using Cloudflare to expose local MCP servers to the internet, enabling remote access to development tools including the full mcp-claude-code toolkit plus native Claude Code CLI integration.
- CLI Module (
vibecode/cli.py): Primary interface providingvibecode startcommand with intelligent tunnel management - OAuth Provider (
vibecode/oauth.py): OAuth 2.1 implementation with Dynamic Client Registration (DCR) and PKCE support - Authenticated Server (
vibecode/server.py): FastAPI wrapper that combines MCP server with OAuth authentication middleware - Claude Code Integration (
vibecode/claude_code_tool.py): Native Claude Code CLI integration with permission bypass for seamless MCP access - Package Structure: Two parallel directories (
vibecode/andvibecode_pkg/) for development and distribution
The system implements OAuth 2.1 with these endpoints:
/.well-known/oauth-authorization-server- Server metadata/register- Dynamic client registration/authorize- Authorization with PKCE/token- Token exchange
Automatic tunnel selection based on authentication status with persistence support:
- Persistent tunnels: Creates stable
vibecode-{timestamp}.cfargotunnel.comdomains when authenticated - Quick tunnels: Falls back to random
*.trycloudflare.comdomains - Local mode:
--no-tunnelfor development - Tunnel Persistence: Automatically reuses existing tunnel processes across MCP server restarts
- Process Tracking: Saves tunnel process PID and URL to
.vibecode.json - Smart Reuse: Automatically detects and reuses running tunnel processes
- Process Validation: Checks if saved tunnel process is still alive before reuse
- Graceful Fallback: Creates new tunnel if existing process is not accessible
- Manual Control: Commands to check status (
vibecode tunnel status) and stop tunnels (vibecode tunnel stop) - Configuration Options:
--no-reuseflag to force creation of new tunnels
VibeCode exposes 17 powerful development tools through the MCP protocol:
read,write,edit,multi_edit- File manipulationdirectory_tree- Directory structure visualizationgrep,grep_ast,content_replace- Code search and replacement
notebook_read,notebook_edit- Jupyter notebook operations
run_command- Execute shell commands in persistent sessions
todo_read,todo_write- Session task tracking
dispatch_agent- Sub-agent delegation for complex tasksbatch- Batch multiple tool operationsthink- Structured reasoning tool
claude_code- The flagship tool: Full Claude Code CLI access with:- File operations, code analysis, Git workflows
- Terminal command execution, web search
- Multi-step automation, GitHub integration
- Permission bypass (
--dangerously-skip-permissions) for seamless operation
# Install in development mode
pip install -e .
# Install development dependencies
pip install -e ".[dev]"
# Install cloudflared (required for tunnels)
brew install cloudflared# Start with persistent domain (requires cloudflare login)
vibecode start
# Start with temporary domain
vibecode start --quick
# Local development (no tunnel)
vibecode start --no-tunnel --port 8300
# Use specific tunnel
vibecode start --tunnel my-tunnel-name
# Tunnel management commands
vibecode tunnel status # Check current tunnel status
vibecode tunnel stop # Stop running tunnel
vibecode start --no-reuse # Force new tunnel (skip reuse)IMPORTANT: ALWAYS RUN TESTS DURING DEVELOPMENT
- Run tests between iterations to ensure nothing is broken
- MANDATORY: Always run the end-to-end test before marking any task as complete
# Run all integration tests (main test suite)
python -m pytest vibecode/tests/ -v
# Run core integration tests (faster)
python -m pytest vibecode/tests/test_integration.py -v
# Run end-to-end comprehensive test (REQUIRED before completing tasks)
python test_claude_code_integration.py
# Run specific test
pytest vibecode/tests/test_integration.py::test_vibecode_local_mode
# Test CLI directly
python -m vibecode.cli --help
python -m vibecode.cli start --helpTest Running Policy:
- Between iterations: Run
python -m pytest vibecode/tests/test_integration.py -vto verify core functionality - Before task completion: ALWAYS run
python test_claude_code_integration.pyfor end-to-end validation - Full test suite: Use
python -m pytest vibecode/tests/ -vfor comprehensive testing
# Format code
black vibecode/
# Check imports
isort vibecode/
# Lint
flake8 vibecode/
# Type checking
mypy vibecode/The system automatically detects cloudflared installation across multiple paths:
cloudflared(in PATH)/opt/homebrew/bin/cloudflared(Apple Silicon)/usr/local/bin/cloudflared(Intel Mac)/usr/bin/cloudflared(Linux)
- UUID Paths: Each session generates unique UUID paths (
/{uuid}) for security - OAuth Authentication: Full OAuth 2.1 flow with PKCE for public clients
- CORS Configuration: Allows all origins (configure for production)
- Token Validation: JWT tokens with 1-hour expiration
The AuthenticatedMCPServer wraps the base ClaudeCodeServer with:
- FastAPI middleware for authentication
- OAuth endpoint mounting
- Health checks at
/health - Selective authentication (skips OAuth endpoints)
- Dual Structure: Both
vibecode/andvibecode_pkg/contain similar code for development/distribution - Entry Point:
vibecode.cli:mainis the main entry point defined in pyproject.toml - Dependencies: Built on
mcp-claude-code, FastAPI, uvicorn, and Cloudflare tooling - Python Version: Requires Python 3.10+
- Error Handling: Graceful fallbacks from persistent to quick tunnels
- Process Management: Daemon threads for MCP server, subprocess management for tunnels
- Configuration: Environment-based with intelligent defaults
- Logging: stderr for tunnel output, stdout for user instructions
- Testing: Mandatory end-to-end testing before task completion to ensure system integrity
CRITICAL: Testing is MANDATORY before completing any task
-
During Development: Run integration tests between iterations
python -m pytest vibecode/tests/test_integration.py -v
-
Before Task Completion: ALWAYS run the end-to-end test
python test_claude_code_integration.py
-
Task is NOT complete until the E2E test passes successfully
This ensures that:
- Core MCP server functionality works
- Claude Code integration is intact
- All 17 tools are properly exposed
- Server startup and communication protocols function correctly