Agent HTTP: Add a Production-Ready HTTP API to Claude Code in 5 Minutes

Agent HTTP: Add a Production-Ready HTTP API to Claude Code in 5 Minutes

Agent HTTP is an MCP server that gives Claude Code a clean HTTP API, enabling programmatic control and integration without terminal scraping.

18h ago·3 min read·2 views·via hn_claude_code
Share:

Agent HTTP: Add a Production-Ready HTTP API to Claude Code in 5 Minutes

What It Does

Agent HTTP is a native MCP channel server that exposes Claude Code's capabilities through a clean, RESTful HTTP API. Instead of wrapping the CLI in a virtual terminal and parsing screen output (like agentapi does), it communicates directly with Claude Code via the Model Context Protocol (MCP) channel system. This means messages are exact—no terminal diffing, no TUI artifact stripping, and no heuristics that break when the CLI updates.

The API is compatible with the agentapi specification (POST /message, GET /messages, GET /status, GET /events), making it a drop-in replacement for projects that only need Claude Code support.

Setup

Requirements:

  • Bun runtime
  • Claude Code v2.1.80+

Installation:

# Clone the repository
cd agent-http

# Install dependencies
bun install

Configuration:
Create or update your .mcp.json file:

{
  "mcpServers": {
    "http-router": {
      "command": "bun",
      "args": ["./http.ts"]
    }
  }
}

Start Claude Code with the channel loaded:

claude --dangerously-load-development-channels server:http-router

The HTTP API will start on port 3284 by default.

API Endpoints

Send a Message

# JSON format
curl -X POST localhost:3284/message \
  -H "Content-Type: application/json" \
  -d '{"content": "List files in this directory", "type": "user"}'

# Plain text format
curl -X POST localhost:3284/message -d "What files are in this directory?"

Both return immediately with { "ok": true, "chat_id": "1" } once Claude starts processing.

Get Message History

curl localhost:3284/messages

Returns an array of all messages with timestamps.

Check Status

curl localhost:3284/status

Returns { "status": "stable" } when idle or { "status": "running" } when processing.

Real-time Events

curl -N localhost:3284/events

Server-Sent Events stream that broadcasts message and status events in real-time.

Web Chat Interface

A simple web chat interface is included for testing and demos:

http://localhost:3284/chat

It connects to the same API endpoints—messages sent from the chat UI show up in /messages and vice versa.

Custom Configuration

Change Port

Update .mcp.json:

{
  "mcpServers": {
    "http-router": {
      "command": "bun",
      "args": ["./http.ts", "--port", "8080"]
    }
  }
}

Priority: --port flag > CLAUDE_HTTP_PORT env > 3284 default.

JavaScript Example

// Send a message
const res = await fetch("http://localhost:3284/message", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ content: "Explain this codebase" }),
});
const { chat_id } = await res.json();

Why This Matters

Agent HTTP transforms Claude Code from a terminal-only tool into a programmable service. You can now:

  • Integrate Claude Code into existing applications
  • Build custom UIs on top of Claude's capabilities
  • Create automated workflows that interact with Claude programmatically
  • Use Claude Code as a backend service for other tools

The MCP-native approach ensures reliability and exact message handling, making this suitable for production use cases where terminal scraping would be fragile.

AI Analysis

Claude Code users should install Agent HTTP immediately if they want to integrate Claude Code into any automated workflow or custom application. This changes Claude Code from a terminal tool to a programmable service. **Specific actions to take:** 1. Install Bun if you haven't already: `curl -fsSL https://bun.sh/install | bash` 2. Clone the repository and add the MCP server configuration to your `.mcp.json` 3. Start Claude Code with `--dangerously-load-development-channels` flag to load the HTTP server 4. Test with `curl localhost:3284/chat` to see the web interface **Workflow changes:** Instead of building custom scripts that parse Claude Code's terminal output, you can now make direct HTTP calls. This is particularly valuable for CI/CD pipelines, automated code reviews, or building custom dashboards that leverage Claude's coding capabilities. The SSE endpoint means you can build real-time applications that show Claude's thinking process as it works.
Original sourcegithub.com

Trending Now

More in Products & Launches

Browse more AI articles