Skip to content

Commit d4aa70c

Browse files
committed
feat: mcp approval
1 parent 8d3e48e commit d4aa70c

File tree

8 files changed

+68
-5
lines changed

8 files changed

+68
-5
lines changed

api/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>top.bella</groupId>
88
<artifactId>openai-java</artifactId>
9-
<version>0.23.79</version>
9+
<version>0.23.80</version>
1010
</parent>
1111
<packaging>jar</packaging>
1212
<artifactId>openai-api</artifactId>

api/src/main/java/com/theokanning/openai/assistants/message/MessageContent.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
import com.fasterxml.jackson.annotation.JsonInclude;
44
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import com.theokanning.openai.assistants.message.content.Approval;
56
import com.theokanning.openai.assistants.message.content.AudioData;
67
import com.theokanning.openai.assistants.message.content.ImageFile;
78
import com.theokanning.openai.assistants.message.content.Text;
89
import com.theokanning.openai.completion.chat.ChatToolCall;
910
import com.theokanning.openai.completion.chat.ImageUrl;
1011
import com.theokanning.openai.completion.chat.ToolMessage;
12+
import com.theokanning.openai.response.tool.MCPApprovalResponse;
1113
import com.theokanning.openai.response.tool.ToolCall;
1214
import lombok.Data;
1315

@@ -21,7 +23,7 @@
2123
public class MessageContent {
2224

2325
/**
24-
* image_url/image_file/text/tool_call/tool_result/audio
26+
* image_url/image_file/text/tool_call/tool_result/audio/clear/approval
2527
*/
2628
String type;
2729

@@ -58,6 +60,10 @@ public class MessageContent {
5860
@JsonInclude(JsonInclude.Include.NON_NULL)
5961
ToolMessage toolResult;
6062

63+
@JsonProperty("approval")
64+
@JsonInclude(JsonInclude.Include.NON_NULL)
65+
Approval approval;
66+
6167
public boolean empty() {
6268
switch (type) {
6369
case "image_file":
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.theokanning.openai.assistants.message.content;
2+
3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import lombok.AllArgsConstructor;
6+
import lombok.Data;
7+
import lombok.NoArgsConstructor;
8+
9+
@Data
10+
@NoArgsConstructor
11+
@AllArgsConstructor
12+
@JsonInclude(JsonInclude.Include.NON_NULL)
13+
public class Approval {
14+
/**
15+
* The ID of the approval request being answered.
16+
*/
17+
@JsonProperty("approval_request_id")
18+
private String approvalRequestId;
19+
20+
/**
21+
* The label of the MCP server making the request.
22+
*/
23+
@JsonProperty("server_label")
24+
private String serverLabel;
25+
26+
/**
27+
* The name of the tool to run.
28+
*/
29+
private String name;
30+
31+
/**
32+
* A JSON string of arguments for the tool.
33+
*/
34+
private String arguments;
35+
36+
/**
37+
* Whether the request was approved.
38+
*/
39+
private Boolean approve;
40+
41+
/**
42+
* Optional reason for the decision.
43+
*/
44+
private String reason;
45+
46+
private Integer index;
47+
}

api/src/main/java/com/theokanning/openai/assistants/run_step/StepDetails.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public class StepDetails {
4646
@JsonProperty("redacted_reasoning_content")
4747
private String redactedReasoningContent;
4848

49+
@JsonInclude(JsonInclude.Include.NON_NULL)
50+
@JsonProperty("approval_ids")
51+
private List<String> approvalIds;
52+
4953
@JsonInclude(JsonInclude.Include.NON_NULL)
5054
private List<Annotation> annotations;
5155

api/src/main/java/com/theokanning/openai/response/tool/MCPToolCall.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ public class MCPToolCall extends ToolCall {
4646
*/
4747
private String arguments;
4848

49+
/**
50+
* Unique identifier for the MCP tool call approval request. Include this value in a subsequent mcp_approval_response input to approve or reject the corresponding tool call.
51+
*/
52+
@JsonProperty("approval_request_id")
53+
private String approvalRequestId;
54+
4955
/**
5056
* The output from the tool call.
5157
*/

client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>top.bella</groupId>
88
<artifactId>openai-java</artifactId>
9-
<version>0.23.79</version>
9+
<version>0.23.80</version>
1010
</parent>
1111
<packaging>jar</packaging>
1212

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>top.bella</groupId>
77
<artifactId>openai-java</artifactId>
8-
<version>0.23.79</version>
8+
<version>0.23.80</version>
99
<packaging>pom</packaging>
1010
<description>openai java 版本</description>
1111
<name>openai-java</name>

service/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>top.bella</groupId>
88
<artifactId>openai-java</artifactId>
9-
<version>0.23.79</version>
9+
<version>0.23.80</version>
1010
</parent>
1111
<packaging>jar</packaging>
1212

0 commit comments

Comments
 (0)