kotlin-sdk/samples/kotlin-mcp-client
Repository files (latest commit first)
Filename Latest commit message Latest commit date
dependabot[bot] 3c917cc97a
chore(deps): bump com.anthropic:anthropic-java from 2.26.0 to 2.27.0 in /samples/kotlin-mcp-client in the other-dependencies group across 1 directory (#719)
[//]: # (dependabot-start)
⚠️  **Dependabot is rebasing this PR** ⚠️ 

Rebasing might not happen immediately, so don't worry if this takes some
time.

Note: if you make any changes to this PR yourself, they will take
precedence over the rebase.

---

[//]: # (dependabot-end)

Bumps the other-dependencies group with 1 update in the
/samples/kotlin-mcp-client directory:
[com.anthropic:anthropic-java](https://github.com/anthropics/anthropic-sdk-java).

Updates `com.anthropic:anthropic-java` from 2.26.0 to 2.27.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.27.0</h2>
<h2>2.27.0 (2026-04-23)</h2>
<p>Full Changelog: <a
href="https://github.com/anthropics/anthropic-sdk-java/compare/v2.26.0...v2.27.0">v2.26.0...v2.27.0</a></p>
<h3>Features</h3>
<ul>
<li><strong>api:</strong> CMA Memory public beta (<a
href="d95526a079">d95526a</a>)</li>
</ul>
<h3>Bug Fixes</h3>
<ul>
<li><strong>api:</strong> fix errors in api spec (<a
href="9d5a18a1e2">9d5a18a</a>)</li>
<li><strong>api:</strong> restore missing features (<a
href="e737fbf367">e737fbf</a>)</li>
</ul>
<h3>Chores</h3>
<ul>
<li>add missing methods (<a
href="5984a2f018">5984a2f</a>)</li>
<li><strong>client:</strong> stable title (<a
href="4c4f2cefff">4c4f2ce</a>)</li>
<li><strong>tests:</strong> bump steady to v0.22.1 (<a
href="ef1bbcafbc">ef1bbca</a>)</li>
</ul>
</blockquote>
</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.27.0 (2026-04-23)</h2>
<p>Full Changelog: <a
href="https://github.com/anthropics/anthropic-sdk-java/compare/v2.26.0...v2.27.0">v2.26.0...v2.27.0</a></p>
<h3>Features</h3>
<ul>
<li><strong>api:</strong> CMA Memory public beta (<a
href="d95526a079">d95526a</a>)</li>
</ul>
<h3>Bug Fixes</h3>
<ul>
<li><strong>api:</strong> fix errors in api spec (<a
href="9d5a18a1e2">9d5a18a</a>)</li>
<li><strong>api:</strong> restore missing features (<a
href="e737fbf367">e737fbf</a>)</li>
</ul>
<h3>Chores</h3>
<ul>
<li>add missing methods (<a
href="5984a2f018">5984a2f</a>)</li>
<li><strong>client:</strong> stable title (<a
href="4c4f2cefff">4c4f2ce</a>)</li>
<li><strong>tests:</strong> bump steady to v0.22.1 (<a
href="ef1bbcafbc">ef1bbca</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="2dbf515b95"><code>2dbf515</code></a>
chore: release main (<a
href="https://redirect.github.com/anthropics/anthropic-sdk-java/issues/325">#325</a>)</li>
<li>See full diff in <a
href="https://github.com/anthropics/anthropic-sdk-java/compare/v2.26.0...v2.27.0">compare
view</a></li>
</ul>
</details>
<br />

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-27 16:21:38 +00:00
..
gradle chore(deps): bump com.anthropic:anthropic-java from 2.26.0 to 2.27.0 in /samples/kotlin-mcp-client in the other-dependencies group across 1 directory (#719) 2026-04-27 16:21:38 +00:00
src/main docs: update client and server samples (#598) 2026-03-13 10:23:51 +01:00
build.gradle.kts Add Ktor BOM for dependency management across all modules, run Kotlin-MCP-Server Sample (#367) 2025-11-04 11:44:39 +02:00
gradle.properties #302 Update samples build workflow (#330) 2025-10-23 13:02:22 +03:00
gradlew chore(deps): bump the other-dependencies group across 4 directories with 4 updates (#634) 2026-03-27 00:58:15 +00:00
gradlew.bat chore(deps): bump the other-dependencies group across 4 directories with 4 updates (#634) 2026-03-27 00:58:15 +00:00
README.md docs: streamable server sample (#595) 2026-03-10 12:45:21 +01:00
settings.gradle.kts #302 Update samples build workflow (#330) 2025-10-23 13:02:22 +03:00

Kotlin MCP Client

An interactive CLI client that connects to any MCP server over STDIO and pipes queries through Anthropic's Claude API.

Overview

This sample demonstrates a complete MCP client workflow: launching an MCP server as a subprocess, discovering its tools, converting them to Anthropic's tool format, and running an interactive chat loop where Claude can call server tools on behalf of the user.

Prerequisites

  • JDK 17+
  • An ANTHROPIC_API_KEY environment variable set with a valid Anthropic API key
  • An MCP server script to connect to (.js, .py, or .jar)

Build & Run

Run the client, passing the path to an MCP server:

# Connect to a JVM server
./gradlew run --args="path/to/server.jar"

# Connect to a Python server
./gradlew run --args="path/to/server.py"

# Connect to a Node.js server
./gradlew run --args="path/to/build/index.js"

Note

The client uses STDIO transport, so it launches the MCP server as a subprocess. Ensure the server script is executable and is a valid .js, .py, or .jar file.

MCP Capabilities

From the client perspective, this sample demonstrates:

  • Tool discovery — lists tools from the connected server and converts them to Anthropic's tool format.
  • Tool invocation — when Claude's response requests a tool call, the client invokes the corresponding MCP tool and feeds the result back into the conversation.

Additional Resources