kotlin-sdk/samples/kotlin-mcp-server
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Leonid Stashevsky 42f560e665
Add server sample (#8)
* Change required dependencies from implementation to api

* Add kotlin mcp server sample

Fixes #6

* Add explicit nop logger to clean CLI

* Update readme with reference
2024-12-16 13:27:00 +01:00
..
.idea Add server sample (#8) 2024-12-16 13:27:00 +01:00
gradle/wrapper Add server sample (#8) 2024-12-16 13:27:00 +01:00
src/main/kotlin Add server sample (#8) 2024-12-16 13:27:00 +01:00
.gitignore Add server sample (#8) 2024-12-16 13:27:00 +01:00
build.gradle.kts Add server sample (#8) 2024-12-16 13:27:00 +01:00
gradle.properties Add server sample (#8) 2024-12-16 13:27:00 +01:00
gradlew Add server sample (#8) 2024-12-16 13:27:00 +01:00
gradlew.bat Add server sample (#8) 2024-12-16 13:27:00 +01:00
README.md Add server sample (#8) 2024-12-16 13:27:00 +01:00
settings.gradle.kts Add server sample (#8) 2024-12-16 13:27:00 +01:00

MCP Kotlin Server Sample

A sample implementation of an MCP (Model Communication Protocol) server in Kotlin that demonstrates different server configurations and transport methods.

Features

  • Multiple server operation modes:
    • Standard I/O server
    • SSE (Server-Sent Events) server with plain configuration
    • SSE server using Ktor plugin
  • Built-in capabilities for:
    • Prompts management
    • Resources handling
    • Tools integration

Getting Started

Running the Server

To run the server in SSE mode on the port 3001, run:

./gradlew run

Connecting to the Server

For SSE servers (both plain and Ktor plugin versions):

  1. Start the server
  2. Use the MCP inspector to connect to http://localhost:<port>/sse

Server Capabilities

  • Prompts: Supports prompt management with list change notifications
  • Resources: Includes subscription support and list change notifications
  • Tools: Supports tool management with list change notifications

Implementation Details

The server is implemented using:

  • Ktor for HTTP server functionality
  • Kotlin coroutines for asynchronous operations
  • SSE for real-time communication
  • Standard I/O for command-line interface