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]>
25 lines
729 B
TypeScript
25 lines
729 B
TypeScript
import BunSQLite from "@moduletrace/bun-sqlite";
|
|
import type { BUN_SQLITE_COBBLE_MCP_SERVERS } from "@/db/types/db";
|
|
import AppError from "@/src/utils/app-error";
|
|
import parseMcpServerRow from "./parse-mcp-server-row";
|
|
|
|
type Params = {
|
|
mcp_server_id: number | string;
|
|
};
|
|
|
|
/**
|
|
* One MCP server, or an `AppError` when there's none.
|
|
*/
|
|
export default async function grabMcpServer({ mcp_server_id }: Params) {
|
|
const row = (
|
|
await BunSQLite.sql<BUN_SQLITE_COBBLE_MCP_SERVERS>({
|
|
sql: `SELECT * FROM mcp_servers WHERE id = ?`,
|
|
values: [mcp_server_id],
|
|
})
|
|
).payload?.[0];
|
|
|
|
if (!row) throw new AppError(`That MCP server doesn't exist.`);
|
|
|
|
return parseMcpServerRow({ row });
|
|
}
|