flutter_ai_mcp

Model Context Protocol for flutter_ai — connect to MCP servers over Streamable HTTP and expose their tools to the agent loop with no glue code.

flutter_ai streaming chat — the agent loop MCP tools plug into

flutter_ai_mcp on pub.dev pub points License: BSD-3-Clause

Family: flutter_ai · core · client · elements · tools · voice
Recipes · Migrating from the Vercel AI SDK


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

Driving the agent loop uses flutter_ai_client — add it to your pubspec.yaml alongside flutter_ai_mcp and flutter_ai_tools.

import 'package:flutter_ai_client/flutter_ai_client.dart';
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, signal) => 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 McpConnection if you prefer a different MCP client; mcpToolSpecs works with any implementation.

Status

Published on pub.dev (see the CHANGELOG). Built on mcp_client.

If flutter_ai saves you time, you can buy me a coffee ☕.

Libraries

flutter_ai_mcp
Model Context Protocol (MCP) integration for the flutter_ai family.