McpBuilder class
Builder that generates MCP server code from @Server and @Tool annotations.
This builder processes Dart files containing MCP annotations and generates:
.mcp.dartfiles containing the complete MCP server implementation.mcp.jsonfiles containing tool metadata (if generateJson is true)
The builder supports two transport modes:
- stdio: JSON-RPC over standard input/output (default)
- http: HTTP server using the shelf package
For HTTP transport, the builder extracts port and address configuration from the @Server annotation to customize the server binding.
Example generated files:
my_server.mcp.dart- Complete MCP server with tool handlersmy_server.mcp.json- Tool metadata with JSON schemas
Constructors
Properties
-
buildExtensions
→ Map<
String, List< String> > -
Mapping from input file extension to output file extensions.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
build(
BuildStep buildStep) → Future< void> -
Generates the outputs for a given
BuildStep. -
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