Add MCP servers and custom tools for bots

Two new settings pages, MCPs and Tools. Super admins define them; super
admins and admins attach them to bots, to workspaces (every bot there),
or to every bot. Bots get them in chat replies and tasks.

- Custom tools: a JSON-schema of arguments plus an HTTP request, a script
  on the bot's computer, or a prompt, templated with {{args.x}} and
  {{env.KEY}}, secrets redacted from results.
- MCP servers: remote (URL and headers) or stdio commands run on the host
  with a setup command and an isolated env, in a per-process pool. Tools
  are listed into a cache and connect on first call.
- Add, edit, access and try open in modals.
- Markdown, JSON and command fields use twui's AceEditor (CodeEditor),
  its scripts loaded on demand.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-19 15:01:39 +01:00
co-authored by Claude Opus 5.5
parent 550aaeabac
commit c6ec7d77a2
95 changed files with 4733 additions and 164 deletions
+28
View File
@@ -0,0 +1,28 @@
import { ReservedToolNames, ReservedToolPrefixes } from "@/src/dict/custom-tool-dict";
type Params = {
name: string;
};
/**
* Why a custom tool can't take this name, or null when it can: snake_case
* of 2 to 64 characters, never a built-in tool's name or a computer tool's
* prefix, and never with `__` (MCP tools use it, `<server>__<tool>`).
*/
export default function checkCustomToolName({ name }: Params): string | null {
if (!/^[a-z][a-z0-9_]{1,63}$/.test(name)) {
return `Use lowercase letters, numbers and underscores, starting with a letter (2 to 64 characters).`;
}
if (name.includes("__")) return `Don't use a double underscore: MCP tools use it.`;
if ((ReservedToolNames as readonly string[]).includes(name)) {
return `${name} is a built-in tool's name.`;
}
const prefix = ReservedToolPrefixes.find((p) => name.startsWith(p));
if (prefix) return `Names starting with ${prefix} are kept for computers' tools.`;
return null;
}