Kimi Code MCP 标志

Kimi Code MCP

社区
howardpen9

MCP server for Claude Code × Kimi K2.5 (256K context) — delegate bulk codebase analysis to Kimi, save 90% on token costs. Session caching, parallel agents, TypeScript.

发布者howardpen9
代码仓库kimi-code-mcp
语言TypeScript
复刻数
12
星标数
61
可用工具
0
传输类型stdio
分类
许可协议MIT
链接
  • 将工具接入 AI 工作流

    Kimi Code MCP 提供 MCP 功能,可供兼容的 AI 客户端和智能体使用。

  • 0 个可用工具

    浏览下方可调用的操作;如果服务器提供了名称和描述,也会一并显示。

  • 可直接复制的配置

    使用安装配置片段,在您首选的 MCP 客户端中配置此服务器。

  • 开源社区热度

    关联的代码仓库有 61 个 Star 和 12 个 Fork。

kimi-code-mcp

English | 中文說明



Delegate codebase analysis from Claude to Kimi Code (kimi-for-coding, 256K) — cut Claude-side token cost ~90%.

TaskClaude onlyClaude + kimi-code-mcpClaude-side savings
Analyze 200-file monorepo~250K tok~25K tok~90%
Summarize 50-page RFC PDF~60K tok~6K tok~90% (sketch)
Cross-reference 100 commits~80K tok~8K tok~90% (sketch)

*Illustrative estimates — savings are on Claude tokens only and depend on the task; Kimi's subscription cost is separate. See Token Economics.

Quick start

bash
# 1. Install Kimi CLI and log in
curl -L code.kimi.com/install.sh | bash
kimi login

# 2. Install via npm
npm install -g kimi-mcp-server

Add to .mcp.json (project-level or ~/.claude/mcp.json for global):

json
{
  "mcpServers": {
    "kimi-code": {
      "command": "npx",
      "args": ["-y", "kimi-mcp-server"]
    }
  }
}

Run /mcp in Claude Code to verify — you should see kimi-code with 8 tools.

[!TIP] You don't need the CLI for the common case. kimi_query and kimi_verify call the Kimi Code API directly — no Python CLI install or kimi login required. Just provide an API key via $KIMICODE_API_KEY or ~/.kimi/config.toml (see Kimi Code API Setup). Only the codebase-reading tools (kimi_analyze, kimi_resume) need the CLI. See Two backends: API vs CLI for the full split.

How it works

  1. Claude calls the kimi_analyze tool when a task needs bulk codebase reading.
  2. MCP routes the request to Kimi Code (kimi-for-coding, 256K context) — Kimi reads the entire codebase in one pass.
  3. The result is piped back as a structured response — Claude acts on it with precise, targeted edits.
┌──────────────┐  stdio/MCP   ┌──────────────┐  subprocess   ┌──────────────┐
│  Claude Code │ ◄──────────► │ kimi-code-mcp│ ────────────► │ Kimi CLI     │
│  (conductor) │              │ (MCP server) │               │ (256K ctx)   │
└──────────────┘              └──────────────┘               └──────────────┘

Two backends: API vs CLI

The server reaches Kimi two different ways, and each tool uses the one that fits its job. Knowing which is which tells you what you need to set up.

BackendHow it talks to KimiWhat it needsSees your codebase?
Direct APIHTTPS to api.kimi.com/coding/v1An API key only ($KIMICODE_API_KEY or ~/.kimi/config.toml)❌ No — you paste in the context
Local CLISpawns the kimi binary as a subprocessCLI installed and kimi login done✅ Yes — reads files from disk
ToolBackendWhy
kimi_queryAPI (CLI only if no key configured)Contextless Q&A — no codebase needed, so the API is simpler and has no login dependency
kimi_verifyAPIYou pass the code/diff/claim inline; Kimi judges it as an independent third party
kimi_analyzeCLIMust read your whole codebase (256K ctx) from disk
kimi_resumeCLIContinues a stateful CLI session that holds prior codebase context
kimi_list_sessions, kimi_cache_*, kimi_statuslocalRead local session/cache metadata

[!IMPORTANT] Most users only need the API key. If you just want a second opinion / verification (kimi_query, kimi_verify), set the API key and you're done — skip the CLI entirely. Install + kimi login only when you want Kimi to read your codebase via kimi_analyze / kimi_resume.

Run kimi_status any time to see which backends are live — it reports the API-configured state and the CLI install/auth state separately.

Guidelines for agents

If you are an AI agent (Claude Code, a subagent, etc.) deciding when to call these tools:

  • Cross-check your own work before committing → kimi_verify. Paste the actual diff/code/claim plus the surrounding context (goal, constraints, signatures). Kimi sees only the context string — no repo, no session history. Vague context → useless review.
  • Quick model-agnostic programming question → kimi_query. No codebase needed. Returns a different model's opinion.
  • Need to understand a large/unfamiliar codebase → kimi_analyze with work_dir. Prefer this over reading 50 files yourself; it's ~10× cheaper in Claude tokens. Requires the CLI to be installed and logged in.
  • Drill deeper after an analyze → kimi_resume with the returned session_id (retains up to 256K tokens of prior context).
  • Don't know why a Kimi call failed → kimi_status first. "Not authenticated" on the CLI does not affect kimi_query/kimi_verify (those use the API).
  • Keep outputs lean. Default detail_level: summary for orientation; raise to normal/detailed only when you need code snippets. Bigger output = more Claude tokens, defeating the purpose.
  • Skip Kimi for small/single-file work — Claude reading directly is faster under ~10 files.

MCP server that connects Kimi Code (model kimi-for-coding, 256K context, auto-upgraded) with Claude Code — letting Claude orchestrate while Kimi handles the heavy reading.

[!TIP] Stop paying Claude to read files. Kimi Code delivers frontier-class code intelligence at a fraction of the cost (see chart above). Delegate bulk codebase scanning to Kimi (256K context, near-zero cost) and let Claude focus on what it does best — reasoning, decisions, and precise code edits. One kimi_analyze call can replace 50+ file reads.

What is Kimi Code?

Kimi Code is an AI code agent by Moonshot AI. The model ID kimi-for-coding (1T MoE, 256K context) automatically receives backend upgrades — no version pinning required. It works across Terminal, IDE, and CLI — writing, debugging, refactoring, and analyzing code autonomously.

Key specs:

  • 256K token context — reads entire codebases in one pass
  • Parallel agent spawning — handles concurrent tasks
  • Shell, file, and web access — full developer toolchain
  • Install: curl -L code.kimi.com/install.sh | bash

[!WARNING] Kimi Code membership required. All tools ultimately hit Kimi Code, which needs an active Kimi Code plan. The API tools (kimi_query, kimi_verify) authenticate with an API key; the codebase tools (kimi_analyze, kimi_resume) additionally need the CLI installed + kimi login. See kimi.com/code for pricing tiers and quotas.

Install from source

If you prefer to build locally instead of using the npm package:

bash
git clone https://github.com/howardpen9/kimi-code-mcp.git
cd kimi-code-mcp && npm install && npm run build
json
{
  "mcpServers": {
    "kimi-code": {
      "command": "node",
      "args": ["/absolute/path/to/kimi-code-mcp/dist/index.js"]
    }
  }
}

Kimi Code API Setup

[!NOTE] Kimi Code API and Moonshot API are separate providers — their API keys are not interchangeable.

There are two ways to configure the Kimi Code API for the CLI:

Option 1: OAuth Login (Recommended)

In the Kimi Code CLI shell, run:

bash
kimi

Then use the /login (or /setup) command:

/login
  1. Select Kimi Code as the platform
  2. Your browser opens for OAuth authorization
  3. Config is saved automatically to ~/.kimi/config.toml

[!NOTE] zsh: command not found: kimi after install? The installer puts the binary at ~/.local/bin/kimi, which may not be on your PATH. Add it (then restart your shell or open a new tab):

bash
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc

The MCP server calls the binary by absolute path, so this only affects running kimi yourself in a terminal (e.g. for kimi login).

Option 2: Manual API Key Configuration

Get your API Key

  1. Visit code.kimi.com
  2. Sign in → Settings → API Keys
  3. Create a new key (starts with sk-, shown only once)

Edit config file

bash
nano ~/.kimi/config.toml

Add:

toml
[providers.kimi-code]
type = "kimi"
base_url = "https://api.kimi.com/coding/v1"
api_key = "sk-your-api-key"

[models.kimi-for-coding]
provider = "kimi-code"
model = "kimi-for-coding"
max_context_size = 262144
capabilities = ["thinking"]

[defaults]
model = "kimi-for-coding"

Using environment variables (recommended for security)

bash
# Add to ~/.zshrc (macOS) or ~/.bashrc (Linux)
export KIMICODE_API_KEY="sk-your-api-key"

Then reference it in config.toml:

toml
[providers.kimi-code]
type = "kimi"
base_url = "https://api.kimi.com/coding/v1"
api_key = "${KIMICODE_API_KEY}"

Multi-provider config example

You can configure both Kimi Code and Moonshot side by side:

toml
[providers.kimi-code]
type = "kimi"
base_url = "https://api.kimi.com/coding/v1"
api_key = "${KIMICODE_API_KEY}"

[providers.moonshot-cn]
type = "kimi"
base_url = "https://api.moonshot.cn/v1"
api_key = "${MOONSHOT_API_KEY}"

[models.kimi-for-coding]
provider = "kimi-code"
model = "kimi-for-coding"
max_context_size = 262144
capabilities = ["thinking"]

[models.kimi-k2]
provider = "moonshot-cn"
model = "kimi-k2-0905-preview"
max_context_size = 256000
capabilities = ["thinking"]

[defaults]
model = "kimi-for-coding"

Switch models at any time with /model or /model kimi-k2 in the CLI.

Kimi Code vs Moonshot

FeatureKimi CodeMoonshot
FocusOptimized for codingGeneral-purpose chat
Endpointapi.kimi.com/coding/v1api.moonshot.cn/v1
API KeySeparate — apply at code.kimi.comSeparate
SearchWeb / FetchURLBuilt-inNot available
Context262K256K

What You Can Do

Just tell Claude what you need. It will delegate to Kimi automatically:

PromptWhat happens
"Analyze this codebase's architecture"Kimi reads all files (256K ctx), Claude acts on the report
"Scan for security vulnerabilities, then review Kimi's findings"Kimi audits, Claude cross-examines — AI pair review
"Map all dependencies of the auth module, then plan the refactoring"Kimi builds the dependency graph, Claude plans the changes
"Review the recent changes for regressions and edge cases"Kimi reviews full context (not just the diff), Claude synthesizes
"Resume the last Kimi session and ask about the API design"Kimi retains 256K tokens of context across sessions

Why This Exists

Claude Code is powerful but expensive. Every file it reads costs tokens. Meanwhile, many tasks — pre-reviewing large codebases, scanning for patterns, generating audit reports — are high-certainty work that doesn't need Claude's full reasoning power.

[!IMPORTANT] The cost equation: Claude reads 50 files to understand your architecture = expensive. Kimi reads 50 files via kimi_analyze = near-zero cost. Claude then acts on Kimi's structured report = minimal tokens. Total savings: 60-80% fewer Claude tokens on analysis-heavy tasks.

How It Saves Tokens

                          ┌─────────────────────────────┐
                          │   You (the developer)       │
                          └──────────┬──────────────────┘
                                     │ prompt
                                     ▼
                          ┌─────────────────────────────┐
                          │   Claude Code (conductor)   │
                          │   - orchestrates workflow    │
                          │   - makes decisions          │
                          │   - writes & edits code      │
                          └──────┬──────────────┬───────┘
                      precise    │              │  delegate
                      edits      │              │  bulk reading
                      (tokens)   │              │  (FREE)
                                 ▼              ▼
                          ┌──────────┐   ┌──────────────┐
                          │ your     │   │  Kimi Code   │
                          │ codebase │   │  - 256K ctx  │
                          └──────────┘   │  - reads all │
                                         │  - reports   │
                                         └──────────────┘
  1. Claude receives your task → decides it needs codebase understanding
  2. Claude calls kimi_analyze via MCP → Kimi reads the entire codebase (256K context, near-zero cost)
  3. Kimi returns a structured analysis
  4. Claude acts on the analysis with precise, targeted edits

Result: Claude only spends tokens on decision-making and code writing, not on reading files.

Mutual Code Review with Kimi Code

kimi-for-coding is a 1T MoE model designed for deep code comprehension. This enables AI pair review:

  1. Kimi pre-reviews — 256K context means it sees the entire codebase at once: security issues, anti-patterns, dead code, architectural problems
  2. Claude cross-examines — reviews Kimi's findings, challenges questionable items, adds its own insights
  3. Two perspectives — different models catch different things. What one misses, the other finds

Use Kimi as a Code Reviewer

Beyond ad-hoc analysis, you can use Kimi as a dedicated reviewer in your workflow:

PR Review Workflow

┌──────────────┐   diff    ┌──────────────┐  structured  ┌──────────────┐
│   Your PR    │ ────────► │  Kimi Code   │  findings    │  Claude Code │
│  (changes)   │           │  (reviewer)  │ ────────────►│  (decision)  │
└──────────────┘           └──────────────┘              └──────────────┘

Continuous Audit Pattern

WhenWhatWhy
Before mergingKimi scans diff + affected modulesCatch regressions early
WeeklyFull codebase sweepAccumulated tech debt
Pre-releaseSecurity-focused auditShip with confidence

Each review session can be resumed (kimi_resume) — Kimi retains up to 256K tokens of context from previous sessions, building understanding over time.

What Kimi Reviews Well

Review TypeWhy Kimi Excels
Security audit256K context sees full attack surface, not just isolated files
Dead code detectionCan trace imports/exports across entire codebase
API consistencyCompares patterns across all endpoints simultaneously
Dependency analysisMaps full dependency graph in one pass
Architecture reviewSees the forest and the trees at the same time

Tools

ToolDescriptionTimeout
kimi_analyzeCLI — deep codebase analysis (architecture, audit, refactoring)10 min
kimi_queryAPI — quick programming questions, no codebase context (CLI only if no key configured)2 min
kimi_verifyAPI — independent third-party verification of code/diffs/claims; no CLI required, context-driven5 min
kimi_list_sessionsList existing Kimi sessions with metadatainstant
kimi_resumeCLI — resume a previous session (up to 256K token context)10 min
kimi_statusReport API-configured state + CLI install/version/auth statusinstant
kimi_cache_statusView session cache statistics and performance metricsinstant
kimi_cache_invalidateManually invalidate cached sessions (by dir or all)instant

Output Control Parameters

kimi_analyze and kimi_resume support these parameters to control output size:

ParameterValuesDefaultEffect
detail_levelsummary / normal / detailednormalControls prompt-side verbosity instructions
max_output_tokensnumber15000Hard ceiling — output truncated at clean boundary if exceeded
include_thinkingbooleanfalseInclude Kimi's internal reasoning chain (10-30K extra tokens)

kimi_query also supports max_output_tokens and include_thinking.

Token Economics

[!NOTE] The savings come from compression ratio, not from free reading. Kimi's subscription cost still applies, but the key benefit is reducing expensive Claude Code token consumption.

                    Without kimi-code-mcp        With kimi-code-mcp (normal)
                    ─────────────────────        ───────────────────────────
Raw source:         50 files × ~4K = 200K        Kimi reads (subscription cost)
Claude reads:       200K tokens                  5-15K token report
Claude token cost:  $$$                          $

Compression ratio by detail_level:

LevelCompressionOutput SizeEquivalent SourceBest For
summary40-100x~2-5K tokens~8-20K chars / ~200-500 lines of codeQuick orientation, file inventory
normal15-40x~5-15K tokens~20-60K chars / ~500-1500 lines of codeArchitecture review, dependency mapping
detailed5-15x~15-40K tokens~60-160K chars / ~1500-4000 lines of codeSecurity audit with code snippets

When savings happen:

  • Large codebases (50+ files) — architecture understanding, cross-file scanning
  • Security audits, dead code detection, API consistency checks
  • Pre-review before targeted edits (scan first → edit specific files)

When to skip and let Claude read directly:

  • Small codebases (<10 files) — direct reading is faster
  • Single-file modifications — Claude's built-in file reading is sufficient
  • When you need every line of code — detailed output approaches raw reading cost

Implementation details

Under the hood:

  1. Claude Code calls an MCP tool (e.g., kimi_analyze)
  2. This server spawns the kimi CLI with the prompt and codebase path
  3. Kimi autonomously reads files, analyzes the code (up to 256K tokens)
  4. The result is parsed from Kimi's JSON output and returned to Claude Code
  5. Claude acts on the structured results — edits, plans, or further analysis

CLI Invocation Reference

The MCP server calls the Kimi CLI in non-interactive (print) mode:

bash
kimi --work-dir <path> --print -p "<prompt>"
FlagPurpose
--printNon-interactive mode — outputs result and exits (required for subprocess use)
-p / --promptPass prompt directly (bypasses interactive shell)
--work-dir / -wSet codebase root directory
-S <id>Resume a specific session by ID
--no-thinkingDisable thinking mode

[!NOTE] There is no kimi analyze subcommand. The MCP tool is named kimi_analyze, but the underlying CLI uses the flags above. Use this syntax to call Kimi directly for debugging or scripting.

Advanced Setup

For development (auto-recompile on changes):

json
{
  "mcpServers": {
    "kimi-code": {
      "command": "npx",
      "args": ["tsx", "/absolute/path/to/kimi-code-mcp/src/index.ts"]
    }
  }
}

npm

Published as kimi-mcp-server on npm.

bash
npx kimi-mcp-server          # run directly
npm install -g kimi-mcp-server # install globally

Project Structure

src/
├── index.ts           # MCP server setup, tool definitions, API-vs-CLI routing
├── kimi-api.ts        # Direct Kimi Code API client (kimi_query / kimi_verify)
├── kimi-runner.ts     # Spawns kimi CLI, parses output, handles timeouts
├── cache-manager.ts   # Session cache (warmup, reuse, invalidation)
└── session-reader.ts  # Reads Kimi session metadata from ~/.kimi/

Contributing

See CONTRIBUTING.md for guidelines.

Changelog

See CHANGELOG.md for version history.

License

MIT

安装

TypingMind
{
  "mcpServers": {
    "kimi-code-mcp": {
      "command": "npx",
      "args": [
        "tsx",
        "/path/to/kimi-code-mcp/src/index.ts"
      ]
    }
  }
}

将 Kimi Code MCP MCP 与多个 AI 模型配合使用

TypingMind 在工作区级别连接 MCP 工具,因此连接 Kimi Code MCP 后,您就可以在 TypingMind 中搭配不同的 AI 模型使用,无需为每个模型单独设置。 此 MCP 通过您设备上的 TypingMind MCP 连接器在本地运行。

本地连接器设置指南

如果 MCP 服务器需要访问您电脑上的本地文件、应用或私有资源,请选择此方式。

1

打开 MCP 设置

在 TypingMind 中,依次前往“设置”、“高级设置”和“模型上下文协议”,然后选择“设置连接器”。

  1. 在您的浏览器中打开 TypingMind。
  2. 点击“设置”图标。
  3. 进入“高级设置”。
  4. 打开“模型上下文协议”部分。
  5. 点击“设置连接器”,然后选择“此设备”。
TypingMind MCP 连接器设置界面,已选择“此设备”
2

运行连接器命令

选择“此设备”,从 TypingMind 复制命令并在终端中运行。使用 MCP 时,请保持该进程运行。

  1. 复制 TypingMind 显示的设置命令。
  2. 在 macOS 上打开“终端”,或在 Windows 上打开 Windows Terminal。
  3. 粘贴并运行命令。
  4. 如果终端询问您是否继续,请确认安装软件包。
  5. 使用 MCP 工具时,请保持终端窗口及其中的进程运行。
3

将 Kimi Code MCP 添加为服务器

当连接器状态为“就绪”时,点击“编辑服务器”,然后粘贴 MCP 服务器配置。

  1. 等待连接器状态显示为“就绪”。
  2. 点击“编辑服务器”。
  3. 粘贴 Kimi Code MCP MCP 服务器配置。
  4. 保存服务器列表。
  5. 如需确认连接器是否仍处于就绪状态,请刷新。
TypingMind MCP 设置界面,显示正在运行的服务器和“编辑服务器”按钮
{
  "mcpServers": {
    "kimi-code-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "kimi-code-mcp"
      ]
    }
  }
}
4

在不同模型中使用同一连接

保存服务器列表,打开“插件”,启用 Kimi Code MCP MCP 工具,然后在 TypingMind 中选择任意受支持的 AI 模型,即可在聊天中使用这些工具,或将其分配给智能体。

  1. 在 TypingMind 中打开“插件”页面。
  2. 启用 Kimi Code MCP MCP 工具。
  3. 开始聊天并选择您想使用的 AI 模型。
  4. 在聊天中使用 MCP 工具,或将其分配给 AI 智能体。
  5. 根据需要随时切换到其他 AI 模型,无需重新连接 MCP。
在 TypingMind 聊天中使用已启用的 MCP 工具和选定的 AI 模型
您能使用 Kimi Code MCP 帮我完成这项任务吗?
Kimi Code MCP
当然。我已阅读。
以下是我使用 Kimi Code MCP 得到的结果。

常见问题

Kimi Code MCP MCP 服务器有什么用途?

Kimi Code MCP 是一个 MCP 服务器,可让兼容的 AI 客户端连接外部工具并获取上下文。在 TypingMind 中,只需添加一次此 MCP 服务器,即可在您的 AI 工作区中使用其工具。

可以在 TypingMind 中让多个 AI 模型使用 Kimi Code MCP MCP 吗?

可以。TypingMind 在工作区层面连接 MCP 工具,因此您可以让 Claude、ChatGPT、Gemini 等不同 AI 模型,或您在 TypingMind 中配置的其他模型使用 Kimi Code MCP,而无需为每个模型单独配置 MCP 服务器。

为什么在 TypingMind 中使用 Kimi Code MCP MCP?

TypingMind 将多个 AI 模型、提示词、插件、AI 智能体、API 密钥和 MCP 工具整合到同一个工作区中,是优秀的大语言模型聊天前端之一。连接 Kimi Code MCP 后,您可以在偏好的不同模型中使用其 MCP 工具,同时在 TypingMind 中井然有序地管理聊天工作流程。

如何将 Kimi Code MCP MCP 连接到 TypingMind?

Kimi Code MCP 通过 TypingMind 本地 MCP 连接器运行。当 MCP 服务器需要访问您计算机上的本地文件、桌面应用、命令行工具或私有资源时,这种方式最合适。

Kimi Code MCP MCP 在 TypingMind 中提供哪些工具?

Kimi Code MCP 提供 MCP 功能,您可以在 TypingMind 的插件页面启用这些功能,然后在聊天中使用,或将其分配给 AI 智能体。

使用 Kimi Code MCP MCP 需要向 TypingMind 提供我的 API 密钥吗?

不需要。TypingMind 采用本地优先的设计,让您自行掌控模型提供商、API 密钥、提示词和 MCP 配置。如果 Kimi Code MCP 需要身份验证,请在创建连接时,为该 MCP 服务器添加所需的请求头、OAuth 设置或本地配置。

相关 MCP 服务器

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇