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
+30 -3
View File
@@ -1,4 +1,5 @@
import type { Client } from "@modelcontextprotocol/sdk/client/index.js";
import recordMcpServerConnection from "@/src/functions/backend/db/extensions/record-mcp-server-connection";
import type { McpServerRecord } from "@/src/types";
import fillTemplate from "@/src/utils/fill-template";
import connectMcpServer from "./connect-mcp-server";
@@ -17,13 +18,39 @@ type Params = {
* How one run reaches an MCP server, without connecting yet: `client()`
* connects on the first call and is reused after. A remote server gets
* its own connection for the run (closed by `close`); a stdio server is
* shared through the process's pool and keeps running.
* shared through the process's pool and keeps running. Whether it
* connected is saved on the server when that changes
* (`recordMcpServerConnection`).
*/
export default function openMcpServer({ server, envs, signal }: Params) {
let remote: Promise<Client> | undefined;
let recorded = false;
/**
* Once per run: an error every time (its message may change), a
* success only when the server was failing.
*/
const record = <T>(connecting: Promise<T>) =>
connecting.then(
async (client) => {
if (!recorded && server.status != "ok") await recordMcpServerConnection({ mcp_server_id: server.id });
recorded = true;
return client;
},
async (error: unknown) => {
if (!signal?.aborted) {
await recordMcpServerConnection({
mcp_server_id: server.id,
error: error instanceof Error ? error.message : String(error),
});
}
throw error;
},
);
const client = () => {
if (server.transport == "stdio") return grabStdioMcpClient({ server, envs });
if (server.transport == "stdio") return record(grabStdioMcpClient({ server, envs }));
remote ||= connectMcpServer({
url: fillTemplate({ template: server.url, envs }),
@@ -36,7 +63,7 @@ export default function openMcpServer({ server, envs, signal }: Params) {
throw error;
});
return remote;
return record(remote);
};
const close = async () => {