-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat (mcp-conf): Project-level MCP configuration with merge/override strategy #2349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,14 +10,12 @@ | |||||||
| from __future__ import annotations | ||||||||
|
|
||||||||
| import asyncio | ||||||||
| import json | ||||||||
| import sys | ||||||||
| from typing import Any | ||||||||
| from uuid import UUID | ||||||||
|
|
||||||||
| from kimi_cli import logger | ||||||||
| from kimi_cli.app import KimiCLI, enable_logging | ||||||||
| from kimi_cli.cli.mcp import get_global_mcp_config_file | ||||||||
| from kimi_cli.cli.mcp import collect_file_mcp_configs | ||||||||
| from kimi_cli.exception import MCPConfigError | ||||||||
| from kimi_cli.web.store.sessions import load_session_by_id | ||||||||
|
|
||||||||
|
|
@@ -32,18 +30,20 @@ async def run_worker(session_id: UUID) -> None: | |||||||
| # Get the kimi-cli session object | ||||||||
| session = joint_session.kimi_cli_session | ||||||||
|
|
||||||||
| # Load default MCP config file if it exists | ||||||||
| default_mcp_file = get_global_mcp_config_file() | ||||||||
| mcp_configs: list[dict[str, Any]] = [] | ||||||||
| if default_mcp_file.exists(): | ||||||||
| raw = default_mcp_file.read_text(encoding="utf-8") | ||||||||
| try: | ||||||||
| mcp_configs = [json.loads(raw)] | ||||||||
| except json.JSONDecodeError: | ||||||||
| logger.warning( | ||||||||
| "Invalid JSON in MCP config file: {path}", | ||||||||
| path=default_mcp_file, | ||||||||
| ) | ||||||||
| # Load MCP config files according to merge_strategy. | ||||||||
| work_dir = session.dir | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Web worker uses session storage directory instead of project working directory for MCP config discovery In
Suggested change
Was this helpful? React with 👍 or 👎 to provide feedback. |
||||||||
|
|
||||||||
| from kimi_cli.config import load_config | ||||||||
|
|
||||||||
| strategy = load_config().mcp.merge_strategy | ||||||||
| try: | ||||||||
| mcp_configs = collect_file_mcp_configs(strategy, work_dir=work_dir) | ||||||||
| except Exception as exc: | ||||||||
| logger.warning( | ||||||||
| "Failed to load MCP configs for web worker: {error}", | ||||||||
| error=exc, | ||||||||
| ) | ||||||||
| mcp_configs = [] | ||||||||
|
|
||||||||
| # Detect whether this is a resumed session (has prior state on disk) | ||||||||
| # vs a brand-new session that should honor config.default_plan_mode. | ||||||||
|
|
@@ -56,8 +56,7 @@ async def run_worker(session_id: UUID) -> None: | |||||||
| ) | ||||||||
| except MCPConfigError as exc: | ||||||||
| logger.warning( | ||||||||
| "Invalid MCP config in {path}: {error}. Starting without MCP.", | ||||||||
| path=default_mcp_file, | ||||||||
| "Invalid MCP config: {error}. Starting without MCP.", | ||||||||
| error=exc, | ||||||||
| ) | ||||||||
| kimi_cli = await KimiCLI.create(session, mcp_configs=None, resumed=resumed, ui_mode="wire") | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The web worker now calls
collect_file_mcp_configs()withsession.dir, which points to the session storage directory under~/.kimi/sessions/..., not the user’s project workspace. As a result, project-level MCP config discovery (<work_dir>/.kimi/mcp.json) never finds the project file in web sessions, so web mode silently falls back to global/default MCP config and ignores project-specific servers. This breaks the new project-level MCP behavior for the web workflow.Useful? React with 👍 / 👎.