annotationsDefault property
Server-wide default values for tool annotation hints.
When set, the 4 boolean hints (ToolAnnotations.readOnlyHint,
ToolAnnotations.destructiveHint, ToolAnnotations.idempotentHint,
ToolAnnotations.openWorldHint) are applied as defaults to every
generated tool. Individual tools can override any hint via their own
@Tool(annotations: ToolAnnotations(...)).
Merge rules:
- Tool-level values always take precedence over server defaults for the same key.
- The ToolAnnotations.title field is never inherited from server defaults; each tool must provide its own title.
- If neither server defaults nor tool-level annotations exist for a tool, no annotations are emitted for that tool.
Example:
@Server(
annotationsDefault: ToolAnnotations(openWorldHint: false),
)
class MyService {
@Tool(annotations: ToolAnnotations(readOnlyHint: true))
// → merged: {readOnlyHint: true, openWorldHint: false}
Future<User> getUser(int id) async { ... }
@Tool(description: 'Create user')
// → merged: {openWorldHint: false} (server default only)
Future<User> createUser(String name) async { ... }
}
Defaults to null (no server-wide annotation defaults).
Implementation
final ToolAnnotations? annotationsDefault;