callTool method
Calls an MCP tool through the active session.
Implementation
Future<McpJsonMap> callTool(
String name, {
Object? id,
McpJsonMap arguments = const <String, Object?>{},
bool streamable = true,
String? protocolVersion,
Map<String, String> headers = const <String, String>{},
}) async {
final toolName = _validatedMcpToolName(name, 'name');
final response = await request(
'tools/call',
id: id,
params: <String, Object?>{'name': toolName, 'arguments': arguments},
streamable: streamable,
protocolVersion: protocolVersion,
headers: _headersWithToolParameterHeaders(toolName, arguments, headers),
);
return _validatedToolCallResult(
_jsonRpcResultFrom(response, method: 'tools/call'),
label: 'tools/call result',
);
}