Agent HTTP MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
bun install
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add agent-http -- bun "<FULL_PATH_TO_AGENT_HTTP>/dist/index.js" --port 8080

Replace <FULL_PATH_TO_AGENT_HTTP>/dist/index.js with the actual folder you prepared in step 1.

README.md

An HTTP API for Claude Code using a native MCP channel

Agent HTTP

An HTTP API for Claude Code, built as a native MCP channel. Send messages to Claude Code over HTTP and get responses back — no terminal screen-scraping, no TUI parsing. Messages flow through Claude's native channel protocol.

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

How it works

agent-http is an MCP channel server that Claude Code spawns as a subprocess. It bridges HTTP and Claude Code's internal messaging system:

  1. You send an HTTP request to the server
  2. The server pushes it to Claude Code via the MCP channel protocol
  3. Claude processes the message and calls the reply tool to send responses back
  4. Responses are stored in conversation history and broadcast to SSE listeners

Unlike agentapi, which wraps any CLI agent by running it in a virtual terminal and parsing screen output, agent-http uses Claude Code's native channel system. Messages are exact — no terminal diffing, no TUI artifact stripping, no heuristics that break when the CLI updates.

agentapi agent-http
Integration Screen-scrapes a terminal emulator Native MCP channel protocol
Message fidelity Approximated from terminal diffs Exact
Multi-agent support Claude, Aider, Goose, Codex, etc. Claude Code only
Fragility Can break on TUI changes Stable — uses documented MCP contract

Setup

Requires Bun and Claude Code v2.1.80+.

bun install

Usage

Start Claude Code with the channel loaded:

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

Claude Code reads .mcp.json, spawns the server, and the HTTP API starts on port 3284.

To use a custom port, update .mcp.json:

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

API

Send a message

curl -X POST localhost:3284/message \
  -H "Content-Type: application/json" \
  -d '{"content": "Hello, Claude!", "type": "user"}'

Returns immediately with { "ok": true, "chat_id": "1" } once Claude starts processing. Also accepts plain text:

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

Get conversation history

curl localhost:3284/messages

Returns an array of all messages:

[
  { "role": "user", "content": "Hello!", "timestamp": "2025-03-19T..." },
  { "role": "assistant", "content": "Hi there!", "timestamp": "2025-03-19T..." }
]

Check agent status

curl localhost:3284/status

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

Stream events (SSE)

curl -N localhost:3284/events

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

event: status
data: {"status":"running"}

event: message
data: {"role":"assistant","content":"Hello!","timestamp":"2025-03-19T..."}

event: status
data: {"status":"stable"}

Chat UI

A simple web chat interface is available at:

http://localhost:3284/chat

Chat UI

A 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.

Health check

curl localhost:3284/health

Configuration

Option Default Description
--port flag 3284 Set via .mcp.json args: ["./http.ts", "--port", "8080"]
CLAUDE_HTTP_PORT env 3284 Set via .mcp.json env or shell environment

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

Programmatic usage

Node.js / Bun

// 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();

// Poll for completion
const poll = async () => {
  while (true) {
    const status = await fetch("http://localhost:3284/status").then(r => r.json());
    if (status.status === "stable") break;
    await new Promise(r => setTimeout(r, 1000));
  }
  return fetch("http://localhost:3284/messages").then(r => r.json());
};

const messages = await poll();
console.log(messages.at(-1).content);

Python

import requests
import time

# Send a message
requests.post("http://localhost:3284/message", json={
    "content": "What does this project do?",
    "type": "user"
})

# Wait for response
while True:
    status = requests.get("http://localhost:3284/status").json()
    if status["status"] == "stable":
        break

Environment Variables

CLAUDE_HTTP_PORTSets the port for the HTTP API (default 3284)

Configuration

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

Try it

Send a message to Claude Code via the HTTP API to analyze the current directory.
Retrieve the full conversation history from the Agent HTTP server.
Stream real-time events from the agent to monitor status updates.
Check the current status of the Claude Code agent using the status endpoint.

Frequently Asked Questions

What are the key features of Agent HTTP?

Native MCP channel integration for stable message exchange. HTTP API for programmatic interaction with Claude Code. Real-time event streaming via Server-Sent Events (SSE). Built-in web chat interface for testing and demos. Exact message fidelity without terminal screen-scraping.

What can I use Agent HTTP for?

Building custom web-based UIs for Claude Code. Integrating Claude Code into automated CI/CD pipelines. Programmatically controlling Claude Code from external scripts. Monitoring agent status and conversation history in real-time.

How do I install Agent HTTP?

Install Agent HTTP by running: bun install

What MCP clients work with Agent HTTP?

Agent HTTP works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Agent HTTP docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare