Package org.forgerock.openig.mcp
Class McpContext
java.lang.Object
org.forgerock.services.context.AbstractContext
org.forgerock.openig.mcp.McpContext
- All Implemented Interfaces:
Context
A context holding MCP request and response information. Note that:
- an MCP client can send an MCP response to the server in response to a request from the MCP server sent as a Server Sent Event (SSE).
- An MCP server can only acknowledge the Client's request, without request's body.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumMCP request types.static final classA helper object for working with a valid MCP Client request.static final classA helper object for working with a valid MCP Server response.static enumMCP response types. -
Field Summary
Fields inherited from class org.forgerock.services.context.AbstractContext
data -
Constructor Summary
ConstructorsConstructorDescriptionMcpContext(Context parent) Create aMcpContext.McpContext(Context parent, JsonRpcPayload clientMcpPayload, JsonRpcPayload serverMcpPayload, McpVersion mcpVersion, String sessionId) Create aMcpContext. -
Method Summary
Modifier and TypeMethodDescriptionReturns the JSON-RPC message received from the MCP client.Returns the MCP Client message type.Returns a McpClientRequest if this context contains a valid client request, otherwise null.Returns a McpServerResponse if this context contains a valid server response, otherwise null.Returns the MCP version being used.Returns the JSON-RPC message received from the MCP server, if any.Returns the MCP Server message type.Returns the MCP sessionId, if set.Methods inherited from class org.forgerock.services.context.AbstractContext
as, asContext, containsContext, containsContext, get, getContext, getContextName, getId, getParent, getRootId, isRootContext, toJsonValue, toString
-
Constructor Details
-
McpContext
Create aMcpContext.- Parameters:
parent- the parentContext.
-
McpContext
public McpContext(Context parent, JsonRpcPayload clientMcpPayload, JsonRpcPayload serverMcpPayload, McpVersion mcpVersion, String sessionId) Create aMcpContext.- Parameters:
parent- the parentContext.clientMcpPayload- the JSON-RPC message received from the MCP Client.serverMcpPayload- the JSON-RPC message received from the MCP Server.mcpVersion- the MCP versionsessionId- the MCP sessionId
-
-
Method Details
-
clientMessageType
Returns the MCP Client message type.- Returns:
- the MCP Client message type
-
serverMessageType
Returns the MCP Server message type.- Returns:
- the MCP Server message type
-
clientMcpPayload
Returns the JSON-RPC message received from the MCP client.- Returns:
- the JSON-RPC message received from the MCP client
-
mcpClientRequest
Returns a McpClientRequest if this context contains a valid client request, otherwise null.- Returns:
- a McpClientRequest if this context contains a valid client request, otherwise null
-
mcpServerResponse
Returns a McpServerResponse if this context contains a valid server response, otherwise null.- Returns:
- a McpServerResponse if this context contains a valid server response, otherwise null
-
mcpVersion
Returns the MCP version being used.- Returns:
- the MCP version being used
-
sessionId
Returns the MCP sessionId, if set.- Returns:
- the MCP sessionId, if set
-
serverMcpPayload
Returns the JSON-RPC message received from the MCP server, if any.- Returns:
- the JSON-RPC message received from the MCP server, if any
-