callInProcess method

Future callInProcess(
  1. String tool,
  2. Map<String, dynamic> params
)

Dispatch a registered tool entirely in-process, with no external MCP client involved. Used by JS atoms such as host.mcp.callTool. Throws ToolNotFoundException for unregistered tool names.

Implementation

Future<dynamic> callInProcess(
  String tool,
  Map<String, dynamic> params,
) async {
  final handler = _inProcess[tool];
  if (handler == null) {
    throw ToolNotFoundException(tool, _inProcess.keys.toList());
  }
  try {
    return await handler(params);
  } catch (e, st) {
    _logger.logError('In-process tool failed', e, st, {'tool': tool});
    throw ToolExecutionException(tool, cause: e);
  }
}