codeMode property

bool codeMode
final

Whether this tool should be available in code mode.

Only meaningful when the parent Server annotation has codeMode: true. When true (the default), this tool is:

  • Listed in the search tool's results so LLMs can discover it
  • Available as an async JavaScript function named external_<toolName> in the execute tool's sandbox
  • Callable via the generic call_tool(name, params) function

Set to false for tools that should not be available in code mode, such as destructive operations that require explicit confirmation. Tools with codeMode: false are excluded from the search index and the sandbox environment entirely.

Note: This controls sandbox availability, not whether the tool appears in the standard tools/list response. See codeModeVisible for tool list visibility.

Example:

@Tool(description: 'Delete a user', codeMode: false)
Future<bool> deleteUser(int id) async { ... }

Defaults to true.

Implementation

final bool codeMode;