Navigation
Flutter MCP Server: Hot Reload & Effortless Scaling - MCP Implementation

Flutter MCP Server: Hot Reload & Effortless Scaling

Flutter MCP Server: Supercharge dev workflows with real-time hot reload, effortless scaling, and cloud-native microservices. Deploy faster, build better apps.

Developer Tools
4.8(178 reviews)
267 saves
124 comments

Users create an average of 53 projects per month with this tool

About Flutter MCP Server

What is Flutter MCP Server: Hot Reload & Effortless Scaling?

Flutter MCP Server is a plugin enabling developers to build Model Context Protocol (MCP)-compliant servers directly in Flutter applications. It standardizes how large language models (LLMs) interact with your app’s data, tools, and workflows. By exposing resources (data endpoints), tools (action executors), and prompts (interaction templates), it bridges the gap between Flutter apps and LLM-driven systems. The plugin supports hot reload for rapid iteration and scales seamlessly across platforms—Android, iOS, web, and desktop—with transport options like SSE or standard I/O.

How to Use Flutter MCP Server: Hot Reload & Effortless Scaling?

Start by adding the package to your pubspec.yaml. Define your server instance with createServer(), then register components:

  • Tools: Add functions like a calculator tool with input validation and async handling
  • Resources: Expose dynamic data (e.g., current time) or static configurations via URI handlers
  • Prompts: Create reusable templates for LLM interactions, like personalized greetings

Connect to a transport layer (e.g., createSseTransport()) and ensure protocol version compatibility to maintain seamless communication with clients.

Flutter MCP Server Features

Key Features of Flutter MCP Server: Hot Reload & Effortless Scaling?

Stand out with:

  • Protocol-First Design: Built on MCP spec , ensuring compatibility with certified clients
  • Transport Flexibility: Choose between HTTP/SSE for web-scale deployments or stdio for local workflows
  • Component Granularity: Isolate data (resources), actions (tools), and UX flows (prompts) for maintainable code
  • Hot Reload Ready: Modify tool handlers or prompt templates mid-session without restarting the server

Pro tip: Use addResourceTemplate() with URI parameters to avoid boilerplate for dynamic endpoints.

Use Cases of Flutter MCP Server: Hot Reload & Effortless Scaling?

Power scenarios like:

  • LLM-Driven CLI Tools: Expose command-line utilities via stdio transport for serverless workflows
  • Real-Time Analytics Dashboards: Let LLMs query up-to-date data from resources while triggering calculations via tools
  • Cross-Platform Chatbots: Use prompts to standardize user interactions across mobile/web/desktop apps

For example, a weather app could expose a weather://current resource while letting LLMs trigger alerts via a set-notification

Flutter MCP Server FAQ

FAQ from Flutter MCP Server: Hot Reload & Effortless Scaling?

  • Q: How do I handle version mismatches?
    A: Monitor protocol updates and pin dependencies using explicit version constraints
  • Q: Can I scale horizontally?
    A: Pair with load balancers using SSE transport—each server instance runs independently
  • Q: What’s the best transport for mobile?
    A: Prefer stdio for local IPC or WebSocket-based SSE for cloud interactions

Content

Flutter MCP Server

A Flutter plugin for implementing Model Context Protocol (MCP) servers. This plugin allows Flutter applications to expose data, functionality, and interaction patterns to Large Language Model (LLM) applications in a standardized way.

Features

  • Create MCP servers with standardized protocol support
  • Expose data through Resources
  • Provide functionality through Tools
  • Define interaction patterns through Prompts
  • Multiple transport layers:
    • Standard I/O for local process communication
    • Server-Sent Events (SSE) for HTTP-based communication
  • Cross-platform support: Android, iOS, web, Linux, Windows, macOS

Protocol Version

This package implements the Model Context Protocol (MCP) specification version 2024-11-05.

The protocol version is crucial for ensuring compatibility between MCP clients and servers. Each release of this package may support different protocol versions, so it's important to:

  • Check the CHANGELOG.md for protocol version updates
  • Ensure client and server protocol versions are compatible
  • Stay updated with the latest MCP specification

Version Compatibility

  • Supported protocol version: 2024-11-05
  • Compatibility: Tested with latest MCP client implementations

For the most up-to-date information on protocol versions and compatibility, refer to the Model Context Protocol specification.

Getting Started

Installation

Add the package to your pubspec.yaml:

dependencies:
  flutter_mcp_server: ^0.1.0

Or install via command line:

flutter pub add flutter_mcp_server

Basic Usage

import 'package:flutter_mcp_server/flutter_mcp_server.dart';

void main() {
  // Create a server
  final server = FlutterMcpServer.createServer(
    name: 'Example Server',
    version: '1.0.0',
    capabilities: ServerCapabilities(
      tools: true,
      resources: true,
      prompts: true,
    ),
  );

  // Add a simple calculator tool
  server.addTool(
    name: 'calculator',
    description: 'Perform basic calculations',
    inputSchema: {
      'type': 'object',
      'properties': {
        'operation': {
          'type': 'string',
          'enum': ['add', 'subtract', 'multiply', 'divide'],
        },
        'a': {'type': 'number'},
        'b': {'type': 'number'},
      },
      'required': ['operation', 'a', 'b'],
    },
    handler: (arguments) async {
      final operation = arguments['operation'] as String;
      final a = arguments['a'] as num;
      final b = arguments['b'] as num;
      
      double result;
      switch (operation) {
        case 'add':
          result = (a + b).toDouble();
          break;
        case 'subtract':
          result = (a - b).toDouble();
          break;
        case 'multiply':
          result = (a * b).toDouble();
          break;
        case 'divide':
          if (b == 0) {
            return CallToolResult(
              content: [TextContent(text: 'Division by zero error')],
              isError: true,
            );
          }
          result = (a / b).toDouble();
          break;
        default:
          return CallToolResult(
            content: [TextContent(text: 'Unknown operation: $operation')],
            isError: true,
          );
      }
      
      return CallToolResult(
        content: [TextContent(text: result.toString())],
      );
    },
  );

  // Add a resource
  server.addResource(
    uri: 'time://current',
    name: 'Current Time',
    description: 'Get the current date and time',
    mimeType: 'text/plain',
    handler: (uri, params) async {
      final now = DateTime.now().toString();
      
      return ReadResourceResult(
        contents: [
          ResourceContent(
            resource: Resource(
              uri: uri.toString(),
              name: 'Current Time',
              mimeType: 'text/plain',
            ),
          ),
        ],
      );
    },
  );

  // Add a template prompt
  server.addPrompt(
    name: 'greeting',
    description: 'Generate a customized greeting',
    arguments: [
      PromptArgument(
        name: 'name',
        description: 'Name to greet',
        required: true,
      ),
    ],
    handler: (arguments) async {
      final name = arguments?['name'] as String? ?? 'User';
      
      return GetPromptResult(
        description: 'A friendly greeting',
        messages: [
          Message(
            role: MessageRole.user,
            content: TextContent(text: 'Hello, $name!'),
          ),
        ],
      );
    },
  );

  // Connect to transport
  final transport = FlutterMcpServer.createStdioTransport();
  await server.connect(transport);
}

Core Concepts

Server

The McpServer is your core interface to the MCP protocol. It handles connection management, protocol compliance, and message routing:

final server = FlutterMcpServer.createServer(
  name: 'My App',
  version: '1.0.0',
  capabilities: ServerCapabilities(
    tools: true,
    resources: true,
    prompts: true,
  ),
);

Resources

Resources are how you expose data to LLMs. They're similar to GET endpoints in a REST API - they provide data but shouldn't perform significant computation or have side effects:

// Static resource
server.addResource(
  uri: 'config://app',
  name: 'App Configuration',
  description: 'Application configuration data',
  mimeType: 'text/plain',
  handler: (uri, params) async {
    return ReadResourceResult(
      contents: [
        ResourceContent(
          resource: Resource(
            uri: uri.toString(),
            name: 'App Configuration',
            mimeType: 'text/plain',
          ),
        ),
      ],
    );
  },
);

// Dynamic resource with parameters
server.addResourceTemplate(
  uriTemplate: 'users://{userId}/profile',
  name: 'User Profile',
  description: 'Profile data for specific user',
  mimeType: 'text/plain',
  handler: (uri, params) async {
    final userId = params['userId'];
    // Fetch user data...
    
    return ReadResourceResult(
      contents: [
        ResourceContent(
          resource: Resource(
            uri: uri.toString(),
            name: 'User Profile',
            mimeType: 'text/plain',
          ),
        ),
      ],
    );
  },
);

Tools

Tools let LLMs take actions through your server. Unlike resources, tools are expected to perform computation and have side effects:

server.addTool(
  name: 'search-web',
  description: 'Search the web for information',
  inputSchema: {
    'type': 'object',
    'properties': {
      'query': {'type': 'string'},
      'maxResults': {'type': 'number'},
    },
    'required': ['query'],
  },
  handler: (arguments) async {
    final query = arguments['query'] as String;
    final maxResults = arguments['maxResults'] as int? ?? 5;
    
    // Perform web search...
    
    return CallToolResult(
      content: [TextContent(text: 'Search results here')],
    );
  },
);

Prompts

Prompts are reusable templates that help LLMs interact with your server effectively:

server.addPrompt(
  name: 'analyze-code',
  description: 'Analyze code for potential issues',
  arguments: [
    PromptArgument(
      name: 'code',
      description: 'Code to analyze',
      required: true,
    ),
    PromptArgument(
      name: 'language',
      description: 'Programming language',
      required: false,
    ),
  ],
  handler: (arguments) async {
    final code = arguments?['code'] as String? ?? '';
    final language = arguments?['language'] as String? ?? 'unknown';
    
    return GetPromptResult(
      description: 'Code analysis request',
      messages: [
        Message(
          role: MessageRole.user,
          content: TextContent(text: 'Please analyze this $language code:\n\n$code'),
        ),
      ],
    );
  },
);

Transport Layers

Standard I/O

For command-line tools and direct integrations:

final transport = FlutterMcpServer.createStdioTransport();
await server.connect(transport);

Server-Sent Events (SSE)

For HTTP-based communication:

final transport = FlutterMcpServer.createSseTransport(
  endpoint: '/sse',
  messagesEndpoint: '/messages',
);
await server.connect(transport);

MCP Primitives

The MCP protocol defines three core primitives that servers can implement:

Primitive Control Description Example Use
Prompts User-controlled Interactive templates invoked by user choice Slash commands, menu options
Resources Application-controlled Contextual data managed by the client application File contents, API responses
Tools Model-controlled Functions exposed to the LLM to take actions API calls, data updates

Additional Examples

Check out the example directory for a complete sample application.

Resources

Issues and Feedback

Please file any issues, bugs, or feature requests in our issue tracker.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Related MCP Servers & Clients