request method
Sends a stateful JSON-RPC request using the active MCP session.
Implementation
Future<McpJsonMap> request(
String method, {
Object? id,
McpJsonMap? params,
bool streamable = true,
bool includeSession = true,
String? protocolVersion,
Map<String, String> headers = const <String, String>{},
}) async {
final response = await post(
<String, Object?>{
'jsonrpc': '2.0',
'id': id ?? _nextRequestId++,
'method': method,
'params': ?params,
},
streamable: streamable,
includeSession: includeSession,
protocolVersion: protocolVersion,
headers: headers,
);
if (response == null) {
throw FormatException('$method did not return a JSON-RPC body');
}
return response;
}