Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/cli/vide_command_runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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/serve_command.dart';
import 'package:vide_cli/cli/session_server_command.dart';
Expand Down Expand Up @@ -32,7 +33,12 @@ class VideCommandRunner extends CommandRunner<void> {
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(ServeCommand());
addCommand(ConnectCommand());
Expand All @@ -44,6 +50,7 @@ class VideCommandRunner extends CommandRunner<void> {

EXAMPLES:
vide Launch interactive TUI
vide --flutter-mcp Run Flutter MCP server (stdio)
vide serve Start daemon on port 8080
vide serve --port 9000 Start daemon on port 9000
vide serve --generate-token Start with auto-generated auth token
Expand All @@ -67,6 +74,11 @@ SAFETY:
return;
}

if (topLevelResults['flutter-mcp'] as bool) {
await FlutterRuntimeServer().startStdio();
return;
}

if (topLevelResults.command != null) {
await super.runCommand(topLevelResults);
return;
Expand Down
18 changes: 18 additions & 0 deletions packages/claude_sdk/lib/src/mcp/server/mcp_server_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> 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<void> stop() async {
await onStop();
Expand Down
54 changes: 52 additions & 2 deletions packages/flutter_runtime_mcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
Expand Down
15 changes: 1 addition & 14 deletions packages/flutter_runtime_mcp/bin/main.dart
Original file line number Diff line number Diff line change
@@ -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();
}