Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import com.ibm.websphere.ras.TraceComponent;

import io.openliberty.mcp.internal.monitor.metrics.McpOperationStatAttributes;
import io.openliberty.mcp.monitor.McpOperationStatsMXBean;
import io.openliberty.mcp.monitor.McpOperationStatisticsMXBean;

/**
* Records statistics for MCP (Model Context Protocol) operations.
Expand All @@ -25,10 +25,10 @@
* A new instance is created for each unique combination of operation attributes (method name,
* tool name, error type, etc.). All instances are managed by {@link McpStatsMonitorImpl}.
* <p>
* The statistics are exposed via JMX through the {@link McpOperationStatsMXBean} interface
* The statistics are exposed via JMX through the {@link McpOperationStatisticsMXBean} interface
* and can be consumed by monitoring systems like MicroProfile Metrics and MicroProfile Telemetry.
*/
public class McpOperationStatistics extends Meter implements McpOperationStatsMXBean {
public class McpOperationStatistics extends Meter implements McpOperationStatisticsMXBean {
private static final TraceComponent tc = Tr.register(McpOperationStatistics.class);

private final String mcpMethodName;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*******************************************************************************
* Copyright (c) 2026 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/

package io.openliberty.mcp.monitor;

/**
* Management interface for MCP operation statistics.
* <p>
* This MXBean exposes monitoring information for MCP operations, including
* operation attributes, invocation count, and total duration.
* <p>
* Each MXBean instance represents statistics for a unique set of MCP operation
* attributes, such as method name, tool name, error type, and response status.
* The values are intended to be consumed through JMX by administrators,
* monitoring tools, and applications that need to observe MCP server behavior.
*/
public interface McpOperationStatisticsMXBean {

/**
* Returns the MCP JSON-RPC method name associated with this operation.
*
* @return the MCP method name, for example {@code tools/call}, or
* {@code null} if the method name is not available.
*/
String getMcpMethodName();

/**
* Returns the error type associated with this operation.
*
* @return the error type, or {@code null} if no error type was recorded.
*/
String getErrorType();

/**
* Returns the GenAI prompt name associated with this operation.
*
* @return the GenAI prompt name, or {@code null} if not applicable.
*/
String getGenAiPromptName();

/**
* Returns the GenAI tool name associated with this operation.
*
* @return the GenAI tool name, or {@code null} if not applicable.
*/
String getGenAiToolName();

/**
* Returns the JSON-RPC response status code associated with this operation.
*
* @return the JSON-RPC response status code, or {@code null} if unavailable.
*/
String getRpcResponseStatusCode();

/**
* Returns the GenAI operation name associated with this operation.
*
* @return the GenAI operation name, or {@code null} if unavailable.
*/
String getGenAiOperationName();

/**
* Returns the JSON-RPC protocol version associated with this operation.
*
* @return the JSON-RPC protocol version, or {@code null} if unavailable.
*/
String getJsonrpcProtocolVersion();

/**
* Returns the MCP protocol version associated with this operation.
*
* @return the MCP protocol version, or {@code null} if unavailable.
*/
String getMcpProtocolVersion();

/**
* Returns the network protocol name used for this operation.
*
* @return the network protocol name, or {@code null} if unavailable.
*/
String getNetworkProtocolName();

/**
* Returns the network protocol version used for this operation.
*
* @return the network protocol version, or {@code null} if unavailable.
*/
String getNetworkProtocolVersion();

/**
* Returns the network transport used for this operation.
*
* @return the network transport, or {@code null} if unavailable.
*/
String getNetworkTransport();

/**
* Returns the MCP resource URI associated with this operation.
*
* @return the MCP resource URI, or {@code null} if unavailable.
*/
String getMcpResourceUri();

/**
* Returns the number of times this operation has been recorded.
*
* @return the operation count.
*/
long getCount();

/**
* Returns the total recorded duration for this operation.
* <p>
* The duration is reported in nanoseconds.
*
* @return the total operation duration in nanoseconds.
*/
double getDuration();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*******************************************************************************
* Copyright (c) 2026 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package io.openliberty.mcp.monitor;

/**
* Management interface for MCP session statistics.
* <p>
* This MXBean exposes monitoring information for MCP sessions, including
* protocol and network attributes, session count, and total session duration.
* <p>
* The values are intended to be consumed through JMX by administrators,
* monitoring tools, and applications that need to observe MCP server behavior.
*/
public interface McpSessionStatisticsMXBean {

/**
* Returns the error type associated with the session.
*
* @return the error type, or {@code null} if no error type was recorded.
*/
String getErrorType();

/**
* Returns the JSON-RPC protocol version associated with the session.
*
* @return the JSON-RPC protocol version, or {@code null} if unavailable.
*/
String getJsonrpcProtocolVersion();

/**
* Returns the MCP protocol version associated with the session.
*
* @return the MCP protocol version, or {@code null} if unavailable.
*/
String getMcpProtocolVersion();

/**
* Returns the network protocol name used for the session.
*
* @return the network protocol name, or {@code null} if unavailable.
*/
String getNetworkProtocolName();

/**
* Returns the network protocol version used for the session.
*
* @return the network protocol version, or {@code null} if unavailable.
*/
String getNetworkProtocolVersion();

/**
* Returns the network transport used for the session.
*
* @return the network transport, or {@code null} if unavailable.
*/
String getNetworkTransport();

/**
* Returns the number of sessions recorded for this set of attributes.
*
* @return the session count.
*/
long getCount();

/**
* Returns the total recorded session duration.
* <p>
* The duration is reported in nanoseconds.
*
* @return the total session duration in nanoseconds.
*/
double getDuration();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*******************************************************************************
* Copyright (c) 2025 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
/**
* MCP tools, resources and prompts can be declared using the annotations in this package.
*/
@com.ibm.websphere.ras.annotation.TraceOptions(traceGroup = "MCP")
@org.osgi.annotation.versioning.Version("1.0")
package io.openliberty.mcp.monitor;