Skip to main content

claude-code-server

Claude Code CLI wrapped as HTTP SSE server + reusable React chat UI.

Install

pip install claude-code-server

Quick Start

claude-code-server --working-dir /path/to/project --port 8333
# Open http://localhost:8333 for the Web UI
# API available at http://localhost:8333/api/*

Embed in existing FastAPI app

from claude_code_server import create_router, AgentConfig

router = create_router(AgentConfig(working_dir="/path/to/project"))
app.include_router(router, prefix="/api")

Dynamic config per request

from claude_code_server import create_router, AgentConfig, ChatRequest

def config_factory(req: ChatRequest) -> AgentConfig:
    return AgentConfig(
        working_dir="/path/to/project",
        system_prompt="You are a helpful assistant for ...",
        env={"MY_VAR": "value"},
    )

router = create_router(config_factory=config_factory)

Frontend component library (npm)

npm install claude-code-chat
import { Chat } from 'claude-code-chat'

<Chat
  apiBase="/api"
  uploadUrl="/api/upload"
  getHeaders={() => ({ Authorization: `Bearer ${token}` })}
  slashCommands={[
    { name: 'status', description: 'Check status', type: 'prompt', prompt: 'Show status' },
  ]}
/>

Or use individual components:

import { useChat, ChatMessages, ChatInput } from 'claude-code-chat'

const { messages, send, cancel, isLoading, costInfo, uploadFile } = useChat({
  apiBase: '/api',
  uploadUrl: '/api/upload',
})

<ChatMessages messages={messages} isLoading={isLoading} costInfo={costInfo} />
<ChatInput onSend={send} isLoading={isLoading} onCancel={cancel} onUploadFile={uploadFile} />

Note: Import the bundled CSS in your app entry:

import 'claude-code-chat/style.css'

SSE Event Protocol

Event Data Description
session {session_id} Session created/resumed
text {content} Text delta
thinking {content} Thinking delta
tool_call {id, name, arguments} Tool invocation
tool_result {id, name, result, is_error} Tool result
done {cost, duration_ms} Turn complete
error {message} Error

API

Backend

  • ClaudeAgent — Core agent class
  • AgentConfig — Configuration (working_dir, system_prompt, env, max_turns, ...)
  • ChatRequest — Request model (prompt, session_id)
  • create_router(config?, config_factory?) — FastAPI router factory
  • create_app(config?) — Standalone FastAPI app

Frontend

  • <Chat> — Complete chat page (drop-in)
  • <ChatMessages> — Message renderer
  • <ChatInput> — Input with slash commands + file upload
  • useChat(config) — SSE streaming hook
  • useChatStore — Zustand store

Metadata

Release files for claude-code-server 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for claude-code-server 0.1.1
File Size Uploaded
claude_code_server-0.1.1.tar.gz 8.0 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for claude-code-server 0.1.1
File Interpreter ABI Platform
claude_code_server-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 MB

Release files / claude_code_server-0.1.1.tar.gz

Download URL claude_code_server-0.1.1.tar.gz
Size 8.0 MB
Tags Source
SHA-256 checksum
How to use checksums
2f2e1e78b5612f3cf2d6e11cc120d0bce5f710ac33ef7b098c6370ca99e1511c
BLAKE2b-256 checksum
How to use checksums
28463b704cf78ba622b3acf1ff77c409a6a30c942b9603084c8e562ede2d940d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.4

Release files / claude_code_server-0.1.1-py3-none-any.whl

Download URL claude_code_server-0.1.1-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
134e5d30dc92855a300ef9d69cff378712706a92adfb4ae4548fb06dce364ce3
BLAKE2b-256 checksum
How to use checksums
a676c93525f64374a0360ac2bcfd1a36bad3027c3ada09d8a80639dc38f7be16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page