MCP Catalogs
首页mcp4k screenshot

mcp4k

by ondrsh·69·综合分 46

用于构建 MCP 客户端和服务器并提供编译时类型安全的 Kotlin 多平台框架。

developer-toolsai-llm
4
Forks
0
活跃 Issue
1 个月前
最近提交
2 天前
收录于

概述

mcp4k 是一个全面的 Kotlin 框架,实现了大部分 MCP 规范。它采用编译驱动的方法,在编译时而非运行时强制执行正确的参数类型。该框架支持客户端和服务器实现,包含工具、资源、提示和采样功能。它使用 @McpTool 和 @McpPrompt 等注解提供清晰的 API 来定义服务器功能。当前仅支持 stdio 传输方式,但计划在未来支持其他传输方式。

试试问 AI

装完之后,这里有 5 个你可以让 AI 做的事:

:构建基于 Kotlin 的 MCP 服务器以提供自定义工具
:创建 Kotlin 客户端与 MCP 服务器交互
:使用 Kotlin 多平台开发跨平台 MCP 应用
:mcp4k 兼容哪些 Kotlin 版本?
:mcp4k 是否支持 stdio 以外的传输方式?

什么时候选它

当在 Kotlin 多平台项目中构建 MCP 服务器/客户端并需要编译时类型安全和自动 JSON-RPC 处理时,选择 mcp4k。

什么时候不要选它

不适用于需要超出 stdio 传输的项目,或者当您需要使用 Kotlin 以外的语言时。

此 server 暴露的工具

从 README 抽取出 7 个工具
  • reverseStringinput: String

    Reverses an input string

  • sendEmailrecipients: List<String>, email: Email

    Sends an email with specified recipients and email content

  • setUserNamename: String

    Sets the username in the server context

  • greetUser

    Greets the user whose name is stored in the server context

  • toolThatAddsSecondTool

    A tool that adds another tool to the server at runtime

  • codeReviewPromptcode: String

    Generates a code review prompt based on the provided code

  • slowToolOperationiterations: Int = 10

    Performs a slow operation with specified iterations

可对比工具

mcp-tsmcp-pythonmcp-js

安装

安装

将 mcp4k 添加到您的构建文件中:

plugins {
  kotlin("multiplatform") version "2.3.21" // 或 kotlin("jvm")
  kotlin("plugin.serialization") version "2.3.21"

  id("sh.ondr.mcp4k") version "0.4.10" // <-- 添加此行
}

在 Claude Desktop 中使用

添加到您的 claude_desktop_config.json 文件:

{
  "mcpServers": {
    "mcp4k-example": {
      "command": "java",
      "args": ["-jar", "your/mcp4k-server.jar 的路径"]
    }
  }
}

FAQ

mcp4k 兼容哪些 Kotlin 版本?
每个 mcp4k 版本都与特定的 Kotlin 版本绑定。例如,版本 0.4.10 需要 Kotlin 2.3.21。请查阅 README 获取完整的兼容性表格。
mcp4k 是否支持 stdio 以外的传输方式?
目前,mcp4k 仅支持 stdio 传输方式,但计划在未来支持 HTTP-Streaming 和其他传输方式。

mcp4k 对比

GitHub →

最后更新于 · 由 README + GitHub 公开数据自动生成。