This commit is contained in:
33
docs/snippets/dart/mcp/mcp_custom_client.md
Normal file
33
docs/snippets/dart/mcp/mcp_custom_client.md
Normal file
@@ -0,0 +1,33 @@
|
||||
<!-- snippet:syntax-only -->
|
||||
|
||||
```dart title="Dart"
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
Future<void> main() async {
|
||||
final process = await Process.start('kreuzberg', <String>['mcp']);
|
||||
|
||||
final request = <String, Object?>{
|
||||
'method': 'tools/call',
|
||||
'params': <String, Object?>{
|
||||
'name': 'extract_file',
|
||||
'arguments': <String, Object?>{
|
||||
'path': 'document.pdf',
|
||||
'async': true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
process.stdin.writeln(jsonEncode(request));
|
||||
await process.stdin.flush();
|
||||
await process.stdin.close();
|
||||
|
||||
final line = await process.stdout
|
||||
.transform(utf8.decoder)
|
||||
.transform(const LineSplitter())
|
||||
.first;
|
||||
print(line);
|
||||
|
||||
await process.exitCode;
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user