startStreamableHttp method

Future<void> startStreamableHttp({
  1. String host = '127.0.0.1',
  2. int port = 7820,
  3. String endpoint = '/mcp',
})

Implementation

Future<void> startStreamableHttp({
  String host = '127.0.0.1',
  int port = 7820,
  String endpoint = '/mcp',
}) async {
  register();
  // Single source of truth — the config carries host/port/endpoint
  // and both the transport (which listens) and the spec (which the
  // recipe surfaces to consumers like Claude Code's --mcp-config)
  // read the path off the same object. Hosts that need a custom
  // path (e.g. `/api/mcp`, `/v2/mcp`) override [endpoint] here.
  final config = mcp.StreamableHttpServerConfig(
    host: host,
    port: port,
    endpoint: endpoint,
  );
  final t = mcp.StreamableHttpServerTransport(config: config);
  await t.start();
  _transport = t;
  server.connect(t);
  _externalSpec = McpServerSpec(
    name: name,
    transport: McpServerTransport.http,
    url: 'http://${config.host}:${config.port}${config.endpoint}',
  );
}