You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* add wasm and ios targets
* add yarn.lock file to gitignore
* clean up code
* fix typo in method name
* add wasm server example
* update jrelease publishing for klibs
* update gradle-publish workflow to use macos runner
* update README to reflect multiplatform support and clarify server setup for JVM and WASM
* remove the old main file from the kotlin-mcp-server example
* update api dump
* Refactor `build.gradle.kts`
* clean up imports and remove unnecessary charset specification in tests
* add JS target configuration and update API dump
Copy file name to clipboardExpand all lines: README.md
+14-4Lines changed: 14 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,19 @@
1
1
# MCP Kotlin SDK
2
2
3
-
Kotlin implementation of the [Model Context Protocol](https://modelcontextprotocol.io) (MCP), providing both client and server capabilities for integrating with LLM surfaces.
Kotlin Multiplatform implementation of the [Model Context Protocol](https://modelcontextprotocol.io) (MCP),
9
+
providing both client and server capabilities for integrating with LLM surfaces across various platforms.
4
10
5
11
## Overview
6
12
7
-
The Model Context Protocol allows applications to provide context for LLMs in a standardized way, separating the concerns of providing context from the actual LLM interaction. This Kotlin SDK implements the full MCP specification, making it easy to:
13
+
The Model Context Protocol allows applications to provide context for LLMs in a standardized way,
14
+
separating the concerns of providing context from the actual LLM interaction.
15
+
This SDK implements the MCP specification for Kotlin,
16
+
enabling you to build applications that can communicate using MCP on the JVM, WebAssembly and iOS.
8
17
9
18
- Build MCP clients that can connect to any MCP server
10
19
- Create MCP servers that expose resources, prompts and tools
@@ -13,7 +22,7 @@ The Model Context Protocol allows applications to provide context for LLMs in a
13
22
14
23
## Samples
15
24
16
-
-[kotlin-mcp-server](./samples/kotlin-mcp-server): shows how to set up a Kotlin MCP server with different tools and other features.
25
+
-[kotlin-mcp-server](./samples/kotlin-mcp-server): demonstrates a multiplatform (JVM, Wasm) MCP server setup with various features and transports.
17
26
-[weather-stdio-server](./samples/weather-stdio-server): shows how to build a Kotlin MCP server providing weather forecast and alerts using STDIO transport.
18
27
-[kotlin-mcp-client](./samples/kotlin-mcp-client): demonstrates building an interactive Kotlin MCP client that connects to an MCP server via STDIO and integrates with Anthropic’s API.
Copy file name to clipboardExpand all lines: samples/kotlin-mcp-server/README.md
+24-8Lines changed: 24 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,15 @@
1
1
# MCP Kotlin Server Sample
2
2
3
-
A sample implementation of an MCP (Model Communication Protocol) server in Kotlin that demonstrates different server configurations and transport methods.
3
+
A sample implementation of an MCP (Model Communication Protocol) server in Kotlin that demonstrates different server
4
+
configurations and transport methods for both JVM and WASM targets.
4
5
5
6
## Features
6
7
7
8
- Multiple server operation modes:
8
-
- Standard I/O server
9
-
- SSE (Server-Sent Events) server with plain configuration
10
-
- SSE server using Ktor plugin
9
+
- Standard I/O server (JVM only)
10
+
- SSE (Server-Sent Events) server with plain configuration (JVM, WASM)
11
+
- SSE server using Ktor plugin (JVM, WASM)
12
+
- Multiplatform support
11
13
- Built-in capabilities for:
12
14
- Prompts management
13
15
- Resources handling
@@ -17,17 +19,30 @@ A sample implementation of an MCP (Model Communication Protocol) server in Kotli
17
19
18
20
### Running the Server
19
21
20
-
To run the server in SSE mode on the port 3001, run:
22
+
You can run the server on the JVM or using Kotlin/WASM on Node.js.
23
+
24
+
25
+
#### JVM:
26
+
27
+
To run the server on the JVM (defaults to SSE mode with Ktor plugin on port 3001):
28
+
29
+
```bash
30
+
./gradlew runJvm
31
+
```
32
+
33
+
#### WASM:
34
+
35
+
To run the server using Kotlin/WASM on Node.js (defaults to SSE mode with Ktor plugin on port 3001):
21
36
22
37
```bash
23
-
./gradlew run
38
+
./gradlew wasmJsNodeDevelopmentRun
24
39
```
25
40
26
41
### Connecting to the Server
27
42
28
-
For SSE servers (both plain and Ktor plugin versions):
43
+
For servers on JVM or WASM:
29
44
1. Start the server
30
-
2. Use the MCP inspector to connect to `http://localhost:<port>/sse`
45
+
2. Use the [MCP inspector](https://modelcontextprotocol.io/docs/tools/inspector) to connect to `http://localhost:<port>/sse`
31
46
32
47
## Server Capabilities
33
48
@@ -42,3 +57,4 @@ The server is implemented using:
42
57
- Kotlin coroutines for asynchronous operations
43
58
- SSE for real-time communication
44
59
- Standard I/O for command-line interface
60
+
- Common Kotlin code shared between JVM and WASM targets
0 commit comments