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]>
34 lines
933 B
TypeScript
34 lines
933 B
TypeScript
import type { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
import { AppData } from "@/src/data/app-data";
|
|
import type { McpToolInfo } from "@/src/types";
|
|
|
|
type Params = {
|
|
client: Client;
|
|
};
|
|
|
|
/**
|
|
* Every tool an MCP server offers, page by page.
|
|
*/
|
|
export default async function listMcpTools({ client }: Params): Promise<McpToolInfo[]> {
|
|
const tools: McpToolInfo[] = [];
|
|
let cursor: string | undefined;
|
|
|
|
do {
|
|
const page = await client.listTools(cursor ? { cursor } : undefined, {
|
|
timeout: AppData.McpConnectTimeoutMs,
|
|
});
|
|
|
|
for (const tool of page.tools) {
|
|
tools.push({
|
|
name: tool.name,
|
|
description: tool.description || tool.title || tool.name,
|
|
input_schema: tool.inputSchema as Record<string, unknown>,
|
|
});
|
|
}
|
|
|
|
cursor = page.nextCursor;
|
|
} while (cursor);
|
|
|
|
return tools;
|
|
}
|