Use Claude Code with the Cline VS Code extension through a simple OpenAI-compatible bridge.
cline.code
makes Claude Code work with the Cline VS Code extension. It's a bridge that translates between Cline's OpenAI API format and Claude's MCP (Model Context Protocol).
π BREAKTHROUGH: Fully Working with Cline!
After extensive debugging and solving multiple critical compatibility issues, the bridge now provides complete Cline integration. See BREAKTHROUGH_SOLUTION.md for the technical journey.
This bridge enables the Cline VS Code extension to work with Claude AI by:
- Accepting OpenAI-formatted requests from Cline
- Communicating with Claude via the MCP (Model Context Protocol)
- Returning responses in OpenAI-compatible format
- Full streaming support (SSE) for real-time responses
- π― Cline VS Code Extension - Complete integration with all features
- π File Operations: Create, read, modify files through Cline
- β‘ Command Execution: Run shell commands via Claude
- π§ Planning & Execution: Support for Cline's PLAN and ACT modes
- π‘ Streaming Support: Real-time responses with Server-Sent Events
- π§ Tool Integration: Full XML tool processing for Cline compatibility
Hey! π I'm someone who loves Claude Code - it's my main go-to coding assistant. I kept seeing people in forums and Discord asking "Can I use Claude with Cline?" The Cline VS Code extension is amazing, but it only worked with OpenAI.
I thought: "This sounds like a fun personal challenge... I wonder if I can make Claude work with Cline?"
Spoiler alert: I did! π
After lots of experimenting, I figured out how to use Claude's MCP (Model Context Protocol) server as a bridge. This adapter sits between Cline and Claude Code, translating API calls so they work together perfectly.
This is a personal project I built for fun and to help the community. Here's what that means:
- Things might break π§ (I'm just one person!)
- I'll do my best to fix issues and respond to questions
- Your help is invaluable - testing, bug reports, and contributions are super welcome!
- It's unofficial - not affiliated with Anthropic or any IDE companies
cline.code
leverages Anthropic's official Model Context Protocol (MCP) server functionality built into Claude Code. Here's the complete architecture:
graph TD
A[Cline VS Code Extension] -->|OpenAI API format| B[cline.code Bridge<br/>Express.js Server]
B -->|JSON-RPC calls| C[Claude MCP Server<br/>claude mcp serve]
C -->|Task tool requests| D[Claude AI<br/>Anthropic's API]
D -->|AI responses| C
C -->|MCP responses| B
B -->|OpenAI format| A
E[Your Authentication<br/>Claude CLI login] -.->|Credentials| C
F[File System<br/>Your Project] -.->|Access| A
style A fill:#e1f5fe
style B fill:#f3e5f5
style C fill:#e8f5e8
style D fill:#fff3e0
style E fill:#fce4ec
style F fill:#f1f8e9
- Sends standard OpenAI API requests (
/v1/chat/completions
) - Expects OpenAI-format responses with
choices
,usage
, etc. - Handles file operations, command execution through tool calls
- Express.js server on
localhost:8000
- Protocol translator between Cline's OpenAI format and Claude's MCP
- Streaming support - Converts to Server-Sent Events for Cline
- Tool processing - Handles XML tool tags for Cline's PLAN/ACT modes
- Spawned automatically by our gateway using
claude mcp serve
- JSON-RPC 2.0 communication over stdio pipes
- Task tool - The key discovery! Uses the
Task
tool to send prompts to Claude - Official implementation - We're using Anthropic's own MCP server
- The actual AI - Claude Sonnet, Opus, etc.
- Your authentication - Uses your Claude CLI credentials
- Smart responses - Understands context and generates appropriate tool usage
- Cline Request:
POST /v1/chat/completions
with OpenAI format - Bridge Translation: Converts to MCP
tools/call
withTask
tool - MCP Communication: JSON-RPC over stdio to Claude MCP server
- Claude Processing: AI generates response with tool usage (XML tags)
- Response Translation: Converts back to OpenAI format with
choices
array - Cline Receives: Standard OpenAI response that Cline understands perfectly
- Official MCP Server: We discovered Claude Code has a built-in MCP server mode
- Task Tool: The
Task
tool is Claude's gateway for chat-style interactions - XML Tool Processing: Cline expects specific XML tool formats for file operations
- Streaming Translation: Cline requires Server-Sent Events, not JSON responses
- Mode Detection: Handle Cline's PLAN MODE vs ACT MODE workflows
β WORKING SOLUTION - Successfully tested with Cline!
- β Full OpenAI API compatibility
- β Streaming support (Server-Sent Events)
- β XML tool format compatibility
- β Production code structure
- β Configuration management & authentication
# Clone the repository
git clone https://github.com/vanzan01/cline.code.git
cd cline.code
# Install dependencies
npm install
# Run the production server (recommended for local use)
HOST=127.0.0.1 PORT=8000 AUTH_ENABLED=false npm start
# Or simple start (binds to all interfaces)
npm start
# Or run in development mode with auto-reload
npm run dev
That's it! The bridge is now running on http://localhost:8000
# In a new terminal, test with curl:
curl -X POST http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "claude-code",
"messages": [{"role": "user", "content": "Hello"}]
}'
# Run the minimal POC demo
npm run demo:minimal
# Or try the chatbot demo
# With the bridge running, open demos/chatbot/claude-bridge-chatbot-demo/index.html in your browser
The bridge supports environment variables for production configuration:
PORT=3000 # Server port (default: 8000)
HOST=localhost # Server host (default: 0.0.0.0)
AUTH_ENABLED=true # Enable API key validation (default: false)
API_KEYS=key1,key2,key3 # Comma-separated list of valid API keys
LOG_LEVEL=debug # Logging level: info, debug (default: info)
LOGGING_ENABLED=true # Enable request logging (default: true)
MCP_COMMAND=claude # Claude CLI command (default: claude)
MCP_TIMEOUT=15000 # MCP initialization timeout ms (default: 10000)
# Default setup (port 8000, all interfaces)
npm start
curl http://localhost:8000/health
# Custom port
PORT=3000 npm start
curl http://localhost:3000/health
# Localhost only (more secure for development)
HOST=localhost PORT=3000 npm start
curl http://localhost:3000/health
# Production setup
HOST=0.0.0.0 PORT=8080 npm start
curl http://localhost:8080/health
# Enable authentication with API keys
AUTH_ENABLED=true API_KEYS=key1,key2,key3 npm start
# Test with valid API key
curl -H "Authorization: Bearer key1" http://localhost:8000/health
# Test with invalid key (should get 401)
curl -H "Authorization: Bearer wrong-key" http://localhost:8000/health
# Test without key (should get 401)
curl http://localhost:8000/health
# Default logging (info level)
npm start
curl http://localhost:8000/health
# See: [2025-05-27T08:13:13.316Z] GET /health - 200 - 3ms
# Debug logging (detailed JSON)
LOG_LEVEL=debug npm start
curl http://localhost:8000/health
# See detailed request info in JSON format
# Disable logging
LOGGING_ENABLED=false npm start
curl http://localhost:8000/health
# No request logs (only startup logs)
# Development setup
HOST=localhost PORT=3000 LOG_LEVEL=debug npm start
# Production-like setup
PORT=8080 AUTH_ENABLED=true API_KEYS=prod-key LOG_LEVEL=info npm start
curl -H "Authorization: Bearer prod-key" http://localhost:8080/health
# High-performance setup (no logging)
PORT=8000 LOGGING_ENABLED=false MCP_TIMEOUT=5000 npm start
cline.code/
βββ src/ # Production implementation
β βββ index.js # Application entry point
β βββ app.js # Express app configuration
β βββ services/ # Business logic
β β βββ mcp/ # MCP client implementation
β βββ routes/ # API endpoints
β βββ middleware/ # Express middleware
β βββ config/ # Configuration (Phase 2)
βββ demos/ # Working demonstrations
β βββ minimal-bridge/ # Minimal POC that works
β βββ chatbot/ # Example chatbot using the bridge
βββ docs/ # Documentation
β βββ README.md # Documentation overview
β βββ PRODUCTION_UPGRADE_PLAN.md # Roadmap for production
β βββ architecture/ # Design specs and diagrams
βββ tests/ # Test suite (coming soon)
βββ CHANGELOG.md # Version history
- Startup: Bridge automatically spawns Claude MCP server as child process
- Client (e.g., Cursor IDE) sends OpenAI-format request to bridge
- Bridge receives request on OpenAI-compatible endpoints
- Bridge communicates with Claude MCP server via JSON-RPC over stdio
- Claude MCP processes request using the Task tool
- Bridge parses and formats response in OpenAI format
- Client receives standard OpenAI response
The Claude MCP server exposes a Task
tool that enables chat functionality:
- Method:
tools/call
withname: "Task"
- Sends prompts to Claude AI
- Returns responses in nested JSON structure
- Node.js 18+
- Claude Code CLI installed and authenticated
- WSL (if running on Windows)
- Install Cline VS Code Extension
- Start cline.code:
npm start
- Configure Cline to use
http://localhost:8000
as the OpenAI API endpoint - Try creating files, running commands, asking questions - it should all work!
Making it more robust:
- Cline-specific edge cases
- Error scenarios
- Performance improvements
- Better documentation
π Found a bug with Cline?
- Open an issue with details (what happened, error messages)
- I'll do my best to fix it quickly
π‘ Got an idea?
- Cline-specific feature requests welcome
- Architecture improvements
- Better Cline integration ideas
π§ Want to contribute code?
- Fork it, fix it, PR it!
- All skill levels welcome
- Even small improvements are hugely appreciated
π’ Just want to test?
- Try different Cline workflows and let me know what works (or doesn't)
- Share your Cline setup tips
Remember: This project exists to make Claude work perfectly with Cline! π
# Clone and setup
git clone https://github.com/vanzan01/cline.code.git
cd cline.code
npm install
# Run the production server (one command - handles everything!)
npm start
# Or run in development mode with auto-reload
npm run dev
# In another terminal, test it
curl http://localhost:8000/health
# Test the chat endpoint
curl -X POST http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model": "claude-code", "messages": [{"role": "user", "content": "Hello"}]}'
# Run tests
node tests/integration/openai-compatibility.test.js
node tests/manual/basic-functionality.js
- Production Upgrade Plan - Roadmap for incremental production development
- Architecture Specification - Detailed technical design (legacy)
- Source Code Documentation - Production code structure
- Documentation Overview - Guide to all documentation
- Changelog - Version history and updates
- Proof of concept
- Basic demos
- Modular production structure
- MCPClient class implementation
- Route separation
- Configuration management (environment variables)
- API key validation (configurable authentication)
- Request logging middleware
- Error handling middleware
- Environment-based settings
- GET /v1/models endpoint
- Model listing
- Connection resilience
- Request queuing
- Streaming responses
- Comprehensive testing
- Docker support
- Cline-specific optimizations
See PRODUCTION_UPGRADE_PLAN.md for detailed roadmap.
This project started as my personal challenge, but I'd love to turn it into something the whole community can benefit from!
π§ͺ Testers:
- Try cline.code with different Cline workflows and use cases
- Report what works and what doesn't
- Help me understand how Cline behaves in different scenarios
π§ Developers:
- Improve Cline-specific compatibility and features
- Improve error handling and edge cases
- Make the code more robust and maintainable
π Writers:
- Cline setup guides and tutorials
- Troubleshooting documentation
- Improve the README and docs
I built this because I love Claude Code and wanted to share it with people who love Cline. The goal is simple: make Claude work perfectly with Cline.
This isn't about building a business or becoming the "official" solution. It's about solving a real problem that Cline users have and doing it in the open where everyone can benefit.
- Start small - even fixing typos or improving error messages helps!
- Open an issue first for bigger features so we can discuss the approach
- Test thoroughly - include steps to reproduce and test your changes
- Be patient - this is a side project, but I'll do my best to respond quickly
If you contribute something meaningful, I'll make sure you get credit in the README and releases. This is a community effort!
If cline.code
saves you time or you'd like to see more tools like this, consider sponsoring me on GitHub!
More coffee = More code = More awesome tools for the community! ββπ»βπ
Even small contributions help keep me motivated to build cool stuff and respond to issues quickly. Plus, sponsors get my eternal gratitude and maybe early access to new experiments! π
- Unofficial: Not affiliated with Anthropic, Cline, or any IDE companies
- Personal Project: Built by one person in their spare time
- No Warranties: Use at your own risk, things might break
- Community Driven: Success depends on people like you testing and contributing
- Requires Claude Access: You need your own Claude Code authentication
MIT License - See LICENSE file
TL;DR: Use it, modify it, share it, contribute to it! Just keep the license notice. π