Skip to main content
Glama

openwiki-mcp

MCP 服务器,将 OpenWiki (OpenChamber) 文档生成功能作为 模型上下文协议工具暴露,使官方、未修改的 OpenCode(或任何 MCP 主机)能够生成和更新仓库 wiki。

完全独立于 opencode 源代码树 —— openwiki 本身被解析为 外部包(npm 安装或分段离线包),代理凭据通过环境变量传递,从不存储。

工具

工具

映射到代理

注释

openwiki_status

— (仅本地)

检查 openwiki/ + .last-update.json。无代理,无模型,可离线工作。

openwiki_generate

init

首次 wiki 生成。可选的 userMessage 可引导代理。

openwiki_update

update

基于差异的刷新;仅重新生成过时的页面。

Related MCP server: Minecraft Wiki MCP Server

前提条件

  • Node.js >= 22(MCP 服务器和代理子进程均在 node 下运行)

  • openwiki 包安装:

    npm install -g openwiki          # online machine, or
    # offline machine: copy a prepared bundle and point at it
    set OPENWIKI_PACKAGE_ROOT=D:\path\to\staged\bundle\node_modules\openwiki

    OPENWIKI_PACKAGE_ROOT 可以直接指向包根目录,也可以指向包含 node_modules/openwiki 的布局。分段离线包不需要 连接点或符号链接技巧——Node 通过正常的 node_modules 遍历来解析代理的裸导入。

代理模型配置

服务器将以下变量传递(从不存储)到代理子进程中:

环境变量(服务器端)

含义

OPENWIKI_PROVIDER

openai(默认)或 openai-compatible

OPENWIKI_MODEL_ID

模型 ID,例如 gpt-5

OPENAI_COMPATIBLE_BASE_URL

指向本地 OpenAI 兼容网关,以将真实密钥保留在代理环境之外

OPENAI_COMPATIBLE_API_KEY

openai-compatible 提供商的密钥

OPENAI_API_KEY

openai 提供商的密钥

OPENWIKI_PACKAGE_ROOT

可选;指向 openwiki 安装的显式路径

每次调用的 modelId/language/userMessage 工具参数会覆盖该次运行的 环境设置。

注册到 OpenCode

添加到您的 opencode.json / opencode.jsonc:

{
  "mcp": {
    "openwiki": {
      "type": "local",
      "command": ["node", "D:/path/to/openwiki-mcp/dist/index.js"],
      "environment": {
        "OPENWIKI_PACKAGE_ROOT": "D:/path/to/staged/bundle/node_modules/openwiki",
        "OPENWIKI_PROVIDER": "openai-compatible",
        "OPENWIKI_MODEL_ID": "gpt-5",
        "OPENAI_COMPATIBLE_BASE_URL": "http://127.0.0.1:4096/v1"
      }
    }
  }
}

然后这三个工具会作为普通工具出现在每个 OpenCode 对话中。

开发

npm install
npm run build        # tsc -> dist/
npm test             # node --test (status inspection unit tests)
npm run dev          # run the server via tsx (dev)

冒烟测试:

node scripts/smoke.mjs <dir> status        # local inspection only
node scripts/smoke.mjs <dir> init "note"   # full agent run (needs model env)

手动 MCP 协议检查:

@'
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"t","version":"1"}}}
{"jsonrpc":"2.0","method":"notifications/initialized"}
{"jsonrpc":"2.0","id":1,"method":"tools/list"}
'@ | node dist/index.js

设计说明

  • src/openwiki/resolve.ts — 包解析:OPENWIKI_PACKAGE_ROOT,然后 require.resolve("openwiki/package.json")。

  • src/openwiki/worker.mjs — 适配器工作进程:从 stdin 读取一个作业,通过绝对路径导入 代理入口,将 NDJSON 进度信息输出到 stdout。从 opencode 分支的 packages/openwiki 适配器移植,并保持独立。

  • src/openwiki/run.ts — 将工作进程生成为 MCP 服务器的子进程,因此 挂起的代理绝不会拖垮 MCP 主机。

  • src/status.ts — 本地状态检查(无模型成本)。

  • v0.1 将 generate 映射到代理的 init 命令,匹配 openwiki 0.3.x 其中 init 是首次生成命令,update 是刷新命令。

Related MCP Connectors

Related MCP Servers