fix: ensure MCP and skills config changes are immediately reflected

- Use ExtensionsConfig.from_file() instead of cached config to always
  read latest configuration from disk in LangGraph Server
- Add mtime-based cache invalidation for MCP tools to detect config
  file changes made through Gateway API
- Call reload_extensions_config() in Gateway API after updates to
  refresh the global cache
- Remove unnecessary MCP initialization from Gateway startup since
  MCP tools are only used by LangGraph Server

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hetaoBackend
2026-01-25 22:37:53 +08:00
parent 044e38aec6
commit 038f5d44f4
7 changed files with 89 additions and 29 deletions

View File

@@ -73,10 +73,14 @@ def load_skills(skills_path: Path | None = None, use_config: bool = True, enable
skills.append(skill)
# Load skills state configuration and update enabled status
# NOTE: We use ExtensionsConfig.from_file() instead of get_extensions_config()
# to always read the latest configuration from disk. This ensures that changes
# made through the Gateway API (which runs in a separate process) are immediately
# reflected in the LangGraph Server when loading skills.
try:
from src.config.extensions_config import get_extensions_config
from src.config.extensions_config import ExtensionsConfig
extensions_config = get_extensions_config()
extensions_config = ExtensionsConfig.from_file()
for skill in skills:
skill.enabled = extensions_config.is_skill_enabled(skill.name, skill.category)
except Exception as e: