Token导航 LogoToken导航TokenDH.com
MCP Kotlin Starter logo
运维云端stdio官方级别未说明来源级核验

MCP Kotlin Starter

MCP Server

@modelcontextprotocol/inspector

一个功能完整的Kotlin版Model Context Protocol服务器模板,提供生产就绪的代码实现。

工具数

5

提示词数

0

GitHub Stars

0

资源数

0
Kotlin开发模板JavaScriptVS Code生产就绪VS Code

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

SamMorrowDrums

提供方

SamMorrowDrums

最后核验

2026/5/17 20:20

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx @modelcontextprotocol/inspector java -jar build/libs/mcp-kotlin-starter-1.0.0-all.jar

详细介绍

MCP Kotlin入门

![CI](https://github.com/SamMorrowDrums/mcp-kotlin-starter/actions/workflows/ci.yml) ![Kotlin](https://kotlinlang.org/) ![License: MIT](https://opensource.org/licenses/MIT) ![MCP](https://modelcontextprotocol.io/)

Kotlin中一个功能完整的模型上下文协议(MCP)服务器模板。此入门程序使用干净的生产就绪代码演示了MCP的所有主要功能。

📚 文档

✨ 特性

类别功能描述
工具hello基本问候工具
get_weather具有结构化JSON输出的工具
long_task带有进度报告的任务
calculate算术运算
echo回显消息
资源info://about服务器信息
doc://example标记文档示例
config://settings服务器配置
提示greet各种风格的问候
code_review重点领域代码审查

⚠️ 已知限制

Kotlin MCP SDK(v0.8.1)有一些局限性。看 SDK_LIMITIONS.md 有关完整详细信息:

  • 资源模板:SDK不支持 addResourceTemplate()参数化资源使用手动URI解析。
  • 提示标题:The addPrompt() 方法不接受 title 现场。

🚀 快速开始

先决条件

安装

# Clone the repository
git clone https://github.com/SamMorrowDrums/mcp-kotlin-starter.git
cd mcp-kotlin-starter

# Build
./gradlew build

运行服务器

stdio传输 (地方发展):

./gradlew runStdio

HTTP传输 (用于远程/web部署):

./gradlew runHttp
# Server runs on http://localhost:3000

🔧 VS代码集成

该项目包括用于无缝开发的VS代码配置:

  1. 在VS Code中打开项目
  2. MCP配置位于 .vscode/mcp.json
  3. 使用Gradle任务进行构建
  4. 使用VS Code的MCP工具测试服务器

📁 项目结构

.
├── src/main/kotlin/mcp/starter/
│   ├── Server.kt         # Server setup with tools, resources, prompts
│   ├── StdioMain.kt      # stdio transport entrypoint
│   └── HttpMain.kt       # HTTP transport entrypoint
├── src/main/resources/
│   └── logback.xml       # Logging configuration
├── .vscode/
│   └── mcp.json          # MCP server configuration
├── build.gradle.kts      # Gradle build file
├── settings.gradle.kts
├── server.json           # MCP discovery configuration
└── README.md

🛠️ 发展

# Build the project
./gradlew build

# Run tests
./gradlew test

# Create a fat JAR
./gradlew fatJar

# Clean build
./gradlew clean build

🔍 MCP 检查员

MCP 检查员 是测试和调试MCP服务器的重要开发工具。

运行检查器

# First, build the fat JAR
./gradlew fatJar

# Then run with inspector
npx @modelcontextprotocol/inspector java -jar build/libs/mcp-kotlin-starter-1.0.0-all.jar

检查员提供什么

  • 工具选项卡:列出并调用所有已注册的带有参数的工具
  • 资源选项卡:浏览和阅读资源
  • 提示选项卡:查看和测试提示模板
  • 日志选项卡:请参阅客户端和服务器之间的JSON-RPC消息

📖 功能示例

添加工具

server.addTool(
    name = "hello",
    description = "A friendly greeting tool"
) { request ->
    val name = request.arguments["name"]?.jsonPrimitive?.content ?: "World"
    listOf(TextContent("Hello, $name! Welcome to MCP."))
}

添加资源

server.addResource(
    uri = "config://settings",
    name = "Server Settings",
    mimeType = "application/json"
) {
    ReadResourceResult(
        contents = listOf(
            TextResourceContents(
                uri = "config://settings",
                mimeType = "application/json",
                text = """{"precision": 2}"""
            )
        )
    )
}

添加提示

server.addPrompt(
    name = "greet",
    description = "Generate a greeting in a specific style"
) { request ->
    val name = request.arguments?.get("name") ?: "friend"
    GetPromptResult(
        messages = listOf(
            PromptMessage(
                role = Role.user,
                content = TextContent("Write a greeting for $name.")
            )
        )
    )
}

🔐 环境变量

变量描述默认值
PORTHTTP服务器端口3000

🤝 贡献

欢迎投稿!请确保您的更改与其他语言初学者保持功能对等。

📄 许可证

MIT许可证-请参阅 许可证 了解详情。

目录标签

目录标签

Kotlin开发模板JavaScriptVS Code生产就绪本地部署MCP服务器Kotlin开发工具集成

支持客户端

VS Code

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Node.js

来源包(packageName,安装包名)

@modelcontextprotocol/inspector

工具数量(toolCount,工具数)

5

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP