001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.bean.jsonrpc; 018 019import org.apache.juneau.marshall.*; 020 021/** 022 * JSON-RPC 2.0 request envelope. 023 * 024 * <p> 025 * The {@code id} field may be a {@link String}, integral {@link Number}, or {@code null} (notification). 026 * 027 * <p> 028 * This envelope is generic JSON-RPC 2.0 and carries no {@code _meta} property: MCP-specific per-request 029 * metadata belongs under {@code params._meta}, not beside the envelope. See the {@code 2026-07-28} v2 bean 030 * package ({@code org.apache.juneau.bean.mcp.v20260728}) for the typed nested carrier. 031 */ 032@Marshalled 033public class JsonRpcRequest { 034 035 private String jsonrpc; 036 private Object id; 037 private String method; 038 private Object params; 039 040 /** 041 * JSON-RPC protocol version (typically {@code "2.0"}). 042 * 043 * @return The version token, or {@code null} if not set. 044 */ 045 public String getJsonrpc() { 046 return jsonrpc; 047 } 048 049 /** 050 * Sets the JSON-RPC protocol version. 051 * 052 * @param value The new value. Can be <jk>null</jk> to unset the property. 053 * @return This object (for method chaining). 054 */ 055 public JsonRpcRequest setJsonrpc(String value) { 056 jsonrpc = value; 057 return this; 058 } 059 060 /** 061 * Request identifier (string, integer, or {@code null} for notifications). 062 * 063 * @return The id, or {@code null} if not set. 064 */ 065 public Object getId() { 066 return id; 067 } 068 069 /** 070 * Sets the request id. 071 * 072 * @param value The new value. Can be <jk>null</jk> to unset the property. 073 * @return This object (for method chaining). 074 */ 075 public JsonRpcRequest setId(Object value) { 076 id = value; 077 return this; 078 } 079 080 /** 081 * JSON-RPC method name (for example {@code "tools/list"}). 082 * 083 * @return The method, or {@code null} if not set. 084 */ 085 public String getMethod() { 086 return method; 087 } 088 089 /** 090 * Sets the JSON-RPC method name. 091 * 092 * @param value The new value. Can be <jk>null</jk> to unset the property. 093 * @return This object (for method chaining). 094 */ 095 public JsonRpcRequest setMethod(String value) { 096 method = value; 097 return this; 098 } 099 100 /** 101 * Method parameters (object, array, or {@code null}). 102 * 103 * @return The params payload, or {@code null} if not set. 104 */ 105 public Object getParams() { 106 return params; 107 } 108 109 /** 110 * Sets method parameters. 111 * 112 * @param value The new value. Can be <jk>null</jk> to unset the property. 113 * @return This object (for method chaining). 114 */ 115 public JsonRpcRequest setParams(Object value) { 116 params = value; 117 return this; 118 } 119}