Overview
What is MCP Server?
MCP Server is a Dart plugin for implementing Model Context Protocol (MCP) servers. It allows Flutter applications to expose data, functionality, and interaction patterns to Large Language Model (LLM) applications in a standardized way.
How to use MCP Server?
Install the package and create a Server instance with a name, version, and capabilities. Add handlers for tools, resources, and prompts, then connect to a transport (stdio, SSE, or Streamable HTTP). Use the simplified McpServer.createAndStart API or the classic connect method. Configuration of transports is done via TransportConfig objects.
Key features of MCP Server
- Multi-revision MCP support with per-version capability gating
- Core primitives: Resources, Tools, Prompts, and Completions
- Server-initiated requests (sampling, roots, elicitation)
- OAuth 2.1 Resource Server (RFC 9728) with Bearer token validation
- Structured tool output and resource links (2025-06-18+)
- Icons on tools, resources, and prompts (2025-11-25)
- List-changed notifications and progress/cancellation support
- Multiple transports: stdio, SSE, Streamable HTTP
- Cross-platform: Android, iOS, web, Linux, Windows, macOS
Use cases of MCP Server
- Expose application data to LLMs via static or templated resources
- Give LLMs the ability to perform actions with tools (e.g., calculators, file access)
- Provide reusable prompt templates that guide LLM interactions
- Build custom MCP servers that integrate with existing Dart/Flutter apps
FAQ from MCP Server
What protocol versions does MCP Server support?
It supports four revisions: 2024-11-05 (original), 2025-03-26 (earlier 2025 revision), 2025-06-18 (adds elicitation, structured tool output, OAuth), and 2025-11-25 (adds icons, sampling tool calling).
What transport options are available?
STDIO, SSE, and Streamable HTTP (with SSE streaming or JSON response mode). Each is configurable via TransportConfig constructors.
Does MCP Server work on multiple platforms?
Yes, it supports Android, iOS, web, Linux, Windows, and macOS.
How do I configure server capabilities?
Capabilities can be set with simple booleans via ServerCapabilities.simple() or with advanced object-based configuration using ServerCapabilities with detailed sub-capabilities.
What happens if a tool handler returns an error?
Handlers can return CallToolResult with isError: true to signal failure to the LLM, as shown in the division-by-zero example.