cape2333/FutterTestMcp
If you are the rightful owner of FutterTestMcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A Model Context Protocol (MCP) server designed for Flutter integration testing, enabling UI automation test generation and execution through natural language descriptions.
Flutter Test MCP
A Model Context Protocol (MCP) server for Flutter integration testing that supports generating and executing UI automation tests through natural language descriptions.
Features
- ā Natural language-driven test generation
- ā Complete UI operation support (tap, scroll, text input, etc.)
- ā Smart waiting and delay mechanisms
- ā Text and element verification
- ā Screenshot functionality
- ā Test execution and reporting
- ā Device management
Installation
- Clone the repository
git clone https://github.com/your-username/flutter-test-mcp.git
cd flutter-test-mcp
- Install dependencies
pnpm install
- Build the project
pnpm run build
Usage
Start the MCP Server
pnpm start
Configure in Claude Code
Add to your Claude Code MCP configuration:
{
"mcpServers": {
"flutter-test": {
"command": "node",
"args": ["/path/to/flutter-test-mcp/dist/index.js"]
}
}
}
Main Tools
1. generate_flutter_test
Generate Flutter integration test code from natural language descriptions
Parameters:
description
: Natural language description of the test scenariotestName
: Test case nameprojectPath
: Flutter project path
Example:
Description: "Tap login button, enter username admin, enter password 123456, tap confirm button, verify welcome text is displayed"
2. run_integration_test
Execute Flutter integration tests
Parameters:
projectPath
: Flutter project pathtestFile
: Test file pathdevice
: Device ID (optional)
3. UI Operation Tools
tap_element - Tap Element
finder
: Finding method (text, key, type, etc.)value
: Finding value
enter_text - Enter Text
finder
: Input field finding methodvalue
: Input field finding valuetext
: Text to enter
scroll - Scroll
direction
: Scroll direction (up, down, left, right)distance
: Scroll distance (pixels)
4. Wait and Verification Tools
wait_for_element - Wait for Element
finder
: Element finding methodvalue
: Finding valuetimeout
: Timeout in seconds
verify_text_exists - Verify Text Exists
text
: Text to verifyshouldExist
: Whether the text should exist
delay - Delay
seconds
: Delay duration in seconds
Natural Language Parsing
Supported operation types:
Tap Operations
- "Tap login button"
- "Click 'Submit' button"
- "Press the confirm button"
Input Operations
- "Enter username 'admin'"
- "Type password '123456'"
- "Fill email address 'test@example.com'"
Scroll Operations
- "Scroll down"
- "Swipe up"
- "Slide left"
Wait Operations
- "Wait 2 seconds"
- "Delay 1.5 seconds"
- "Pause for 500 milliseconds"
Verification Operations
- "Verify page shows 'Login successful'"
- "Confirm 'Welcome' text exists"
- "Check 'Error' message does not exist"
Element Finding Methods
Method | Description | Example |
---|---|---|
text | Find by text | find.text('Login') |
key | Find by Key | find.byKey(Key('login_btn')) |
type | Find by type | find.byType(ElevatedButton) |
icon | Find by icon | find.byIcon(Icons.home) |
tooltip | Find by tooltip | find.byTooltip('Tap to login') |
semantics | Find by semantics | find.bySemanticsLabel('Login button') |
Test File Generation Example
Input description:
"Open app, tap login button, enter username admin, enter password 123456, tap confirm, wait 2 seconds, verify welcome page is displayed"
Generated test code:
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:myapp/main.dart' as app;
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
group('User Login Test', () {
testWidgets('Open app, tap login button, enter username admin, enter password 123456, tap confirm, wait 2 seconds, verify welcome page is displayed', (WidgetTester tester) async {
// Start app
app.main();
await tester.pumpAndSettle();
// Tap login button
await tester.tap(find.text('login button'));
await tester.pumpAndSettle();
// Enter username admin
await tester.enterText(find.text('username'), 'admin');
await tester.pumpAndSettle();
// Enter password 123456
await tester.enterText(find.text('password'), '123456');
await tester.pumpAndSettle();
// Tap confirm
await tester.tap(find.text('confirm'));
await tester.pumpAndSettle();
// Wait 2 seconds
await Future.delayed(Duration(milliseconds: 2000));
// Verify welcome page exists
expect(find.text('welcome page'), findsOneWidget);
});
});
}
Development
Project Structure
src/
āāā index.ts # MCP server main entry
āāā generators/
ā āāā test-generator.ts # Test code generator
āāā tools/
ā āāā test-runner.ts # Test executor
ā āāā ui-actions.ts # UI action tools
ā āāā wait-actions.ts # Wait action tools
āāā utils/
āāā logger.ts # Logger utility
Development Mode
pnpm run dev
Build
pnpm run build
Contributing
Issues and Pull Requests are welcome!
License
MIT License