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
@@ -1,7 +1,7 @@
import { useState } from "react";
import Form from "@moduletrace/twui/form/Form";
import Input from "@moduletrace/twui/form/Input";
import Textarea from "@moduletrace/twui/form/Textarea";
import CodeEditor from "@/src/components/general/code-editor";
import ImagePickField from "@/src/components/general/image-pick-field";
import WorkspaceAvatar from "@/src/components/general/workspace-avatar";
import setProfileImage from "@/src/functions/frontend/set-profile-image";
@@ -82,16 +82,14 @@ export default function AddWorkspaceForm({ onCancel }: Props) {
defaultValue={description}
onChange={(e) => setDescription(e.target.value)}
/>
<Textarea
id="add-workspace-instructions"
<CodeEditor
mode="markdown"
className="h-32"
title="Context"
label="Context"
showLabel
rows={5}
placeholder="We ship on April 14. The repo is acme/launch. Marketing signs off on all copy."
defaultValue={system_prompt}
content={system_prompt}
info="Every bot working here gets this. You can change it later."
onChange={(e) => setSystemPrompt(e.target.value)}
onChange={(value) => setSystemPrompt(value)}
/>
<AddFormActions submit_label="Create workspace" loading={loading} error={error} onCancel={onCancel} />
</Form>
+6 -8
View File
@@ -1,8 +1,8 @@
import { useContext, useState } from "react";
import Form from "@moduletrace/twui/form/Form";
import Input from "@moduletrace/twui/form/Input";
import Textarea from "@moduletrace/twui/form/Textarea";
import Checkbox from "@moduletrace/twui/form/Checkbox";
import CodeEditor from "@/src/components/general/code-editor";
import type { BUN_SQLITE_COBBLE_BOTS } from "@/db/types/db";
import ImagePickField from "@/src/components/general/image-pick-field";
import { AppContext } from "@/src/pages/__root";
@@ -165,16 +165,14 @@ export default function BotForm({ bot, onCancel, onSaved }: Props) {
<BotHuePicker hue={hue} disabled={loading} onChange={setHue} />
</>
)}
<Textarea
id="bot-form-instructions"
<CodeEditor
mode="markdown"
className="h-40"
title="Instructions"
label="Instructions"
showLabel
rows={6}
placeholder="You research topics for the user. Find good sources, read them, and report back with a short summary and links."
defaultValue={system_prompt}
content={system_prompt}
info="What it does and how. It refines these itself as it learns how you work."
onChange={(e) => setSystemPrompt(e.target.value)}
onChange={(value) => setSystemPrompt(value)}
/>
{!bot && workspace?.id ? (
<Checkbox