generateCodeModeToolRegistrations function

String generateCodeModeToolRegistrations()

Generates the search and execute tool registrations for code mode.

Implementation

String generateCodeModeToolRegistrations() {
  return '''
    registerTool(
      Tool(
        name: 'search',
        description: 'Search for available tools by name or description. Returns matching tools with their parameter information. Use this to discover available tools before calling execute.',
        inputSchema: Schema.object(
          properties: {
            'query': Schema.string(
              description: 'Search terms. Space-separated terms are AND-matched against tool names and descriptions (case-insensitive).',
            ),
            'detail_level': UntitledSingleSelectEnumSchema(
              description: 'Level of detail: "brief" (name + description), "detailed" (+ parameter names/types/required), "full" (+ complete parameter schemas).',
              values: ['brief', 'detailed', 'full'],
            ),
          },
          required: ['query'],
        ),
      ),
      _search,
    );
    registerTool(
      Tool(
        name: 'execute',
        description: 'Execute JavaScript code with access to MCP tool functions. Use call_tool(name, params) to call any tool by name, or use external_<toolName>(args) convenience wrappers. Use the search tool first to discover available tools and their signatures. All calls are async - use await for sequential calls and Promise.all() for parallel calls. Return a value to include it in the result.',
        inputSchema: Schema.object(
          properties: {
            'code': Schema.string(
              description: 'JavaScript code to execute.',
            ),
          },
          required: ['code'],
        ),
      ),
      _execute,
    );''';
}