Give bots tools and MCP servers per bot and workspace, with status and tests

- Bots and workspaces get tools and MCP servers from their settings
  pages; bots also from chips under the chat composer, removable there
- "Every bot" now gives one to every bot now and every new bot; each can
  still drop it (attach-every-bot-extensions.ts moves old installs over)
- Status lines: MCP servers record whether they connect, tools whether
  their last run worked
- Test connection in the MCP form and a Test panel in the tool form check
  the form as it is, without saving
- Hide Google sign-in on the login form

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-19 15:35:13 +01:00
co-authored by Claude Opus 5.5
parent c6ec7d77a2
commit 6294b911e6
69 changed files with 2026 additions and 271 deletions
+44
View File
@@ -0,0 +1,44 @@
import grabSuperAdminUser from "@/src/functions/backend/backups/grab-super-admin-user";
import testMcpDraft from "@/src/functions/backend/db/extensions/test-mcp-draft";
import { TestMcpServerRequestSchema } from "@/src/schemas/extension-schema";
import type { McpServerTestPayload } from "@/src/types";
import AppError from "@/src/utils/app-error";
import parseWithSchema from "@/src/utils/parse-with-schema";
import safeErrorMessage from "@/src/utils/safe-error-message";
import type {
APIResponseObject,
BunextAPIRouteHandler,
} from "@moduletrace/bunext/types";
/**
* Super admin only: connects to an MCP server as the form has it, saved or
* not, and returns its tools or why it didn't connect. Nothing is saved.
*/
export const handler: BunextAPIRouteHandler<
APIResponseObject<McpServerTestPayload>
> = async ({ req, body }) => {
try {
if (req.method != "POST") {
throw new AppError(`Method not allowed`);
}
const user = await grabSuperAdminUser({ req });
if (!user?.id) {
throw new AppError(`Only a super admin can do that.`);
}
const data = parseWithSchema({ schema: TestMcpServerRequestSchema, data: body });
const result = await testMcpDraft({ data });
return {
success: true,
msg: result.ok
? `Connected: ${result.tools.length} ${result.tools.length == 1 ? "tool" : "tools"}.`
: `Couldn't connect.`,
singleRes: result.ok ? { ok: true, tools: result.tools } : { ok: false, tools: [], error: result.error },
};
} catch (error: unknown) {
return { success: false, msg: safeErrorMessage({ error }) };
}
};