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:
@@ -0,0 +1,33 @@
|
||||
import type { BUN_SQLITE_COBBLE_MCP_SERVERS } from "@/db/types/db";
|
||||
import type { McpServerStatus, McpTransport } from "@/src/dict/mcp-dict";
|
||||
import type { McpServerRecord, McpToolInfo } from "@/src/types";
|
||||
import parseJsonColumn from "./parse-json-column";
|
||||
|
||||
type Params = {
|
||||
row: BUN_SQLITE_COBBLE_MCP_SERVERS;
|
||||
};
|
||||
|
||||
/**
|
||||
* An `mcp_servers` row with its JSON columns read.
|
||||
*/
|
||||
export default function parseMcpServerRow({ row }: Params): McpServerRecord {
|
||||
return {
|
||||
id: Number(row.id),
|
||||
name: row.name || "",
|
||||
slug: row.slug || "",
|
||||
description: row.description || "",
|
||||
transport: (row.transport || "remote") as McpTransport,
|
||||
url: row.url || "",
|
||||
headers: parseJsonColumn<Record<string, string>>({ text: row.headers, fallback: {} }),
|
||||
command: row.command || "",
|
||||
setup_command: row.setup_command || "",
|
||||
env: parseJsonColumn<Record<string, string>>({ text: row.env, fallback: {} }),
|
||||
excluded_tools: parseJsonColumn<string[]>({ text: row.excluded_tools, fallback: [] }),
|
||||
tools: parseJsonColumn<McpToolInfo[]>({ text: row.tools_cache, fallback: [] }),
|
||||
all_bots: row.all_bots == 1,
|
||||
enabled: row.enabled != 0,
|
||||
status: (row.status || "untested") as McpServerStatus,
|
||||
last_error: row.last_error || "",
|
||||
last_synced_at: typeof row.last_synced_at == "number" ? row.last_synced_at : null,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user