Skip to content

Commit 4754565

Browse files
sdelamotzolov
authored andcommitted
define explicitely that values should always be included in code completions (#601)
* define explicitely that values should always be included * spring apply
1 parent 531c5b8 commit 4754565

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

mcp-core/src/main/java/io/modelcontextprotocol/spec/McpSchema.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2501,6 +2501,7 @@ public CompleteResult(CompleteCompletion completion) {
25012501
* @param hasMore Indicates whether there are additional completion options beyond
25022502
* those provided in the current response, even if the exact total is unknown
25032503
*/
2504+
@JsonInclude(JsonInclude.Include.ALWAYS)
25042505
public record CompleteCompletion( // @formatter:off
25052506
@JsonProperty("values") List<String> values,
25062507
@JsonProperty("total") Integer total,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package io.modelcontextprotocol.spec;
2+
3+
import io.modelcontextprotocol.json.McpJsonMapper;
4+
import org.junit.jupiter.api.Test;
5+
import java.io.IOException;
6+
import java.util.Collections;
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
9+
class CompleteCompletionSerializationTest {
10+
11+
@Test
12+
void codeCompletionSerialization() throws IOException {
13+
McpJsonMapper jsonMapper = McpJsonMapper.getDefault();
14+
McpSchema.CompleteResult.CompleteCompletion codeComplete = new McpSchema.CompleteResult.CompleteCompletion(
15+
Collections.emptyList(), 0, false);
16+
String json = jsonMapper.writeValueAsString(codeComplete);
17+
String expected = """
18+
{"values":[],"total":0,"hasMore":false}""";
19+
assertEquals(expected, json, json);
20+
21+
McpSchema.CompleteResult completeResult = new McpSchema.CompleteResult(codeComplete);
22+
json = jsonMapper.writeValueAsString(completeResult);
23+
expected = """
24+
{"completion":{"values":[],"total":0,"hasMore":false}}""";
25+
assertEquals(expected, json, json);
26+
}
27+
28+
}

0 commit comments

Comments
 (0)