selectServerToolsForPrompt
selectServerToolsForPrompt(
options:SelectServerToolsForPromptOptions):Promise<ServerTool[]>
Defined in: src/lib/tools/serverTools.ts:1177
Select server-side tools for a prompt using the same path
useChatStorage runs internally. Use this anywhere outside the chat
hook — background-task workers, server scripts, debug tools — that needs
the same selection the chat flow would produce.
Mirrors the responses-API branch of sendMessage: fetch catalog with
caching, optionally embed the prompt (only when the filter is a function),
apply the filter, return matching ServerTool[] (with embeddings and
descriptions intact for downstream serialization).
Returns [] on any of: undefined/empty filter, empty prompt for a
function filter, failed catalog fetch, or failed embedding.
Parameters
| Parameter | Type |
|---|---|
|
|
Returns
Promise<ServerTool[]>
Example
import { defaultServerToolsFilter, selectServerToolsForPrompt } from "@anuma/sdk/server";
const tools = await selectServerToolsForPrompt({
prompt: "Generate a slide deck about AI",
serverToolsFilter: defaultServerToolsFilter,
getToken: async () => identityToken,
baseUrl: process.env.API_URL,
});