package xyz.wbsite.mcp.basic; /** * MCP协议响应类 * 用于封装JSON-RPC格式的响应数据 * 支持成功结果和错误信息的返回 * * @author wangbing */ public class McpResponse extends Data { private String jsonrpc; private Long id; private Object result; // Can be ListToolsResult, CallToolResult, etc. private McpError error; // Optional error field public McpResponse() { } public McpResponse(String jsonrpc, Long id, Object result, McpError error) { this.jsonrpc = jsonrpc; this.id = id; this.result = result; this.error = error; } public McpResponse(Long id, Object result) { this("2.0", id, result, null); } public McpResponse(Long id, McpError error) { this("2.0", id, null, error); } public String getJsonrpc() { return jsonrpc; } public void setJsonrpc(String jsonrpc) { this.jsonrpc = jsonrpc; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Object getResult() { return result; } public void setResult(Object result) { this.result = result; } public McpError getError() { return error; } public void setError(McpError error) { this.error = error; } }