flutter_ai_mcp 0.1.1
flutter_ai_mcp: ^0.1.1 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.
flutter_ai_mcp #
☕ Support this project #
If flutter_ai saves you time, buy me a coffee ☕ — it keeps the whole family maintained.
Model Context Protocol integration for the
flutter_ai family. Connect to MCP servers over Streamable
HTTP and expose their tools as flutter_ai tools that flow through the agent
loop — no glue code.
Usage #
import 'package:flutter_ai_mcp/flutter_ai_mcp.dart';
import 'package:flutter_ai_tools/flutter_ai_tools.dart';
// 1. Connect to an MCP server.
final mcp = await StreamableHttpMcpConnection.connect(
baseUrl: 'https://my-mcp-server.example.com',
headers: {'Authorization': 'Bearer <token>'},
);
// 2. Adapt its tools into flutter_ai tools.
final registry = ToolRegistry();
for (final spec in await mcpToolSpecs(mcp)) {
registry.register(spec);
}
// 3. Advertise + run them through the agent loop.
final controller = UseChatController(
provider: provider,
tools: registry.definitions,
onToolCalls: (calls) => Future.wait(calls.map(registry.run)),
);
Scope #
- Streamable HTTP only. stdio is desktop-only (subprocess) and out of scope for a mobile-first toolkit.
- Bring your own transport by implementing
McpConnectionif you prefer a different MCP client;mcpToolSpecsworks with any implementation.
Status #
0.1.0. Built on mcp_client.
