Back to MCP directory
publicPublicdnsLocal runtime

geniomcpserver

Genio MCP服务器为Haiku上的Genio IDE提供模型上下文协议服务,通过BMessage脚本API让Claude Code直接访问编辑器功能,包括导航、读取写入缓冲区、文本编辑和撤销重做操作。

article

README

🚀 Genio MCP 服务器

Genio MCP 服务器是专为 Haiku 系统上的 Genio IDE 设计的 Model Context Protocol(MCP)服务器。它借助 BMessage 脚本 API,让 Claude Code 能够直接访问 Genio 编辑器,为开发者提供了便捷高效的开发体验。

✨ 主要特性

编辑器状态与导航

  • get_editor_state:获取当前文件、光标位置、选中内容、修改状态、可见行以及滚动位置等信息。
  • navigate_to:在指定的行和列位置打开文件。

编辑器内容操作

  • read_editor_buffer:读取当前编辑器的内容。
  • write_editor_buffer:替换整个编辑器缓冲区的内容。

文本编辑功能

  • insert_at_cursor:在光标位置插入或替换选中内容。
  • append_to_file:在文件末尾追加内容。
  • undo / redo:撤销或重做操作。

🚀 快速开始

前提条件

# 在 Haiku 系统上
pkgman install nim          # 需要 Nim >= 2.0.0

构建与安装

# 构建服务器(自动安装依赖项)
nimble build

# 运行测试(需要 Genio 正在运行)
nimble test

# 添加到 Claude Code
claude mcp add --transport stdio genio -- $PWD/genio_mcp_server

或者手动在 ~/.config/claude-code/config.json 中进行配置:

{
  "mcpServers": {
    "genio": {
      "command": "/path/to/genio_mcp_server",
      "transport": "stdio"
    }
  }
}

配置说明

构建设置位于以下文件中:

  • genio_mcp_server.nimble:包含包元数据、依赖项以及后端选择等信息。
  • nim.cfg:编译器标志(需要使用 C++ 后端,并链接 -lbe)。

🔧 技术细节

服务器分为两层:

  1. MCP 层src/genio_mcp_server.nim):使用 nimcp 通过标准输入输出实现 JSON-RPC。
  2. Genio 接口层src/genio_interface.nim):独立的 Haiku API 外部函数接口绑定。

与 Genio 的通信使用 Haiku 的 BMessage 协议,示例代码如下:

var msg = newBMessage(MSG_GET_PROPERTY)
msg.addSpecifier("CaretPosition")
msg.addSpecifier("SelectedEditor")
let reply = genio.sendMessage(msg)

💻 使用示例

基础用法

src/genio_mcp_server.nim 中添加工具的示例代码:

mcpTool:
  proc my_tool(arg: string): string =
    ## 工具描述
    {.cast(gcsafe).}:
      let result = genio.someOperation(arg)
      if result.isSome: return result.get()
      else: raise newException(IOError, "Failed")

测试

nimble test

共有 18 个测试用例,涵盖了连接、导航、编辑器状态、文本操作以及撤销/重做等功能。

📚 详细文档

故障排除

服务器无法连接

  • 确保 Genio 正在运行。
  • 运行 ./genio_mcp_server,应该看到 "Connected to Genio IDE" 信息。

构建错误

  • nimcp not found:运行 nimble install nimcp
  • BApplication undefined:安装 Haiku 开发头文件:pkgman install haiku_devel

📄 许可证

本项目采用 MIT 许可证。

help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client