From 6fc03a4bee2a888ae4b340d52b736ba9af4112c3 Mon Sep 17 00:00:00 2001 From: Norbert515 Date: Thu, 12 Feb 2026 22:01:54 +0100 Subject: [PATCH 1/2] feat: add --flutter-mcp flag to host Flutter MCP server via stdio Add startStdio() to McpServerBase so any MCP server can be run in stdio mode. Wire it into the CLI as `vide --flutter-mcp`, making it easy to configure in Claude Desktop or other MCP clients without needing to point at the standalone binary. --- lib/cli/vide_command_runner.dart | 14 +++++++++++++- .../lib/src/mcp/server/mcp_server_base.dart | 18 ++++++++++++++++++ packages/flutter_runtime_mcp/bin/main.dart | 15 +-------------- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/lib/cli/vide_command_runner.dart b/lib/cli/vide_command_runner.dart index c5e394ef..c0ac0884 100644 --- a/lib/cli/vide_command_runner.dart +++ b/lib/cli/vide_command_runner.dart @@ -2,6 +2,7 @@ import 'dart:io'; import 'package:args/args.dart'; import 'package:args/command_runner.dart'; +import 'package:flutter_runtime_mcp/flutter_runtime_mcp.dart'; import 'package:vide_cli/cli/connect_command.dart'; import 'package:vide_cli/cli/daemon_command.dart'; import 'package:vide_cli/cli/session_server_command.dart'; @@ -32,7 +33,12 @@ class VideCommandRunner extends CommandRunner { negatable: false, help: 'Force local session mode (ignore daemon setting)', ) - ..addFlag('daemon', negatable: false, help: 'Force daemon session mode'); + ..addFlag('daemon', negatable: false, help: 'Force daemon session mode') + ..addFlag( + 'flutter-mcp', + negatable: false, + help: 'Run as a standalone Flutter MCP server (stdio mode)', + ); addCommand(DaemonCommand()); addCommand(ConnectCommand()); @@ -44,6 +50,7 @@ class VideCommandRunner extends CommandRunner { EXAMPLES: vide Launch interactive TUI + vide --flutter-mcp Run Flutter MCP server (stdio) vide daemon start Start daemon on port 8080 vide daemon start --port 9000 Start daemon on port 9000 vide daemon start --detach Start daemon in background @@ -71,6 +78,11 @@ SAFETY: return; } + if (topLevelResults['flutter-mcp'] as bool) { + await FlutterRuntimeServer().startStdio(); + return; + } + if (topLevelResults.command != null) { await super.runCommand(topLevelResults); return; diff --git a/packages/claude_sdk/lib/src/mcp/server/mcp_server_base.dart b/packages/claude_sdk/lib/src/mcp/server/mcp_server_base.dart index d4020a64..4433e5f9 100644 --- a/packages/claude_sdk/lib/src/mcp/server/mcp_server_base.dart +++ b/packages/claude_sdk/lib/src/mcp/server/mcp_server_base.dart @@ -106,6 +106,24 @@ abstract class McpServerBase { } } + /// Start the server in stdio mode (for standalone MCP hosting). + /// + /// Unlike [start], this uses stdin/stdout for communication instead of HTTP. + /// The returned future completes when the transport is closed. + Future startStdio() async { + _mcpServer = McpServer( + Implementation(name: name, version: version), + options: ServerOptions( + capabilities: ServerCapabilities(tools: ServerCapabilitiesTools()), + ), + ); + + registerTools(_mcpServer!); + + final transport = StdioServerTransport(); + await _mcpServer!.connect(transport); + } + /// Stop the server Future stop() async { await onStop(); diff --git a/packages/flutter_runtime_mcp/bin/main.dart b/packages/flutter_runtime_mcp/bin/main.dart index 9dd1638f..244f41d0 100644 --- a/packages/flutter_runtime_mcp/bin/main.dart +++ b/packages/flutter_runtime_mcp/bin/main.dart @@ -1,18 +1,5 @@ import 'package:flutter_runtime_mcp/flutter_runtime_mcp.dart'; -import 'package:mcp_dart/mcp_dart.dart'; void main() async { - final flutterRuntime = FlutterRuntimeServer(); - - final mcpServer = McpServer( - Implementation(name: FlutterRuntimeServer.serverName, version: '1.0.0'), - options: ServerOptions( - capabilities: ServerCapabilities(tools: ServerCapabilitiesTools()), - ), - ); - - flutterRuntime.registerTools(mcpServer); - - final transport = StdioServerTransport(); - await mcpServer.connect(transport); + await FlutterRuntimeServer().startStdio(); } From f1afd0eb3ff2a04ddd85d3526da6c8f85ab5c850 Mon Sep 17 00:00:00 2001 From: Norbert515 Date: Thu, 12 Feb 2026 22:04:15 +0100 Subject: [PATCH 2/2] docs: add standalone Flutter MCP usage to README --- packages/flutter_runtime_mcp/README.md | 54 +++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/packages/flutter_runtime_mcp/README.md b/packages/flutter_runtime_mcp/README.md index e12c2d64..6cd6ba41 100644 --- a/packages/flutter_runtime_mcp/README.md +++ b/packages/flutter_runtime_mcp/README.md @@ -24,9 +24,49 @@ dependencies: path: ../packages/flutter_runtime_mcp ``` -## Usage +## Standalone Usage -### Starting the Server +The easiest way to use the Flutter MCP independently is via vide: + +```bash +vide --flutter-mcp +``` + +This starts the Flutter MCP server in stdio mode, ready for any MCP client. + +### Claude Code + +Add to `.claude/settings.local.json`: + +```json +{ + "mcpServers": { + "flutter-runtime": { + "command": "vide", + "args": ["--flutter-mcp"] + } + } +} +``` + +### Claude Desktop + +Add to your Claude Desktop config (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS): + +```json +{ + "mcpServers": { + "flutter-runtime": { + "command": "vide", + "args": ["--flutter-mcp"] + } + } +} +``` + +## Programmatic Usage + +### Starting the Server (HTTP) ```dart import 'package:flutter_runtime_mcp/flutter_runtime_mcp.dart'; @@ -39,6 +79,16 @@ void main() async { } ``` +### Starting the Server (stdio) + +```dart +import 'package:flutter_runtime_mcp/flutter_runtime_mcp.dart'; + +void main() async { + await FlutterRuntimeServer().startStdio(); +} +``` + ### MCP Tools #### flutterStart