McpBuilder class
Declarative MCP capability builder.
Use inside McpController.configure to register tools, resources,
prompts, resource templates, and custom method handlers — all in one
place, without boilerplate.
@override
void configure(McpBuilder mcp) {
mcp.tool(
name: 'search',
description: 'Search the documentation',
handler: (req) async {
final query = req.params.arguments?['query'] as String? ?? '';
return CallToolResult(content: [TextContent(text: '...')]);
},
);
mcp.resource(
name: 'readme',
uri: rq.url(''),
handler: (req) async => ReadResourceResult(contents: [...]),
);
}
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
buildPromptsResult(
) → ListPromptsResult -
buildResourcesResult(
) → ListResourcesResult -
buildResourceTemplatesResult(
) → ListResourceTemplatesResult -
buildToolsResult(
) → ListToolsResult -
method(
String name, MethodHandler handler) → void - Register a custom MCP method handler.
-
methodHandler(
String name) → MethodHandler? -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
prompt(
{required String name, String? title, String? description, List< PromptArgument> ? arguments, required PromptHandler handler}) → void - Register an MCP prompt.
-
promptHandler(
String name) → PromptHandler? -
resource(
{required String name, required String uri, String? title, String? description, String? mimeType, required ResourceHandler handler}) → void - Register a readable MCP resource.
-
resourceHandlerByUri(
String uri) → ResourceHandler? -
Look up a resource handler for an incoming
resources/readURI. -
resourceTemplate(
{required String name, required String uriTemplate, String? title, String? description, String? mimeType}) → void - Register a resource URI template.
-
tool(
{required String name, String? title, String? description, ToolSchema? inputSchema, ToolSchema? outputSchema, ToolAnnotations? annotations, required ToolHandler handler}) → void - Register an MCP tool.
-
toolHandler(
String name) → ToolHandler? -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited