kotlin-mcp-server-generator
작성자: github
프로덕션 준비가 완료된 Kotlin MCP 서버 프로젝트를 Gradle, 공식 SDK, 타입화된 도구와 함께 생성합니다. build.gradle.kts, 패키지 레이아웃, io.modelcontextprotocol:kotlin-sdk를 사용한 MCP 서버 구성을 포함한 완전한 프로젝트 구조를 스캐폴딩합니다. JSON 스키마 정의, 타입화된 입력/출력, 오류 처리 패턴을 갖춘 2~3개의 샘플 도구를 포함합니다. stdio 전송, 환경 변수 구성, kotlin-logging 통합을 지원하는 코루틴 기반 서버 설정을 제공합니다. 테스트를 포함합니다...
npx skills add https://github.com/github/awesome-copilot --skill kotlin-mcp-server-generatorKotlin MCP Server Project Generator
Generate a complete, production-ready Model Context Protocol (MCP) server project in Kotlin.
Project Requirements
You will create a Kotlin MCP server with:
- Project Structure: Gradle-based Kotlin project layout
- Dependencies: Official MCP SDK, Ktor, and kotlinx libraries
- Server Setup: Configured MCP server with transports
- Tools: At least 2-3 useful tools with typed inputs/outputs
- Error Handling: Proper exception handling and validation
- Documentation: README with setup and usage instructions
- Testing: Basic test structure with coroutines
Template Structure
myserver/
├── build.gradle.kts
├── settings.gradle.kts
├── gradle.properties
├── src/
│ ├── main/
│ │ └── kotlin/
│ │ └── com/example/myserver/
│ │ ├── Main.kt
│ │ ├── Server.kt
│ │ ├── config/
│ │ │ └── Config.kt
│ │ └── tools/
│ │ ├── Tool1.kt
│ │ └── Tool2.kt
│ └── test/
│ └── kotlin/
│ └── com/example/myserver/
│ └── ServerTest.kt
└── README.md
build.gradle.kts Template
plugins {
kotlin("jvm") version "2.1.0"
kotlin("plugin.serialization") version "2.1.0"
application
}
group = "com.example"
version = "1.0.0"
repositories {
mavenCentral()
}
dependencies {
implementation("io.modelcontextprotocol:kotlin-sdk:0.7.2")
// Ktor for transports
implementation("io.ktor:ktor-server-netty:3.0.0")
implementation("io.ktor:ktor-client-cio:3.0.0")
// Serialization
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
// Coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
// Logging
implementation("io.github.oshai:kotlin-logging-jvm:7.0.0")
implementation("ch.qos.logback:logback-classic:1.5.12")
// Testing
testImplementation(kotlin("test"))
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0")
}
application {
mainClass.set("com.example.myserver.MainKt")
}
tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(17)
}
settings.gradle.kts Template
rootProject.name = "{{PROJECT_NAME}}"
Main.kt Template
package com.example.myserver
import io.modelcontextprotocol.kotlin.sdk.server.StdioServerTransport
import kotlinx.coroutines.runBlocking
import io.github.oshai.kotlinlogging.KotlinLogging
private val logger = KotlinLogging.logger {}
fun main() = runBlocking {
logger.info { "Starting MCP server..." }
val config = loadConfig()
val server = createServer(config)
// Use stdio transport
val transport = StdioServerTransport()
logger.info { "Server '${config.name}' v${config.version} ready" }
server.connect(transport)
}
Server.kt Template
package com.example.myserver
import io.modelcontextprotocol.kotlin.sdk.server.Server
import io.modelcontextprotocol.kotlin.sdk.server.ServerOptions
import io.modelcontextprotocol.kotlin.sdk.Implementation
import io.modelcontextprotocol.kotlin.sdk.ServerCapabilities
import com.example.myserver.tools.registerTools
fun createServer(config: Config): Server {
val server = Server(
serverInfo = Implementation(
name = config.name,
version = config.version
),
options = ServerOptions(
capabilities = ServerCapabilities(
tools = ServerCapabilities.Tools(),
resources = ServerCapabilities.Resources(
subscribe = true,
listChanged = true
),
prompts = ServerCapabilities.Prompts(listChanged = true)
)
)
) {
config.description
}
// Register all tools
server.registerTools()
return server
}
Config.kt Template
package com.example.myserver.config
import kotlinx.serialization.Serializable
@Serializable
data class Config(
val name: String = "{{PROJECT_NAME}}",
val version: String = "1.0.0",
val description: String = "{{PROJECT_DESCRIPTION}}"
)
fun loadConfig(): Config {
return Config(
name = System.getenv("SERVER_NAME") ?: "{{PROJECT_NAME}}",
version = System.getenv("VERSION") ?: "1.0.0",
description = System.getenv("DESCRIPTION") ?: "{{PROJECT_DESCRIPTION}}"
)
}
Tool1.kt Template
package com.example.myserver.tools
import io.modelcontextprotocol.kotlin.sdk.server.Server
import io.modelcontextprotocol.kotlin.sdk.CallToolRequest
import io.modelcontextprotocol.kotlin.sdk.CallToolResult
import io.modelcontextprotocol.kotlin.sdk.TextContent
import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.put
import kotlinx.serialization.json.putJsonObject
import kotlinx.serialization.json.putJsonArray
fun Server.registerTool1() {
addTool(
name = "tool1",
description = "Description of what tool1 does",
inputSchema = buildJsonObject {
put("type", "object")
putJsonObject("properties") {
putJsonObject("param1") {
put("type", "string")
put("description", "First parameter")
}
putJsonObject("param2") {
put("type", "integer")
put("description", "Optional second parameter")
}
}
putJsonArray("required") {
add("param1")
}
}
) { request: CallToolRequest ->
// Extract and validate parameters
val param1 = request.params.arguments["param1"] as? String
?: throw IllegalArgumentException("param1 is required")
val param2 = (request.params.arguments["param2"] as? Number)?.toInt() ?: 0
// Perform tool logic
val result = performTool1Logic(param1, param2)
CallToolResult(
content = listOf(
TextContent(text = result)
)
)
}
}
private fun performTool1Logic(param1: String, param2: Int): String {
// Implement tool logic here
return "Processed: $param1 with value $param2"
}
tools/ToolRegistry.kt Template
package com.example.myserver.tools
import io.modelcontextprotocol.kotlin.sdk.server.Server
fun Server.registerTools() {
registerTool1()
registerTool2()
// Register additional tools here
}
ServerTest.kt Template
package com.example.myserver
import kotlinx.coroutines.test.runTest
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
class ServerTest {
@Test
fun `test server creation`() = runTest {
val config = Config(
name = "test-server",
version = "1.0.0",
description = "Test server"
)
val server = createServer(config)
assertEquals("test-server", server.serverInfo.name)
assertEquals("1.0.0", server.serverInfo.version)
}
@Test
fun `test tool1 execution`() = runTest {
val config = Config()
val server = createServer(config)
// Test tool execution
// Note: You'll need to implement proper testing utilities
// for calling tools in the server
}
}
README.md Template
# {{PROJECT_NAME}}
A Model Context Protocol (MCP) server built with Kotlin.
## Description
{{PROJECT_DESCRIPTION}}
## Requirements
- Java 17 or higher
- Kotlin 2.1.0
## Installation
Build the project:
\`\`\`bash
./gradlew build
\`\`\`
## Usage
Run the server with stdio transport:
\`\`\`bash
./gradlew run
\`\`\`
Or build and run the jar:
\`\`\`bash
./gradlew installDist
./build/install/{{PROJECT_NAME}}/bin/{{PROJECT_NAME}}
\`\`\`
## Configuration
Configure via environment variables:
- `SERVER_NAME`: Server name (default: "{{PROJECT_NAME}}")
- `VERSION`: Server version (default: "1.0.0")
- `DESCRIPTION`: Server description
## Available Tools
### tool1
{{TOOL1_DESCRIPTION}}
**Input:**
- `param1` (string, required): First parameter
- `param2` (integer, optional): Second parameter
**Output:**
- Text result of the operation
## Development
Run tests:
\`\`\`bash
./gradlew test
\`\`\`
Build:
\`\`\`bash
./gradlew build
\`\`\`
Run with auto-reload (development):
\`\`\`bash
./gradlew run --continuous
\`\`\`
## Multiplatform
This project uses Kotlin Multiplatform and can target JVM, Wasm, and iOS.
See `build.gradle.kts` for platform configuration.
## License
MIT
Generation Instructions
When generating a Kotlin MCP server:
- Gradle Setup: Create proper
build.gradle.ktswith all dependencies - Package Structure: Follow Kotlin package conventions
- Type Safety: Use data classes and kotlinx.serialization
- Coroutines: All operations should be suspending functions
- Error Handling: Use Kotlin exceptions and validation
- JSON Schemas: Use
buildJsonObjectfor tool schemas - Testing: Include coroutine test utilities
- Logging: Use kotlin-logging for structured logging
- Configuration: Use data classes and environment variables
- Documentation: KDoc comments for public APIs
Best Practices
- Use suspending functions for all async operations
- Leverage Kotlin's null safety and type system
- Use data classes for structured data
- Apply kotlinx.serialization for JSON handling
- Use sealed classes for result types
- Implement proper error handling with Result/Either patterns
- Write tests using kotlinx-coroutines-test
- Use dependency injection for testability
- Follow Kotlin coding conventions
- Use meaningful names and KDoc comments
Transport Options
Stdio Transport
val transport = StdioServerTransport()
server.connect(transport)
SSE Transport (Ktor)
embeddedServer(Netty, port = 8080) {
mcp {
Server(/*...*/) { "Description" }
}
}.start(wait = true)
Multiplatform Configuration
For multiplatform projects, add to build.gradle.kts:
kotlin {
jvm()
js(IR) { nodejs() }
wasmJs()
sourceSets {
commonMain.dependencies {
implementation("io.modelcontextprotocol:kotlin-sdk:0.7.2")
}
}
}
github의 다른 스킬
console-rendering
github
Go에서 struct 태그 기반 콘솔 렌더링 시스템 사용 지침
official
acquire-codebase-knowledge
github
사용자가 기존 코드베이스에 대한 매핑, 문서화, 또는 온보딩을 명시적으로 요청할 때 이 스킬을 사용하세요. "이 코드베이스를 매핑해줘", "문서화해줘"와 같은 프롬프트에서 트리거됩니다.
official
acreadiness-assess
github
현재 리포
official
acreadiness-generate-instructions
github
AgentRC 명령어를 통해 맞춤형 AI 에이전트 지침 파일을 생성합니다. .github/copilot-instructions.md 파일을 생성합니다(기본값, VS Code의 Copilot에 권장됨).
official
acreadiness-policy
github
사용자가 AgentRC 정책을 선택, 작성 또는 적용할 수 있도록 지원합니다. 정책은 관련 없는 검사를 비활성화하고, 영향/수준을 재정의하며, 설정을 통해 준비 상태 점수를 사용자 지정합니다.
official
add-educational-comments
github
코드 파일에 교육용 주석을 추가하여 효과적인 학습 자료로 변환합니다. 설명의 깊이와 어조를 세 가지 설정 가능한 지식 수준(초급, 중급, 고급)에 맞게 조정합니다. 파일이 제공되지 않으면 자동으로 요청하며, 빠른 선택을 위해 번호 목록 매칭을 제공합니다. 교육용 주석만을 사용하여 파일을 최대 125%까지 확장합니다(엄격한 제한: 새 줄 400개, 1,000줄 초과 파일의 경우 300개). 파일 인코딩, 들여쓰기 스타일, 구문 정확성 등을 유지합니다.
official
adobe-illustrator-scripting
github
Adobe Illustrator 자동화 스크립트를 ExtendScript(JavaScript/JSX)로 작성, 디버깅 및 최적화합니다. 스크립트를 생성하거나 수정하여 조작할 때 사용합니다.
official
agent-governance
github
선언적 정책, 의도 분류, AI 에이전트 도구 접근 및 행동 제어를 위한 감사 추적. 구성 가능한 거버넌스 정책은 허용/차단된 도구, 콘텐츠 필터, 속도 제한, 승인 요구 사항을 정의하며, 코드가 아닌 구성으로 저장됨. 의미론적 의도 분류는 패턴 기반 신호를 사용하여 도구 실행 전에 위험한 프롬프트(데이터 유출, 권한 상승, 프롬프트 인젝션)를 탐지함. 도구 수준 거버넌스 데코레이터는 함수에서 정책을 적용함...
official