Record Class HostedTool.Mcp
java.lang.Object
java.lang.Record
org.springframework.ai.openai.responses.HostedTool.Mcp
- Record Components:
serverLabel- the label the model uses to address the serverserverUrl- the server URL, ornullwhen usingconnectorIdconnectorId- an OpenAI-managed connector id, ornullallowedTools- restricts the callable tools, ornullfor all of themheaders- headers to send to the MCP server, e.g. authorizationrequireApproval-never, ornullfor the provider default.alwaysis rejected: the approval round-trip is not implemented, so it would end every tool-using turn without running the tool
- All Implemented Interfaces:
HostedTool
- Enclosing interface:
- HostedTool
public static record HostedTool.Mcp(String serverLabel, @Nullable String serverUrl, @Nullable String connectorId, @Nullable List<String> allowedTools, @Nullable Map<String,String> headers, @Nullable String requireApproval)
extends Record
implements HostedTool
Call tools on a remote MCP server from inside OpenAI's request.
The approval round-trip is out of scope: requireApproval should be
never unless the application inspects
OpenAiResponsesMetadata.HOSTED_TOOL_CALLS on the generation metadata
itself, because an mcp_approval_request left unanswered ends the turn
without running the tool.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.ai.openai.responses.HostedTool
HostedTool.CodeInterpreter, HostedTool.FileSearch, HostedTool.ImageGeneration, HostedTool.Mcp, HostedTool.Raw, HostedTool.WebSearch -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theallowedToolsrecord component.@Nullable StringReturns the value of theconnectorIdrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.headers()Returns the value of theheadersrecord component.static HostedTool.Mcp@Nullable StringReturns the value of therequireApprovalrecord component.Returns the value of theserverLabelrecord component.@Nullable StringReturns the value of theserverUrlrecord component.final StringtoString()Returns a string representation of this record class.com.openai.models.responses.TooltoTool()Convert this tool to the SDK request representation.
-
Constructor Details
-
Mcp
public Mcp(String serverLabel, @Nullable String serverUrl, @Nullable String connectorId, @Nullable List<String> allowedTools, @Nullable Map<String, String> headers, @Nullable String requireApproval) Creates an instance of aMcprecord class.- Parameters:
serverLabel- the value for theserverLabelrecord componentserverUrl- the value for theserverUrlrecord componentconnectorId- the value for theconnectorIdrecord componentallowedTools- the value for theallowedToolsrecord componentheaders- the value for theheadersrecord componentrequireApproval- the value for therequireApprovalrecord component
-
-
Method Details
-
of
-
toTool
public com.openai.models.responses.Tool toTool()Description copied from interface:HostedToolConvert this tool to the SDK request representation.- Specified by:
toToolin interfaceHostedTool
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
serverLabel
Returns the value of theserverLabelrecord component.- Returns:
- the value of the
serverLabelrecord component
-
serverUrl
Returns the value of theserverUrlrecord component.- Returns:
- the value of the
serverUrlrecord component
-
connectorId
Returns the value of theconnectorIdrecord component.- Returns:
- the value of the
connectorIdrecord component
-
allowedTools
Returns the value of theallowedToolsrecord component.- Returns:
- the value of the
allowedToolsrecord component
-
headers
Returns the value of theheadersrecord component.- Returns:
- the value of the
headersrecord component
-
requireApproval
Returns the value of therequireApprovalrecord component.- Returns:
- the value of the
requireApprovalrecord component
-