MCP服务器管理工具

一个用于管理MCP服务器注册的工具,可作为独立CLI或可重用库,支持在多种AI客户端中安装和卸载MCP服务器。

  • by kunobi-ninja
  • TypeScript
  • 本地部署
  • 2 星标
  • 更新于
在 GitHub 查看 kunobi-ninja/mcp-installer

使用说明

@kunobi/mcp安装程序

管理跨AI客户端的MCP服务器注册。同时作为一个 独立CLI 以及a 可重用库 MCP服务器提供 --install / --uninstall 支持。

支持的客户端

所有路径都会根据当前操作系统自动解析。

|客户端|格式|项目范围|用户范围(macOS)|用户范围| |---|---|---|---|---|---| |Claude代码|JSON| .mcp.json | ~/.claude.json | ~/.claude.json | ~/.claude.json | |克劳德桌面|JSON|--| ~/Library/Application Support/Claude/claude_desktop_config.json | ~/.config/Claude/claude_desktop_config.json | %APPDATA%/Claude/claude_desktop_config.json | |游标|JSON| .cursor/mcp.json | ~/.cursor/mcp.json | ~/.cursor/mcp.json | ~/.cursor/mcp.json | |Windsurf | JSON| .windsurf/mcp.json | ~/.codeium/windsurf/mcp_config.json | ~/.codeium/windsurf/mcp_config.json | ~/.codeium/windsurf/mcp_config.json | |Gemini CLI | JSON| .gemini/settings.json | ~/.gemini/settings.json | ~/.gemini/settings.json | ~/.gemini/settings.json | |Codex CLI | TOML| .codex/config.toml | ~/.codex/config.toml | ~/.codex/config.toml | %CODEX_HOME%/config.toml | |GitHub Copilot命令行界面|JSON|--| ~/.copilot/mcp-config.json | ~/.copilot/mcp-config.json | ~/.copilot/mcp-config.json |

环境变量覆盖: CLAUDE_CONFIG_DIR (克劳德码检测), CODEX_HOME (Codex CLI路径), COPILOT_HOME (副驾驶CLI路径)。

GitHub Copilot CLI条目是用 type: "local" 和 tools: ["*"] 以匹配Copilot CLI的预期配置形状。

已安装的客户端会自动检测并在提示中预先选择。

命令行界面

npx @kunobi/mcp-installer list
npx @kunobi/mcp-installer install <name> <command> [args...]
npx @kunobi/mcp-installer uninstall <name>

list --显示所有已注册的MCP服务器

$ npx @kunobi/mcp-installer list

User scope
  Claude Code (~/.claude.json)
    ngage                http https://ngage.int-dev.zondax.io/mcp
    clickup              npx -y mcp-remote https://mcp.clickup.com/mcp
  Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json)
    ngage                npx @zondax/cli@latest mcp proxy --url https://ngage.int-dev.zondax.io/mcp
  Codex CLI (~/.codex/config.toml)
    ngage                npx -y mcp-remote https://mcp.clickup.com/mcp

install --注册MCP服务器

npx @kunobi/mcp-installer install kunobi npx @kunobi/mcp

启动交互式提示以选择范围(项目/用户)和目标客户端。

uninstall --删除MCP服务器

npx @kunobi/mcp-installer uninstall kunobi

图书馆

import { install, uninstall } from '@kunobi/mcp-installer';

// Register your MCP server with AI clients
await install({
  name: 'my-server',
  command: 'npx',
  args: ['@my-org/mcp-server'],
});

// Remove it
await uninstall({ name: 'my-server' });

集成示例

#!/usr/bin/env node

const arg = process.argv[2];

if (arg === '--install' || arg === '-i') {
  const { install } = await import('@kunobi/mcp-installer');
  await install({ name: 'my-server', command: 'npx', args: ['@my-org/mcp-server'] });
  process.exit(0);
}

if (arg === '--uninstall' || arg === '-u') {
  const { uninstall } = await import('@kunobi/mcp-installer');
  await uninstall({ name: 'my-server' });
  process.exit(0);
}

// ... start your MCP server

交互流

$ npx @my-org/mcp-server --install

  ◆ my-server MCP — Install

◆ Scope
│ ● Project (current directory)
│ ○ User (global)
└

◆ Clients (detected: Claude Code, Cursor)
│ ◻ Claude Code        (detected)
│ ◻ Claude Desktop
│ ◻ Cursor             (detected)
│ ◻ Windsurf
│ ◻ Gemini CLI
│ ◻ Codex CLI
└

◇ Wrote .mcp.json (Claude Code)
◇ Updated ~/.cursor/mcp.json (Cursor)

✔ Done! Restart your AI client to load the new MCP server.

API

install(entry: McpServerEntry): Promise<void>

将服务器条目写入所选客户端配置的交互式提示。

uninstall(entry: { name: string }): Promise<void>

从所选客户端配置中删除服务器项的交互式提示。提供了一个“Both”范围选项,可以一次性清理项目和用户配置。

McpServerEntry

interface McpServerEntry {
  name: string;                    // Server name (key in mcpServers)
  command: string;                 // e.g. "npx"
  args: string[];                  // e.g. ["@my-org/mcp-server"]
  env?: Record<string, string>;   // Optional environment variables
}

list(cwd?: string): ClientConfig[]

返回所有客户端和作用域中的所有已注册MCP服务器。可用于构建仪表板或诊断。

import { list } from '@kunobi/mcp-installer';

for (const config of list()) {
  if (config.servers.length > 0) {
    console.log(`${config.client} (${config.scope}): ${config.servers.map(s => s.name).join(', ')}`);
  }
}

checkForUpdate(packageName, currentVersion, timeoutMs?): Promise<UpdateInfo | null>

检查npm注册表以获取更新版本。退货 null 在超时或错误时-无需调用即可安全调用 try/catch.

import { checkForUpdate } from '@kunobi/mcp-installer';

const update = await checkForUpdate('@kunobi/mcp', '0.0.3');
if (update?.updateAvailable) {
  console.log(`Update available: ${update.current} → ${update.latest}`);
}

可用于MCP服务器启动时的非阻塞版本检查。默认超时为3秒。

repin(entry: McpServerEntry, options?): RepinResult[]

非交互式重新固定 已安装 服务器条目新建 command/args,在当前注册的每个客户端配置中(通过以下方式发现 list()).与配对 checkForUpdate 实现显式 upgrade 命令:将spawn固定到一个精确的版本,然后根据需要重新固定到最新版本。

仅包含已包含的配置 entry.name 被触摸-- repin 永远不要在新的地方注册服务器。每位客户 entryDefaults 重新应用。 options.configs 允许您注入配置(例如在测试中),而不是从磁盘读取。

import { checkForUpdate, repin } from '@kunobi/mcp-installer';

const update = await checkForUpdate('@my-org/mcp', current);
if (update?.updateAvailable) {
  const results = repin({
    name: 'my-server',
    command: 'npx',
    args: ['-y', `@my-org/mcp@${update.latest}`],
  });
  // results: [{ client, scope, path, action: 'updated' | 'error', error? }, ...]
  // Restart the client to load the new version.
}

options: { cwd?: string; configs?: ClientConfig[] }.

CLIENTS

客户端注册表导出用于高级用例:

import { CLIENTS } from '@kunobi/mcp-installer';

for (const client of CLIENTS) {
  console.log(client.name, client.detectInstalled());
}