HttpTemplate class
Generates HTTP server code from tool definitions using dart_mcp.
This template creates a complete HTTP MCP server that:
- Uses the shelf package for HTTP request handling
- Supports configurable port and bind address
- Implements bidirectional communication via StreamChannel
- Registers all tools with their JSON schemas
- Handles tool execution with proper error handling
The generated server uses conditional imports for dart:io only when
the default loopback address (127.0.0.1) is specified, avoiding unused
import warnings for custom addresses.
Example generated server configuration:
// Default address uses InternetAddress type
await shelf_io.serve(handler, io.InternetAddress.loopbackIPv4, 3000);
// Custom address uses string literal
await shelf_io.serve(handler, '0.0.0.0', 8080);
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
-
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