McpResponse class

MCP Response wrapper

Represents a JSON-RPC 2.0 response object with either a result or an error.

Constructors

McpResponse({required Object id, dynamic result, McpError? error})
McpResponse.error(Object id, int code, String message, {String? data})
Create an error response
factory
McpResponse.fromData(dynamic result)
Create a response with data and default ID
factory
McpResponse.fromJson(Map<String, dynamic> json)
Create response from JSON map
factory
McpResponse.internalError(Object id, String message)
Create an internal error response
factory
McpResponse.invalidParams(Object id, String detail)
Create an invalid params error response
factory
McpResponse.invalidRequest(Object id)
Create an invalid request error response
factory
McpResponse.methodNotFound(Object id)
Create a method not found error response
factory
McpResponse.parseError(Object id)
Create a parse error response
factory
McpResponse.result(Object id, dynamic result)
Create a successful response
factory

Properties

error McpError?
Error data (null if successful)
final
hashCode int
The hash code for this object.
no setterinherited
id Object
Request ID this response corresponds to (can be string, number, or null)
final
isError bool
Check if response is an error
no setter
isSuccess bool
Check if response is successful
no setter
result → dynamic
Successful result data (null if error)
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Convert to JSON map
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited