OpenCodeMCP

silvabyte/OpenCodeMCP

3.2

If you are the rightful owner of OpenCodeMCP and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

The Conversational Coding MCP Server enables natural language interaction with your codebase through ChatGPT and MCP-enabled LLMs, allowing you to explore, read, modify, and run code commands conversationally.

Tools
11
Resources
0
Prompts
0

Conversational Coding MCP Server

An MCP (Model Context Protocol) server that enables conversational coding via ChatGPT or any MCP-enabled LLM. Talk to your codebase from anywhere - on a bike ride, fishing, or walking the dog.

What It Does

This server bridges ChatGPT to OpenCode, allowing you to:

  • Explore projects - "Show me the folder structure of the horizon backend"
  • Read code - "What does the status-change handler do?"
  • Modify code - "Refactor this function to use async/await"
  • Search - "Find all files that import the auth module"
  • Run commands - "Run the tests and tell me what fails"

All through natural conversation.

Architecture

You (speaking) → ChatGPT → MCP Server → OpenCode → Your Codebase
  • ChatGPT: Interprets your intent and calls MCP tools
  • MCP Server: Routes requests to OpenCode (this project)
  • OpenCode: AI coding agent that actually reads/writes files

Quick Start

Prerequisites

  • Bun runtime
  • OpenCode installed (npm i -g opencode-ai)

Installation

# Clone and install
git clone <repo>
cd opencodemcp
bun install

# Configure
cp .env.example .env
# Edit .env and set your MCP_API_KEY

Running

# Development (with hot reload)
bun run dev

# Production
bun run start

The server starts at http://localhost:9000/mcp

Exposing to ChatGPT

Use Cloudflare Tunnel to expose your local server:

# Install cloudflared
brew install cloudflared

# Create a tunnel (one-time)
cloudflared tunnel create mcp

# Run the tunnel
cloudflared tunnel run --url http://localhost:9000 mcp

Then configure ChatGPT to use your tunnel URL as an MCP endpoint.

Configuration

Environment variables (see .env.example):

VariableRequiredDescription
MCP_API_KEYYesAPI key for authenticating requests
MCP_PORTNoPort to run on (default: 9000)
OPENCODE_URLNoURL of existing OpenCode server
PROJECT_ALIASESNoJSON array of project aliases

Project Aliases

Define friendly names for your projects:

PROJECT_ALIASES='[{"name":"horizon backend","path":"/Users/mat/dev/Horizon"},{"name":"my app","path":"/Users/mat/dev/MyApp"}]'

Then say "open the horizon backend" instead of the full path.

MCP Tools

The server exposes these tools to ChatGPT:

ToolDescription
conversationMain interface - send any coding instruction
list_filesList files and directories
read_fileRead file contents
find_textSearch for text patterns
find_filesFind files by name
get_projectGet current project info
list_projectsList all projects
list_sessionsList active sessions
get_messagesGet session message history
abort_sessionStop current operation
add_aliasAdd a project alias

Example Conversations

Opening a project:

"Open the horizon backend and show me the folder structure"

Exploring code:

"What files implement the analytics storage? Show me the main ones."

Making changes:

"Refactor the status-change handler - extract the shared logic into a utility"

Debugging:

"Run the tests and fix any failures"

Development

# Type check
bun run typecheck

# Run with hot reload
bun run dev

Project Structure

src/
├── index.ts           # Server bootstrap
├── routes.ts          # MCP tool definitions
├── auth.ts            # API key authentication
├── opencodeClient.ts  # OpenCode SDK wrapper
├── sessionManager.ts  # Session tracking
└── types.ts           # TypeScript interfaces

License

MIT