tree: 1f228c5cefb8f3e361ffcf24fd719fed745dc5b2 [search]
  1. elicitations_client.dart
  2. elicitations_server.dart
  3. multi_version_client.dart
  4. multi_version_server.dart
  5. prompts_and_completions_client.dart
  6. prompts_and_completions_server.dart
  7. README.md
  8. resources_client.dart
  9. resources_server.dart
  10. roots_and_logging_client.dart
  11. roots_and_logging_server.dart
  12. sampling_client.dart
  13. sampling_server.dart
  14. streamable_http_client.dart
  15. streamable_http_server.dart
  16. tools_client.dart
  17. tools_server.dart
pkgs/dart_mcp/example/README.md

Client and Server examples

For each client or server feature, there is a corresponding example here with the {feature}_client.dart and {feature}_server.dart file names. Sometimes multiple features are demonstrated together where appropriate, in which case the file name will indicate this.

To run the examples, run the client file directly, so for instance dart run example/tools_client.dart with run the example client which invokes tools, connected to the example server that provides tools (at example/tools_server.dart).

streamable_http_server.dart and streamable_http_client.dart are a pair. Run the server first. It prints its URL. Then run dart run example/streamable_http_client.dart <url> to list tools and call greet. streamableHttpClientChannel in package:dart_mcp/streamable_http.dart is the client transport.

multi_version_server.dart and multi_version_client.dart are a pair. The client spawns the server over stdio and answers the elicitation/create request that this package converts the tool's input_required result into. Run the server with --http and it prints two curl commands that ask a 2026-07-28 client for the same name with an input_required result.

Full Featured Examples

See https://github.com/dart-lang/ai/tree/main/mcp_examples for some more full featured examples using gemini to automatically invoke tools.

The example client there is also useful for testing your own server.