tool method

void tool({
  1. required String name,
  2. String? title,
  3. String? description,
  4. ToolSchema? inputSchema,
  5. ToolSchema? outputSchema,
  6. ToolAnnotations? annotations,
  7. required ToolHandler handler,
})

Register an MCP tool.

inputSchema defaults to ToolSchema(type: 'object') when omitted.

Implementation

void tool({
  required String name,
  String? title,
  String? description,
  ToolSchema? inputSchema,
  ToolSchema? outputSchema,
  ToolAnnotations? annotations,
  required ToolHandler handler,
}) {
  _tools[name] = _ToolEntry(
    Tool(
      name: name,
      title: title,
      description: description,
      inputSchema: inputSchema ?? ToolSchema(type: 'object'),
      outputSchema: outputSchema,
      annotations: annotations,
    ),
    handler,
  );
}