Package com.tnsai.metadata
Record Class MCPToolConfig
java.lang.Object
java.lang.Record
com.tnsai.metadata.MCPToolConfig
- Record Components:
serverUrl- MCP server URLtoolName- specific MCP tool name (empty = method name)apiKeyEnv- env var name for API keytimeout- request timeout in msheaders- custom HTTP headersretryCount- max retries on failureretryBackoffMs- backoff between retries in mscacheToolDefinitions- whether to cache tool definitionscacheTtlSeconds- cache TTL in secondsvalidateParameters- whether to validate params against schemastdioCommand- command for stdio transportstdioArgs- arguments for stdio commandstdioEnv- 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
,
providing a cohesive view of MCP server connection configuration including
server URL, authentication, cache settings, retry, and stdio transport.
invalid reference
ActionSpec
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MCPToolConfigDefault configuration matching @MCPTool annotation defaults. -
Constructor Summary
ConstructorsConstructorDescriptionMCPToolConfig(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 aMCPToolConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theapiKeyEnvrecord component.booleanReturns the value of thecacheToolDefinitionsrecord component.intReturns the value of thecacheTtlSecondsrecord component.effectiveToolName(String actionName) Gets the effective tool name (falls back to action method name).final booleanIndicates whether some other object is "equal to" this one.booleanChecks if API key authentication is configured.final inthashCode()Returns a hash code value for this object.booleanChecks if custom headers are configured.booleanChecks if a server URL is configured.Header[]headers()Returns the value of theheadersrecord component.booleanisStdio()Checks if this uses stdio transport.intReturns the value of theretryBackoffMsrecord component.intReturns the value of theretryCountrecord component.Returns the value of theserverUrlrecord component.String[]Returns the value of thestdioArgsrecord component.Returns the value of thestdioCommandrecord component.String[]stdioEnv()Returns the value of thestdioEnvrecord component.inttimeout()Returns the value of thetimeoutrecord component.toolName()Returns the value of thetoolNamerecord component.final StringtoString()Returns a string representation of this record class.booleanReturns the value of thevalidateParametersrecord component.
-
Field Details
-
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 aMCPToolConfigrecord class.- Parameters:
serverUrl- the value for theserverUrlrecord componenttoolName- the value for thetoolNamerecord componentapiKeyEnv- the value for theapiKeyEnvrecord componenttimeout- the value for thetimeoutrecord componentheaders- the value for theheadersrecord componentretryCount- the value for theretryCountrecord componentretryBackoffMs- the value for theretryBackoffMsrecord componentcacheToolDefinitions- the value for thecacheToolDefinitionsrecord componentcacheTtlSeconds- the value for thecacheTtlSecondsrecord componentvalidateParameters- the value for thevalidateParametersrecord componentstdioCommand- the value for thestdioCommandrecord componentstdioArgs- the value for thestdioArgsrecord componentstdioEnv- the value for thestdioEnvrecord 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
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
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
serverUrl
Returns the value of theserverUrlrecord component.- Returns:
- the value of the
serverUrlrecord component
-
toolName
Returns the value of thetoolNamerecord component.- Returns:
- the value of the
toolNamerecord component
-
apiKeyEnv
Returns the value of theapiKeyEnvrecord component.- Returns:
- the value of the
apiKeyEnvrecord component
-
timeout
public int timeout()Returns the value of thetimeoutrecord component.- Returns:
- the value of the
timeoutrecord component
-
headers
Returns the value of theheadersrecord component.- Returns:
- the value of the
headersrecord component
-
retryCount
public int retryCount()Returns the value of theretryCountrecord component.- Returns:
- the value of the
retryCountrecord component
-
retryBackoffMs
public int retryBackoffMs()Returns the value of theretryBackoffMsrecord component.- Returns:
- the value of the
retryBackoffMsrecord component
-
cacheToolDefinitions
public boolean cacheToolDefinitions()Returns the value of thecacheToolDefinitionsrecord component.- Returns:
- the value of the
cacheToolDefinitionsrecord component
-
cacheTtlSeconds
public int cacheTtlSeconds()Returns the value of thecacheTtlSecondsrecord component.- Returns:
- the value of the
cacheTtlSecondsrecord component
-
validateParameters
public boolean validateParameters()Returns the value of thevalidateParametersrecord component.- Returns:
- the value of the
validateParametersrecord component
-
stdioCommand
Returns the value of thestdioCommandrecord component.- Returns:
- the value of the
stdioCommandrecord component
-
stdioArgs
Returns the value of thestdioArgsrecord component.- Returns:
- the value of the
stdioArgsrecord component
-
stdioEnv
Returns the value of thestdioEnvrecord component.- Returns:
- the value of the
stdioEnvrecord component
-