git-subtree-dir: aiui git-subtree-mainline:0c4826f8ccgit-subtree-split:e30ac1d106
1.2 KiB
name, description, allowed-tools
| name | description | allowed-tools |
|---|---|---|
| add-tool | Add a new AI tool (function call) to the Claude proxy for the AI to use | Bash(*), Read, Edit, Write, Glob, Grep |
Add a new tool that the AI model can call via Claude's tool_use API. The user will describe what the tool should do (e.g., "search local files", "get app status", "browse media").
Steps
-
Read the proxy: Read
packages/app/server/claude-proxy.tsto understand the existing tool_use loop andSEARCH_WEB_TOOLdefinition. -
Define the tool: Add a new tool definition following the Claude tool_use format:
const NEW_TOOL = { name: 'tool_name', description: 'What this tool does...', input_schema: { type: 'object', properties: { ... }, required: [...] } } -
Add handler: In the tool_use loop (where
search_webcalls are handled), add a handler for the new tool name. -
Implement backend: If the tool needs a new API endpoint (e.g.,
/api/media/scan), create a Vite plugin or add a route to the proxy. -
Update system prompt: Add instructions in
useAI.tsSYSTEM_PROMPT telling the AI when and how to use the new tool. -
Verify: Run
pnpm typecheckand test the proxy starts without errors.