Agent HTTP

Agent HTTP

Provides an HTTP API for Claude Code using a native MCP channel to enable stable message exchange without terminal screen-scraping. It allows users to programmatically send messages, retrieve conversation history, and stream real-time events via standard web protocols.

Category
访问服务器

README

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
    time.sleep(1)

# Get the response
messages = requests.get("http://localhost:3284/messages").json()
print(messages[-1]["content"])

SSE listener

const events = new EventSource("http://localhost:3284/events");

events.addEventListener("message", (e) => {
  const msg = JSON.parse(e.data);
  console.log(`[${msg.role}] ${msg.content}`);
});

events.addEventListener("status", (e) => {
  const { status } = JSON.parse(e.data);
  console.log(`Agent is ${status}`);
});

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选