hz_validate_config
Validate Horizon configuration files and essential environment variables to ensure proper setup before running the content aggregation pipeline.
Instructions
校验 Horizon 配置和关键环境变量。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| horizon_path | No | ||
| config_path | No | ||
| sources | No | ||
| check_env | No |
Implementation Reference
- horizon_mcp/service.py:149-197 (handler)The core implementation of the hz_validate_config tool logic, located in the HorizonPipelineService class.
async def validate_config( self, horizon_path: str | None = None, config_path: str | None = None, sources: list[str] | None = None, check_env: bool = True, ) -> dict[str, Any]: ctx, selected_sources, unknown_sources = self._build_context( horizon_path=horizon_path, config_path=config_path, sources=sources, ) warnings: list[str] = [] missing_env: list[str] = [] if check_env: required = [ctx.config.ai.api_key_env] for key in required: if not os.getenv(key): missing_env.append(key) if ctx.config.sources.github and not os.getenv("GITHUB_TOKEN"): warnings.append("未设置 GITHUB_TOKEN,GitHub 抓取可能触发严格限流。") if getattr(ctx.config, "email", None) and ctx.config.email and ctx.config.email.enabled: pwd_key = ctx.config.email.password_env if not os.getenv(pwd_key): missing_env.append(pwd_key) return { "horizon_path": str(ctx.horizon_path), "config_path": str(ctx.config_path), "ai": { "provider": ctx.config.ai.provider.value, "model": ctx.config.ai.model, "languages": list(ctx.config.ai.languages), "api_key_env": ctx.config.ai.api_key_env, }, "filtering": { "ai_score_threshold": ctx.config.filtering.ai_score_threshold, "time_window_hours": ctx.config.filtering.time_window_hours, }, "enabled_sources": get_enabled_sources(ctx.config), "selected_sources": selected_sources, "unknown_sources": unknown_sources, "missing_env": missing_env, "warnings": warnings, } - horizon_mcp/server.py:131-148 (registration)Tool registration for hz_validate_config using the @mcp.tool decorator, which maps the handler in server.py to the service method.
@mcp.tool() async def hz_validate_config( horizon_path: str | None = None, config_path: str | None = None, sources: list[str] | None = None, check_env: bool = True, ) -> dict[str, Any]: """校验 Horizon 配置和关键环境变量。""" return await _run_tool( "hz_validate_config", lambda: service.validate_config( horizon_path=horizon_path, config_path=config_path, sources=sources, check_env=check_env, ), )