DeepSeek MCP 与 Agent 技能 · 框架与插件 · 11-18 · ★ 2,188

AI 聊天机器人框架

alfredfrancis/ai-chatbot-framework
轻量可自托管的 AI 智能体框架,为每位用户提供独立助手,支持私有文件、技能、应用连接和定时任务。
git clone https://github.com/alfredfrancis/ai-chatbot-framework.git

A self-hosted AI agent for everyone on your team.<br> Each person gets an assistant with its own private computer, files, skills, app connections and scheduled tasks.

Quick start · Features · Deploy · Configuration · Architecture ·

AI Chatbot Framework home screen: chats, projects, files, skills, tasks, connections and personal apps in the sidebar, a

Version 2. AI Chatbot Framework used to be an intent/entity NLU chatbot builder. Version 2 rebuilds it

as an agent. The old code is in the git history.

Why

Most agent tools are built for developers. This one is built for people who just want work done: they type what they need, and the agent reads their files, runs code, uses their apps and remembers how they like things. You run it on your own server, with the model of your choice, and every user's work stays in their own locked-down sandbox.

Features

  • Any model. Claude by default; OpenAI, Ollama, OpenRouter, vLLM, LiteLLM or any other

LangChain chat provider. Users can bring their own key.

  • A private computer per user. One Docker sandbox with a persistent /workspace, resource limits and

no Linux capabilities. Commands and local MCP servers run there.

  • A small, fast agent loop. Four tools (read, write, edit, bash), parallel tool calls,

background commands, context compaction, and steering: type while the agent works and it picks your message up without stopping.

  • Sub-agents. The agent splits a big job into parts and runs helpers side by side, each with a fresh

context and its own model. You can watch each one work.

  • Memory in plain files. context.md (about you) and memory.md (what the agent remembers) are files

the agent reads every turn and edits itself. Every few messages a background pass updates memory and skills from the chat.

  • Skills. The open Agent Skills format (skills/<name>/SKILL.md). Upload one, let the agent write one,

or type / in a chat to pick one. Eleven come built in, from pdf and cited-research to council-of-llms and personal-assistant.

  • App connections (MCP). Local servers run in the sandbox; remote servers sign in with OAuth.

One-click setup for Linear, Notion, Jira, Sentry, Stripe and more.

  • Personal apps. The agent can build small apps for you, like a daily Cockpit or a grocery list,

that show up in the sidebar. Each app has its own chat in a panel on its right: ask for a change there and watch the app update as the agent works. Chat replies can include charts, tabs and buttons too.

  • Projects and scheduled tasks. Group chats under shared instructions and a folder. Run a prompt

"every weekday at 08:00" or once "tomorrow at 17:00"; each run becomes a chat, on the model you pick for the task (a small local one is enough for many background jobs).

  • Files and artifacts. Attach files to a message; each chat lists the files it used and made; documents the agent writes open rendered beside the chat.
  • Open protocol. The chat speaks the Agent Client Protocol over

WebSocket, so editors and your own apps can talk to the agent too.

  • Built to scale. Stateless app processes behind Caddy, with PostgreSQL and Redis. Add or remove

processes at any time.

  • A calm interface. Keyboard-first (⌘K, shortcuts), dark and light themes, works on a phone and

installs as an app (PWA).

Every feature in detail: docs/features.md.

Screenshots

| Steering while it works | Skills | Connections (OAuth) | |---|---|---| | Steering: a message queued while the agent works | Skills page | Connections page with a connected app | | Files | Command menu (⌘K) | Phone, light theme | | Files page | Command menu | Chat on a phone in light theme | | Cockpit app | Sub-agents | Charts in a personal app | | Cockpit personal app | Sub-agents working in parallel | Personal app with charts |

The end-to-end tests take these screenshots on every run (docs/screenshots/e2e/).

Quick start

Try it on your machine with Docker. A scripted fake model answers, so you don't need an API key:

git clone https://github.com/alfredfrancis/ai-chatbot-framework.git
cd ai-chatbot-framework
docker compose -f docker-compose.dev.yml up --build   # or: make up-dev

Open http://localhost:5173 and create an account. Try run: ls or show system in a chat.

To use a real model:

ACF_LLM_BASE_URL= ANTHROPIC_API_KEY=sk-ant-... make up-dev

The web app is on :5173 and the API on :8000 (API only; use 5173). Both reload when you save. PostgreSQL is on host port 55432 (postgresql://acf:acf@localhost:55432/acf). If a port is taken, set ACF_DEV_WEB_PORT, ACF_DEV_API_PORT or ACF_DEV_DB_PORT. Agents run in real sandboxes.

Without Docker, make setup && make dev runs the same thing on your machine (set ACF_SANDBOX=local; it is not isolated, so use it for development only).

Deploy

On a server with Docker and a domain pointing at it:

git clone https://github.com/alfredfrancis/ai-chatbot-framework.git && cd ai-chatbot-framework
cp .env.example .env        # set ACF_DOMAIN, POSTGRES_PASSWORD, ACF_SECRET_KEY and a model key
# prepare the host first: gVisor, user-namespace remapping, sandbox firewall (deploy/README.md)
docker compose up -d        # or: make up

[!IMPORTANT]

Set up the host as described in deploy/README.md before going public.

Your account. Set ACF_ADMIN_EMAIL and ACF_ADMIN_PASSWORD in .env to create your account at startup; sign-ups are then closed unless ACF_ALLOW_SIGNUP=true. Without them, open https://<ACF_DOMAIN>, create the first account, then set ACF_ALLOW_SIGNUP=false.

HTTPS. Caddy gets and renews the certificate; ports 80 and 443 must be open. To use other host ports, set ACF_HTTP_PORT / ACF_HTTPS_PORT (e.g. 127.0.0.1:8088 behind a tunnel or another proxy). When that tunnel or proxy terminates HTTPS (e.g. Cloudflare Tunnel), also set ACF_CADDY_ADDRESS=:80 so Caddy serves plain HTTP. Browsers only offer to install the web app as an app over HTTPS (or on localhost).

Images. The stack pulls published images (ACF_REGISTRY / ACF_VERSION in .env), by default the version of the checkout you run it from. To build from source instead, run docker compose up -d --build. Versions and upgrades: docs/releasing.md.

Data. PostgreSQL runs in its own container (volume postgres-data); workspaces live in ./data, or ACF_DATA_PATH. Back up both. Logs are rotated and the app has health checks: /api/health is liveness (the process answers) and /api/health/ready is readiness (200 with {"db":"ok","bus":"ok"} when the database and, with ACF_REDIS_URL, Redis answer within 2 s; 503 otherwise). Point a load balancer or a Kubernetes readiness probe at the ready route and a liveness probe at the live one.

Security. Each user gets one sandbox container. The app runs as a non-root user and never touches the Docker socket: a small proxy (docker-proxy) holds it and allows only sandbox containers with fixed, locked-down settings. Sandboxes run under gVisor, as a non-root user, on their own network, behind an egress firewall on the host.

Scaling

Run state is shared through Redis, so you can run as many app processes as you like and add or remove them at any time:

docker compose up -d --scale app=3

Caddy spreads requests and chat connections over them and picks up new ones within seconds. Any process serves any chat; each user still has one sandbox and one workspace. A stopping process lets its running agents finish first (ACF_SHUTDOWN_GRACE, default 20 s), and its clients reconnect to another one. A crashed process frees its chats after ACF_BUS_TTL (30 s).

Taking a stopping process out of the rotation is the orchestrator's job: the process closes its listening socket when SIGTERM arrives, before its readiness check could report anything. With compose, Caddy looks up the app processes every 5 s and sends a request that a stopping process refuses to another one. On Kubernetes, give the app container a preStop hook that sleeps a few seconds (sleep 5), so the pod is removed from the Service's endpoints before SIGTERM arrives, and set terminationGracePeriodSeconds above that sleep plus ACF_SHUTDOWN_GRACE (for example 40).

Across several machines, every app process needs the same PostgreSQL, Redis and Docker proxy, and the data folder at the same path (shared storage), because sandboxes mount workspaces from the Docker host. Details: architecture.

Upgrades migrate the database first: the migrate service runs acf-migrate and the app starts once it has finished. App processes also migrate when they start (ACF_MIGRATE_ON_START, default true), and processes that start together take turns on the schema. Where a deploy tool runs migrations as their own step (a Kubernetes Job or a Helm hook), run acf-migrate there and set ACF_MIGRATE_ON_START=false on the app, which then refuses to start on an older schema. Give the Job the app's ACF_DB_URL and ACF_SECRET_KEY: migrations can encrypt and decrypt stored secrets, and without the key acf-migrate stops with a message and leaves the database as it was. It never makes a key of its own, which the app wouldn't have; a secret.key file already in ACF_DATA_DIR (a local install) is used.

During a rolling deploy the previous version's processes keep running, and restart or scale up, on the new schema. A process that finds a schema revision it doesn't know logs a warning naming both revisions and starts without migrating. That is safe only because migrations are expand/contract: each release's migrations keep the previous release working. Add tables, and columns that are nullable or have a server default, in one release; drop or rename what the code no longer uses in a later release.

Configuration

Environment variables. Users choose models in Settings → Models: their own key and address per provider, which models are on in the chat's model picker, a token window per model, and a default model and effort. Each chat can switch model and effort from its message box.

| Variable | Default | Meaning | |---|---|---| | ACF_LLM_PROVIDER | anthropic | Any LangChain provider id: anthropic, openai, ollama, google_genai, … | | ACF_LLM_PROVIDERS | providers that take an API key | Providers users may choose (comma-separated, * = any). The server's own is always allowed | | ACF_LLM_MODEL | claude-opus-5-5 / gpt-4.1-mini | Default model | | ACF_MODELS_FILE | built-in list | JSON list of the models users can pick, with their effort levels, default effort and token window (see below) | | ACF_CUSTOM_MODELS | true | Users may add models of their own; false limits everyone to the models list | | ACF_LLM_API_KEY | ANTHROPIC_API_KEY / OPENAI_API_KEY | Server-wide key, used by every user without their own. Only sent to the server's provider and ACF_LLM_BASE_URL | | ACF_SECRET_KEY | generated in ACF_DATA_DIR/secret.key | Encrypts API keys, MCP configs and OAuth tokens in the database. Required by the production stack | | ACF_LLM_BASE_URL | provider default | e.g. http://localhost:11434/v1 with openai for Ollama | | ACF_MAX_AGENT_STEPS | 40 | Model calls per message (and per sub-agent) | | ACF_SUBAGENTS | 8 | Sub-agents of one run working at the same time; more wait their turn (0 = no sub-agents) | | ACF_SUBAGENT_FAST_MODEL | provider's small model | The model a sub-agent gets when the agent asks for fast (Claude: claude-haiku-5-5, OpenAI: gpt-4.1-mini, others: the user's model) | | ACF_COMPACT_TOKENS / ACF_COMPACT_KEEP_TOKENS | 120000 / 20000 | When to summarise old messages, and how much recent history to keep. A model with a token window set (models file or the user's settings) compacts at 80% of that window instead | | ACF_CONTEXT_WINDOW | model's own | Context window size (tokens) for the chat's context meter when the model has no token window set; default comes from LangChain's model profile, 128000 if unknown | | ACF_MEMORY_LIMIT | 4000 | Characters of memory.md (it goes into every prompt); the agent's writes past it are refused | | ACF_REVIEW_INTERVAL | 10 | User messages per chat between background reviews that update memory and skills (0 = off) | | ACF_AUTO_TITLES | true | After a chat's first reply, the chat's model names it in a few words (false: chats keep their first message as title) | | ACF_SKILL_ARCHIVE_DAYS | 30 | Skills not read for this many days move to skills/.archive/ (0 = never; pinned: true in a skill's frontmatter keeps it) | | ACF_DB_URL | SQLite in ACF_DATA_DIR | Database. The Docker stacks use PostgreSQL (postgresql://user:pass@host/db) | | ACF_MIGRATE_ON_START | true | Each app process brings the database schema up to date as it starts. false: run acf-migrate first (a Kubernetes Job, say), and a process that finds an older schema exits with an error naming it | | ACF_DATA_DIR | ./data | Workspaces (and the SQLite file when no ACF_DB_URL is set) | | ACF_ADMIN_EMAIL / ACF_ADMIN_PASSWORD | – | Main account, created at startup; its password is reset to this value (and its sessions signed out) when it changes | | ACF_ADMIN_NAME | email name | Display name for the main account | | ACF_ALLOW_SIGNUP | true, false if ACF_ADMIN_EMAIL is set | Open sign-ups. When false, the first account can still be created on an empty server | | ACF_COOKIE_SECURE | false | true behind HTTPS | | ACF_SANDBOX | docker | docker, local for development (not isolated), or your own adapter as package.module:Class (see architecture). Upgrading an adapter from 2.0.0-beta.1 or earlier: rename its exec method to run; the app refuses to start with one that still defines exec | | ACF_SANDBOX_IMAGE | acf-sandbox:latest | Sandbox image | | ACF_SANDBOX_NETWORK | acf-sandbox | Created when missing, with traffic between sandboxes off. none cuts sandboxes off from the internet | | ACF_SANDBOX_BRIDGE | acf-sbx0 | Interface name of that network (the egress firewall matches it) | | ACF_SANDBOX_RUNTIME | – (runsc in the production stack) | Container runtime, e.g. runsc for gVisor | | ACF_SANDBOX_MEMORY / _CPUS | 1g / 1 | Limits per sandbox | | ACF_SANDBOX_IDLE_MINUTES | 30 | Stop a sandbox no one has used for this long; it starts again, files intact, on the next command. 0 never stops one | | ACF_SANDBOX_HOST_DATA_DIR | – | Host path of the data dir when the app itself runs in Docker | | ACF_MCP_PRESETS_FILE | – | JSON list of extra one-click apps for the Connections page (see below) | | ACF_REDIS_URL | – (set in the production stack) | Redis for run state shared between app processes. Needed for more than one process; unset keeps it in memory | | ACF_REDIS_PREFIX | acf | Key prefix, to share one Redis between deployments | | ACF_BUS_TTL | 30 | Seconds before a dead process's chats, locks and background commands are freed | | ACF_SHUTDOWN_GRACE | 20 | Seconds a stopping process gives its running agents to finish | | ACF_LOG_FORMAT | text | json writes one JSON object per line to stderr (ts, level, logger, message, plus request_id, user_id, chat_id, run_id and task_id where they apply, and exc for a traceback). A request keeps an incoming X-Request-Id (and returns it); a run is run_id, shared by its sub-agents. Message text and tool output are never logged, and key-like tokens are redacted. Inside a span, lines also carry trace_id and span_id | | OTEL_EXPORTER_OTLP_ENDPOINT | – (off) | OpenTelemetry traces and metrics over OTLP/HTTP (protobuf) to this collector address, e.g. http://otel-collector:4318. OTEL_EXPORTER_OTLP_TRACES_ENDPOINT / ..._METRICS_ENDPOINT turn on one signal only. Unset, nothing is exported and nothing is measured. The other standard OTEL_* variables apply (OTEL_EXPORTER_OTLP_HEADERS, OTEL_TRACES_SAMPLER, OTEL_METRIC_EXPORT_INTERVAL, OTEL_RESOURCE_ATTRIBUTES, OTEL_SDK_DISABLED…). Spans: each HTTP request (by route), acf.run, acf.turn, acf.llm, acf.tool, acf.sandbox.exec, acf.follow. Metrics: acf.runs.active, acf.run.duration, acf.tool.calls, acf.sandbox.start.duration, acf.llm.tokens, acf.acp.connections. No message text, tool arguments, commands or query strings are recorded, and no metric has a per-user label | | OTEL_SERVICE_NAME | acf | The service name on exported traces and metrics |

Models

The models users can pick come from a built-in list (Claude Opus/Sonnet/Haiku/Fable, GPT-5, GPT-5 mini, GPT-4.1 mini), or from ACF_MODELS_FILE, which replaces it:

[
  {"provider": "anthropic", "id": "claude-opus-5-5", "name": "Claude Opus 5.5",
   "efforts": ["low", "medium", "high", "max"], "effort": "medium",
   "context_window": 200000, "max_context_window": 1000000},
  {"provider": "openai", "id": "gpt-5", "efforts": ["minimal", "low", "medium", "high"], "effort": "medium"}
]

efforts are the effort levels the model accepts (left out: no effort setting) and effort the default; effort goes to Claude as output_config.effort and to OpenAI as reasoning_effort. context_window is the token window the context meter and compaction use (left out: the model's own); users may set their own up to max_context_window. Only models of providers in ACF_LLM_PROVIDERS are offered. In a user's list, models whose provider has a key (theirs, or the server's for the server's own provider) start out on.

Other LangChain providers need their package installed (pip install langchain-ollama, …).

A local model for background jobs. docker-compose.withllm.yml adds llama.cpp's llama-server with Qwen3.5 4B, sized for a Raspberry Pi 5 with 8 GB, with prompt caching. Pick it as a task's model so hourly jobs run on your own hardware: docs/local-model.md.

App connections (MCP)

Add, edit, turn off or delete connections from the form on the Connections page. Switch to JSON there to edit the whole configuration directly (same format as Claude Desktop; needed for extra keys like oauth, which the form keeps but doesn't edit). The API equivalents are PUT/DELETE /api/mcp/servers/{name} and PUT /api/mcp/config.

{
  "mcpServers": {
    "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/workspace"] },
    "linear":     { "url": "https://mcp.linear.app/mcp" },
    "internal":   { "url": "https://mcp.example.com/mcp", "headers": { "X-Api-Key": "…" } },
    "github":     { "url": "https://api.example.com/mcp", "oauth": { "client_id": "…", "scopes": ["repo"] } }
  }
}

oauth.authorize_params adds parameters to the provider's sign-in URL. Google, for example, only issues a refresh token with { "access_type": "offline", "prompt": "consent" }; without one the connection ends when the access token expires.

Popular apps. The Connections page lists remote MCP servers that support OAuth dynamic client registration — Linear, Notion, Jira & Confluence, Sentry, monday.com, Canva, Intercom, Stripe, Vercel and Hugging Face. Connect writes the entry into your configuration; Sign in does the rest, no API key needed. To add your own (or override a built-in one by id), point ACF_MCP_PRESETS_FILE at a JSON file:

[{ "id": "acme", "name": "Acme", "description": "Tickets and docs", "url": "https://mcp.acme.com/mcp" }]

Skills

A skill is a folder with a SKILL.md:

---
name: weekly-report
description: Write the weekly sales report. Use when asked for the weekly report.
---
# Weekly report
1. Run `python skills/weekly-report/make.py data/sales.csv`
2. …

Upload it as a .zip (or just the SKILL.md) on the Skills page, or ask the agent to create one — every workspace starts with a skill-creator skill that teaches it how, plus a few general skills (backend/acf/builtin_skills/). Each built-in skill is added once; one you delete stays deleted.

Editors and external apps (ACP)

The agent is reachable over the Agent Client Protocol: JSON-RPC 2.0, one message per WebSocket text frame, at ws(s)://<host>/api/acp. The web chat uses the same endpoint (with its session cookie, same origin only). Other clients authenticate with Authorization: Bearer <token>, using the access token from Settings → External apps. External access is off until a token is created; the token is shown once, stored hashed, and can be replaced or revoked at any time.

Supported: initialize, session/new, session/load (replays the history, then follows a running agent), session/list, session/prompt (text, resource links and embedded text resources), session/cancel and session/set_config_option: session/new and session/load return the chat's configOptions, a model select (the user's models that are on) and, for models that have one, an effort select (thought_level). A resource link to file:///workspace/<path> is an attached workspace file: session/load replays it as a resource_link chunk after the message's text (upload the file first with POST /api/files, keep=true). Each session is a chat in the web app. Updates are user_message_chunk, agent_message_chunk and agent_thought_chunk (streamed as the model writes; chunks of one message share _meta.acf.messageId), tool_call, tool_call_update and session_info_update. A session/prompt sent while the agent works is a steering message; its response arrives when the run ends. Extras live under _acf/ (_acf/notice, _acf/turn_end, _acf/turn_start when a finished background command wakes the agent) and _meta.acf, which other clients can ignore. The agent uses its own sandbox and connections, so cwd and mcpServers from the client are ignored.

Clients that start agents as a subprocess over stdio (most editors) can use the bridge:

ACF_ACP_TOKEN=acp_… python -m acf.acp_bridge --url wss://agent.example.com/api/acp

Contributing

Contributions are welcome. Read AGENTS.md first: it covers the layout, the rules (every feature is tested end to end, including the UI) and the workflow. The design of the agent loop is in docs/architecture.md.

make setup          # Python venv + npm install
make sandbox-image  # or set ACF_SANDBOX=local
make dev            # API :8000 + web :5173
make test           # backend tests (Docker tests run when a daemon is available)
make e2e            # Playwright end-to-end tests (writes docs/screenshots/e2e)
make e2e-docker     # the same with real Docker sandboxes (what CI runs)
make lint

Tests never call a real model: backend/tests/fakes/ has a scripted model server (Anthropic and OpenAI APIs), a dependency-free stdio MCP server and an OAuth-protected HTTP MCP server.

Design tokens live in design/tokens.json (mirroring the design system in Claude Design); cd frontend && npm run tokens regenerates src/tokens.css.

Known limitations

  • Sandboxes refuse to start when the workspace belongs to root: run the app as a normal user.
  • No per-user quotas yet (model spend, disk, number of sandboxes), and no rate limiting on sign-in.

License

MIT. See License.txt.