Skip to content

Commit 1d6cb24

Browse files
Bump com.anthropic:anthropic-java from 0.8.0 to 2.6.0 (#246)
Bumps [com.anthropic:anthropic-java](https://github.com/anthropics/anthropic-sdk-java) from 0.8.0 to 2.6.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/anthropics/anthropic-sdk-java/releases">com.anthropic:anthropic-java's releases</a>.</em></p> <blockquote> <h2>v2.6.0</h2> <h2>2.6.0 (2025-09-02)</h2> <p>Full Changelog: <a href="https://github.com/anthropics/anthropic-sdk-java/compare/v2.5.1...v2.6.0">v2.5.1...v2.6.0</a></p> <h3>Features</h3> <ul> <li><strong>client:</strong> adds support for code-execution-2025-08-26 tool (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/da4c57b12dafe5243a5e06288c946830746622e5">da4c57b</a>)</li> </ul> <h3>Bug Fixes</h3> <ul> <li><strong>client:</strong> ensure correct binary content type (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/197fdd5433ad9d39b488bb232797084b08bade7f">197fdd5</a>)</li> <li>fix casing issue (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/c2c50097e4ea22fbac005fc4083142315384c51b">c2c5009</a>)</li> <li>update singularization rules (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/afec494c858f4231191f8ff80e3a5dfd37f62e82">afec494</a>)</li> </ul> <h3>Performance Improvements</h3> <ul> <li><strong>internal:</strong> make formatting faster (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/7c36322f9f664d32a4649f07d0bfc02a3116129b">7c36322</a>)</li> </ul> <h3>Chores</h3> <ul> <li><strong>api:</strong> remove unsupported endpoints (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/d9b7be334b6d949045be9f9ee22f8b80b20c8cda">d9b7be3</a>)</li> <li><strong>ci:</strong> add build job (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/061df8e7024fc4db78f703510e6e80ff20221974">061df8e</a>)</li> <li><strong>ci:</strong> reduce log noise (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/b91d7779f1263e3f33a6297fab9016e2dc52a74b">b91d777</a>)</li> <li><strong>client:</strong> refactor closing / shutdown (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/f0c796d723913df6b9465cbb4d0a84d00df21cdd">f0c796d</a>)</li> <li><strong>client:</strong> rename parameter (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/197fdd5433ad9d39b488bb232797084b08bade7f">197fdd5</a>)</li> <li><strong>internal:</strong> dynamically determine included projects (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/93db169c6cf328e9a7ffca28555264686853001a">93db169</a>)</li> <li><strong>internal:</strong> run formatter (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/06cd69ff9dc45bf6ae427c87818b31bee60fd35d">06cd69f</a>)</li> <li><strong>internal:</strong> support passing arguments to test script (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/8528c63f15574ecf0def1ad937324e83d324675f">8528c63</a>)</li> <li><strong>internal:</strong> support running formatters directly (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/e0de72e934963d0dddf749d678e6293d123cb79e">e0de72e</a>)</li> <li>remove memory upper bound from publishing step (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/cb2ac3b70f37f9d65bbeaff429f684b66911b3b1">cb2ac3b</a>)</li> <li><strong>tests:</strong> setup cache creation in MessageAccumulator test (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/d5de4438df3ee755bac3d4c66021e653c9f07acb">d5de443</a>)</li> </ul> <h2>v2.5.1</h2> <h2>2.5.1 (2025-08-13)</h2> <p>Full Changelog: <a href="https://github.com/anthropics/anthropic-sdk-java/compare/v2.5.0...v2.5.1">v2.5.0...v2.5.1</a></p> <h3>Chores</h3> <ul> <li>deprecate older claude-3-5 sonnet models (<a href="https://redirect.github.com/anthropics/anthropic-sdk-java/issues/591">#591</a>) (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/c7c4cc1a0862f3121f9e1eb7703407efe9198b0c">c7c4cc1</a>)</li> <li><strong>internal:</strong> format identity methods (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/483576abc49b0932bade9ad667747d1eedbea8a4">483576a</a>)</li> </ul> <h2>v2.5.0</h2> <h2>2.5.0 (2025-08-12)</h2> <p>Full Changelog: <a href="https://github.com/anthropics/anthropic-sdk-java/compare/v2.4.0...v2.5.0">v2.4.0...v2.5.0</a></p> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/anthropics/anthropic-sdk-java/blob/main/CHANGELOG.md">com.anthropic:anthropic-java's changelog</a>.</em></p> <blockquote> <h2>2.6.0 (2025-09-02)</h2> <p>Full Changelog: <a href="https://github.com/anthropics/anthropic-sdk-java/compare/v2.5.1...v2.6.0">v2.5.1...v2.6.0</a></p> <h3>Features</h3> <ul> <li><strong>client:</strong> adds support for code-execution-2025-08-26 tool (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/da4c57b12dafe5243a5e06288c946830746622e5">da4c57b</a>)</li> </ul> <h3>Bug Fixes</h3> <ul> <li><strong>client:</strong> ensure correct binary content type (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/197fdd5433ad9d39b488bb232797084b08bade7f">197fdd5</a>)</li> <li>fix casing issue (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/c2c50097e4ea22fbac005fc4083142315384c51b">c2c5009</a>)</li> <li>update singularization rules (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/afec494c858f4231191f8ff80e3a5dfd37f62e82">afec494</a>)</li> </ul> <h3>Performance Improvements</h3> <ul> <li><strong>internal:</strong> make formatting faster (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/7c36322f9f664d32a4649f07d0bfc02a3116129b">7c36322</a>)</li> </ul> <h3>Chores</h3> <ul> <li><strong>api:</strong> remove unsupported endpoints (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/d9b7be334b6d949045be9f9ee22f8b80b20c8cda">d9b7be3</a>)</li> <li><strong>ci:</strong> add build job (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/061df8e7024fc4db78f703510e6e80ff20221974">061df8e</a>)</li> <li><strong>ci:</strong> reduce log noise (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/b91d7779f1263e3f33a6297fab9016e2dc52a74b">b91d777</a>)</li> <li><strong>client:</strong> refactor closing / shutdown (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/f0c796d723913df6b9465cbb4d0a84d00df21cdd">f0c796d</a>)</li> <li><strong>client:</strong> rename parameter (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/197fdd5433ad9d39b488bb232797084b08bade7f">197fdd5</a>)</li> <li><strong>internal:</strong> dynamically determine included projects (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/93db169c6cf328e9a7ffca28555264686853001a">93db169</a>)</li> <li><strong>internal:</strong> run formatter (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/06cd69ff9dc45bf6ae427c87818b31bee60fd35d">06cd69f</a>)</li> <li><strong>internal:</strong> support passing arguments to test script (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/8528c63f15574ecf0def1ad937324e83d324675f">8528c63</a>)</li> <li><strong>internal:</strong> support running formatters directly (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/e0de72e934963d0dddf749d678e6293d123cb79e">e0de72e</a>)</li> <li>remove memory upper bound from publishing step (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/cb2ac3b70f37f9d65bbeaff429f684b66911b3b1">cb2ac3b</a>)</li> <li><strong>tests:</strong> setup cache creation in MessageAccumulator test (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/d5de4438df3ee755bac3d4c66021e653c9f07acb">d5de443</a>)</li> </ul> <h2>2.5.1 (2025-08-13)</h2> <p>Full Changelog: <a href="https://github.com/anthropics/anthropic-sdk-java/compare/v2.5.0...v2.5.1">v2.5.0...v2.5.1</a></p> <h3>Chores</h3> <ul> <li>deprecate older claude-3-5 sonnet models (<a href="https://redirect.github.com/anthropics/anthropic-sdk-java/issues/591">#591</a>) (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/c7c4cc1a0862f3121f9e1eb7703407efe9198b0c">c7c4cc1</a>)</li> <li><strong>internal:</strong> format identity methods (<a href="https://github.com/anthropics/anthropic-sdk-java/commit/483576abc49b0932bade9ad667747d1eedbea8a4">483576a</a>)</li> </ul> <h2>2.5.0 (2025-08-12)</h2> <p>Full Changelog: <a href="https://github.com/anthropics/anthropic-sdk-java/compare/v2.4.0...v2.5.0">v2.4.0...v2.5.0</a></p> <h3>Features</h3> <!-- raw HTML omitted --> </blockquote> <p>... (truncated)</p> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/anthropics/anthropic-sdk-java/commit/42fce65f72958741c63c51b3d19012f35edbb4f9"><code>42fce65</code></a> release: 2.6.0</li> <li><a href="https://github.com/anthropics/anthropic-sdk-java/commit/2b10838cc9b74df3e279763f0ea3af97012a9cc0"><code>2b10838</code></a> feat(client): adds support for code-execution-2025-08-26 tool</li> <li><a href="https://github.com/anthropics/anthropic-sdk-java/commit/ab1254a8ab559806e56a8f41d833cacc80141dde"><code>ab1254a</code></a> chore(internal): run formatter</li> <li><a href="https://github.com/anthropics/anthropic-sdk-java/commit/5611d37f31650a30ada83292d97dfa08561f205c"><code>5611d37</code></a> chore(tests): setup cache creation in MessageAccumulator test</li> <li><a href="https://github.com/anthropics/anthropic-sdk-java/commit/95918dc6c0a0de64682b4c5e0630aff0402205bb"><code>95918dc</code></a> codegen metadata</li> <li><a href="https://github.com/anthropics/anthropic-sdk-java/commit/d4fffce28f5984d2166399c327259e8f32ad993e"><code>d4fffce</code></a> codegen metadata</li> <li><a href="https://github.com/anthropics/anthropic-sdk-java/commit/f02db72ed9521bfc9c1070e33281ab01ba3f2541"><code>f02db72</code></a> codegen metadata</li> <li><a href="https://github.com/anthropics/anthropic-sdk-java/commit/2e258deed300d743ced11eda1920e127039931cc"><code>2e258de</code></a> codegen metadata</li> <li><a href="https://github.com/anthropics/anthropic-sdk-java/commit/31c46ff041c167ce83837555fcd19281e78dad5f"><code>31c46ff</code></a> fix: fix casing issue</li> <li><a href="https://github.com/anthropics/anthropic-sdk-java/commit/6fdc91169fa19753ba8b14887f032ffdd7ac44d6"><code>6fdc911</code></a> fix: update singularization rules</li> <li>Additional commits viewable in <a href="https://github.com/anthropics/anthropic-sdk-java/compare/v0.8.0...v2.6.0">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=com.anthropic:anthropic-java&package-manager=gradle&previous-version=0.8.0&new-version=2.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Konstantin Pavlov <[email protected]>
1 parent a9e2797 commit 1d6cb24

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ awaitility = "4.3.0"
2121

2222
# Samples
2323
mcp-kotlin = "0.7.0"
24-
anthropic = "0.8.0"
24+
anthropic = "2.7.0"
2525
shadow = "8.1.1"
2626

2727
[libraries]

samples/kotlin-mcp-client/src/main/kotlin/io/modelcontextprotocol/sample/client/MCPClient.kt

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ package io.modelcontextprotocol.sample.client
22

33
import com.anthropic.client.okhttp.AnthropicOkHttpClient
44
import com.anthropic.core.JsonValue
5-
import com.anthropic.models.messages.*
5+
import com.anthropic.models.messages.MessageCreateParams
6+
import com.anthropic.models.messages.MessageParam
7+
import com.anthropic.models.messages.Model
8+
import com.anthropic.models.messages.Tool
9+
import com.anthropic.models.messages.ToolUnion
610
import com.fasterxml.jackson.core.type.TypeReference
711
import com.fasterxml.jackson.databind.ObjectMapper
812
import io.modelcontextprotocol.kotlin.sdk.Implementation
@@ -24,7 +28,7 @@ class MCPClient : AutoCloseable {
2428
private val mcp: Client = Client(clientInfo = Implementation(name = "mcp-client-cli", version = "1.0.0"))
2529

2630
private val messageParamsBuilder: MessageCreateParams.Builder = MessageCreateParams.builder()
27-
.model(Model.CLAUDE_3_5_SONNET_20241022)
31+
.model(Model.CLAUDE_4_SONNET_20250514)
2832
.maxTokens(1024)
2933

3034
// List of tools offered by the server
@@ -56,15 +60,15 @@ class MCPClient : AutoCloseable {
5660
// Setup I/O transport using the process streams
5761
val transport = StdioClientTransport(
5862
input = process.inputStream.asSource().buffered(),
59-
output = process.outputStream.asSink().buffered()
63+
output = process.outputStream.asSink().buffered(),
6064
)
6165

6266
// Connect the MCP client to the server using the transport
6367
mcp.connect(transport)
6468

6569
// Request the list of available tools from the server
6670
val toolsResult = mcp.listTools()
67-
tools = toolsResult?.tools?.map { tool ->
71+
tools = toolsResult.tools.map { tool ->
6872
ToolUnion.ofTool(
6973
Tool.builder()
7074
.name(tool.name)
@@ -74,11 +78,11 @@ class MCPClient : AutoCloseable {
7478
.type(JsonValue.from(tool.inputSchema.type))
7579
.properties(tool.inputSchema.properties.toJsonValue())
7680
.putAdditionalProperty("required", JsonValue.from(tool.inputSchema.required))
77-
.build()
81+
.build(),
7882
)
79-
.build()
83+
.build(),
8084
)
81-
} ?: emptyList()
85+
}
8286
println("Connected to server with tools: ${tools.joinToString(", ") { it.tool().get().name() }}")
8387
} catch (e: Exception) {
8488
println("Failed to connect to MCP server: $e")
@@ -93,15 +97,15 @@ class MCPClient : AutoCloseable {
9397
MessageParam.builder()
9498
.role(MessageParam.Role.USER)
9599
.content(query)
96-
.build()
100+
.build(),
97101
)
98102

99103
// Send the query to the Anthropic model and get the response
100104
val response = anthropic.messages().create(
101105
messageParamsBuilder
102106
.messages(messages)
103107
.tools(tools)
104-
.build()
108+
.build(),
105109
)
106110

107111
val finalText = mutableListOf<String>()
@@ -119,7 +123,7 @@ class MCPClient : AutoCloseable {
119123
// Call the tool with provided arguments
120124
val result = mcp.callTool(
121125
name = toolName,
122-
arguments = toolArgs ?: emptyMap()
126+
arguments = toolArgs ?: emptyMap(),
123127
)
124128
finalText.add("[Calling tool $toolName with args $toolArgs]")
125129

@@ -131,17 +135,19 @@ class MCPClient : AutoCloseable {
131135
"""
132136
"type": "tool_result",
133137
"tool_name": $toolName,
134-
"result": ${result?.content?.joinToString("\n") { (it as TextContent).text ?: "" }}
135-
""".trimIndent()
138+
"result": ${result?.content?.joinToString("\n") {
139+
(it as TextContent).text ?: ""
140+
}}
141+
""".trimIndent(),
136142
)
137-
.build()
143+
.build(),
138144
)
139145

140146
// Retrieve an updated response after tool execution
141147
val aiResponse = anthropic.messages().create(
142148
messageParamsBuilder
143149
.messages(messages)
144-
.build()
150+
.build(),
145151
)
146152

147153
// Append the updated response to final text
@@ -160,7 +166,7 @@ class MCPClient : AutoCloseable {
160166

161167
while (true) {
162168
print("\nQuery: ")
163-
val message = readLine() ?: break
169+
val message = readlnOrNull() ?: break
164170
if (message.lowercase() == "quit") break
165171
val response = processQuery(message)
166172
println("\n$response")
@@ -173,4 +179,4 @@ class MCPClient : AutoCloseable {
173179
anthropic.close()
174180
}
175181
}
176-
}
182+
}

0 commit comments

Comments
 (0)