Record Class MCPToolConfig

java.lang.Object
java.lang.Record
com.tnsai.metadata.MCPToolConfig
Record Components:
serverUrl - MCP server URL
toolName - specific MCP tool name (empty = method name)
apiKeyEnv - env var name for API key
timeout - request timeout in ms
headers - custom HTTP headers
retryCount - max retries on failure
retryBackoffMs - backoff between retries in ms
cacheToolDefinitions - whether to cache tool definitions
cacheTtlSeconds - cache TTL in seconds
validateParameters - whether to validate params against schema
stdioCommand - command for stdio transport
stdioArgs - arguments for stdio command
stdioEnv - environment variables for stdio process

public record MCPToolConfig(String serverUrl, String toolName, String apiKeyEnv, int timeout, Header[] headers, int retryCount, int retryBackoffMs, boolean cacheToolDefinitions, int cacheTtlSeconds, boolean validateParameters, String stdioCommand, String[] stdioArgs, String[] stdioEnv) extends Record
Grouped configuration for MCP_TOOL actions.

Extracts and organizes the MCP-specific fields from

invalid reference
ActionSpec
, providing a cohesive view of MCP server connection configuration including server URL, authentication, cache settings, retry, and stdio transport.

This record is part of the ActionConfig decomposition (C-20), splitting ActionSpec's 60+ fields into focused, type-specific records.

Usage


 ActionSpec action = ...;
 MCPToolConfig mcp = action.mcpToolConfig();
 String serverUrl = mcp.serverUrl();
 boolean isStdio = mcp.isStdio();
 
See Also:
  • invalid reference
    ActionSpec#mcpToolConfig()
  • Field Details

    • DEFAULT

      public static final MCPToolConfig DEFAULT
      Default configuration matching @MCPTool annotation defaults.
  • Constructor Details

    • MCPToolConfig

      public MCPToolConfig(String serverUrl, String toolName, String apiKeyEnv, int timeout, Header[] headers, int retryCount, int retryBackoffMs, boolean cacheToolDefinitions, int cacheTtlSeconds, boolean validateParameters, String stdioCommand, String[] stdioArgs, String[] stdioEnv)
      Creates an instance of a MCPToolConfig record class.
      Parameters:
      serverUrl - the value for the serverUrl record component
      toolName - the value for the toolName record component
      apiKeyEnv - the value for the apiKeyEnv record component
      timeout - the value for the timeout record component
      headers - the value for the headers record component
      retryCount - the value for the retryCount record component
      retryBackoffMs - the value for the retryBackoffMs record component
      cacheToolDefinitions - the value for the cacheToolDefinitions record component
      cacheTtlSeconds - the value for the cacheTtlSeconds record component
      validateParameters - the value for the validateParameters record component
      stdioCommand - the value for the stdioCommand record component
      stdioArgs - the value for the stdioArgs record component
      stdioEnv - the value for the stdioEnv record component
  • Method Details

    • hasServerUrl

      public boolean hasServerUrl()
      Checks if a server URL is configured.
      Returns:
      true if serverUrl is not empty
    • isStdio

      public boolean isStdio()
      Checks if this uses stdio transport.
      Returns:
      true if stdioCommand is not empty
    • hasApiKey

      public boolean hasApiKey()
      Checks if API key authentication is configured.
      Returns:
      true if apiKeyEnv is not empty
    • hasHeaders

      public boolean hasHeaders()
      Checks if custom headers are configured.
      Returns:
      true if headers array is not empty
    • effectiveToolName

      public String effectiveToolName(String actionName)
      Gets the effective tool name (falls back to action method name).
      Parameters:
      actionName - the action method name as fallback
      Returns:
      tool name or action name if tool name is empty
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • serverUrl

      public String serverUrl()
      Returns the value of the serverUrl record component.
      Returns:
      the value of the serverUrl record component
    • toolName

      public String toolName()
      Returns the value of the toolName record component.
      Returns:
      the value of the toolName record component
    • apiKeyEnv

      public String apiKeyEnv()
      Returns the value of the apiKeyEnv record component.
      Returns:
      the value of the apiKeyEnv record component
    • timeout

      public int timeout()
      Returns the value of the timeout record component.
      Returns:
      the value of the timeout record component
    • headers

      public Header[] headers()
      Returns the value of the headers record component.
      Returns:
      the value of the headers record component
    • retryCount

      public int retryCount()
      Returns the value of the retryCount record component.
      Returns:
      the value of the retryCount record component
    • retryBackoffMs

      public int retryBackoffMs()
      Returns the value of the retryBackoffMs record component.
      Returns:
      the value of the retryBackoffMs record component
    • cacheToolDefinitions

      public boolean cacheToolDefinitions()
      Returns the value of the cacheToolDefinitions record component.
      Returns:
      the value of the cacheToolDefinitions record component
    • cacheTtlSeconds

      public int cacheTtlSeconds()
      Returns the value of the cacheTtlSeconds record component.
      Returns:
      the value of the cacheTtlSeconds record component
    • validateParameters

      public boolean validateParameters()
      Returns the value of the validateParameters record component.
      Returns:
      the value of the validateParameters record component
    • stdioCommand

      public String stdioCommand()
      Returns the value of the stdioCommand record component.
      Returns:
      the value of the stdioCommand record component
    • stdioArgs

      public String[] stdioArgs()
      Returns the value of the stdioArgs record component.
      Returns:
      the value of the stdioArgs record component
    • stdioEnv

      public String[] stdioEnv()
      Returns the value of the stdioEnv record component.
      Returns:
      the value of the stdioEnv record component