Skip to main content
Glama

Flutter Inspector MCP Server

stateful_widget_example.dart1.92 kB
import 'package:flutter/material.dart'; import 'package:mcp_toolkit/mcp_toolkit.dart'; // StatefulWidget counter example class StatefulCounterWidget extends StatefulWidget { const StatefulCounterWidget({super.key}); @override State<StatefulCounterWidget> createState() => _StatefulCounterWidgetState(); } class _StatefulCounterWidgetState extends State<StatefulCounterWidget> { int _counter = 0; @override void initState() { super.initState(); _registerCounterTool(); } void _registerCounterTool() { addMcpTool( MCPCallEntry.tool( handler: (request) { return MCPCallResult( message: 'StatefulWidget counter value', parameters: {'counter': _counter}, ); }, definition: MCPToolDefinition( name: 'get_stateful_counter', description: 'Get the current StatefulWidget counter value', inputSchema: ObjectSchema(properties: {}), ), ), ); } void _incrementCounter() { setState(() { _counter++; }); } @override Widget build(BuildContext context) { return Container( padding: const EdgeInsets.all(16), decoration: BoxDecoration( border: Border.all(color: Colors.grey.shade300), borderRadius: BorderRadius.circular(8), ), child: Column( children: [ const Text( 'StatefulWidget', style: TextStyle(fontWeight: FontWeight.bold), ), const SizedBox(height: 8), Text( '$_counter', style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold), ), const SizedBox(height: 8), ElevatedButton.icon( onPressed: _incrementCounter, icon: const Icon(Icons.add, size: 16), label: const Text('Increment'), ), ], ), ); } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Arenukvern/mcp_flutter'

If you have feedback or need assistance with the MCP directory API, please join our Discord server