PackageUseCaseTool<T extends Object> class
A ready-made McpTool adapter that resolves a usecase from a DI container and invokes it (spec 025, FR-008).
The tool executes against the container the package's module
registered into — the package's own dependency context — so the tool
never hand-constructs its dependencies. Errors (unregistered usecase,
execution failure) surface as isError results, never as exceptions
across the tool boundary.
PackageUseCaseTool<GetProductUseCase>(
name: 'get_product',
description: 'Fetches a product by id',
container: engine.di,
invoke: (usecase, args) async =>
usecase(GetProductParams(id: args['id'] as String)),
)
- Implemented types
Constructors
-
PackageUseCaseTool({required String name, required String description, required ZuraffaDIContainer container, required PackageUseCaseInvoker<
T> invoke, Map<String, dynamic> inputSchema = const {'type' : 'object', 'additionalProperties' : true}})
Properties
- container → ZuraffaDIContainer
-
The container the usecase is resolved from (the consuming app's
container, populated by the package's registrar).
final
- description → String
-
Human/AI-facing description. Should explain what the tool does,
what its arguments mean, and what it returns.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
inputSchema
→ Map<
String, dynamic> -
JSON Schema (draft-07 subset) describing the call arguments.
The runtime server forwards this verbatim to the MCP client in
the
tools/listresponse.final -
invoke
→ PackageUseCaseInvoker<
T> -
Maps the tool arguments to a usecase invocation and returns its
result.
final
- name → String
-
Stable, unique tool name (snake_case). Used by the MCP client
to invoke this tool via
tools/call.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
call(
Map< String, dynamic> arguments) → Future<McpToolResult> -
Invokes the tool with the named
argumentsfrom atools/callrequest. Implementations should validate inputs defensively (the MCP client is untrusted) and return an McpToolResult — never throw across the JSON-RPC boundary.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited