flutter_ai_mcp 0.1.4 copy "flutter_ai_mcp: ^0.1.4" to clipboard
flutter_ai_mcp: ^0.1.4 copied to clipboard

Model Context Protocol (MCP) integration for flutter_ai: connect to MCP servers over Streamable HTTP and expose their tools as flutter_ai tools that flow through the agent loop.

example/flutter_ai_mcp_example.dart

// ignore_for_file: avoid_print
import 'package:flutter_ai_mcp/flutter_ai_mcp.dart';
import 'package:flutter_ai_tools/flutter_ai_tools.dart';

/// Connects to an MCP server over Streamable HTTP, registers its tools, and
/// shows how they become flutter_ai tools for the agent loop.
Future<void> main() async {
  final mcp = await StreamableHttpMcpConnection.connect(
    baseUrl: 'https://my-mcp-server.example.com',
    headers: {'Authorization': 'Bearer <token>'},
  );

  final registry = ToolRegistry();
  for (final spec in await mcpToolSpecs(mcp)) {
    registry.register(spec);
  }

  // registry.definitions → advertise to a provider; wire the agent loop with
  // `UseChatController(onToolCalls: (calls) => Future.wait(calls.map(registry.run)))`
  // and tool calls route back to MCP automatically.
  print('Registered ${registry.definitions.length} MCP tools.');

  await mcp.close();
}
0
likes
150
points
166
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Model Context Protocol (MCP) integration for flutter_ai: connect to MCP servers over Streamable HTTP and expose their tools as flutter_ai tools that flow through the agent loop.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#ai #llm #mcp #tool-calling #agent

License

BSD-3-Clause (license)

Dependencies

flutter_ai_core, flutter_ai_tools, mcp_client

More

Packages that depend on flutter_ai_mcp