|
19 | 19 | DB_COMPONENT_NAME, |
20 | 20 | DeploymentType, |
21 | 21 | GARBAGE_COLLECTOR_COMPONENT_NAME, |
| 22 | + MCP_SERVER_COMPONENT_NAME, |
22 | 23 | QUERY_JOBS_TABLE_NAME, |
23 | 24 | QUERY_SCHEDULER_COMPONENT_NAME, |
24 | 25 | QUERY_WORKER_COMPONENT_NAME, |
|
47 | 48 | get_clp_home, |
48 | 49 | is_retention_period_configured, |
49 | 50 | validate_db_config, |
| 51 | + validate_mcp_server_config, |
50 | 52 | validate_queue_config, |
51 | 53 | validate_redis_config, |
52 | 54 | validate_results_cache_config, |
@@ -528,6 +530,37 @@ def _set_up_env_for_webui(self, container_clp_config: CLPConfig) -> EnvVarsDict: |
528 | 530 |
|
529 | 531 | return env_vars |
530 | 532 |
|
| 533 | + def _set_up_env_for_mcp_server(self) -> EnvVarsDict: |
| 534 | + """ |
| 535 | + Sets up environment variables and directories for the MCP server component. |
| 536 | +
|
| 537 | + :return: Dictionary of environment variables necessary to launch the component. |
| 538 | + """ |
| 539 | + component_name = MCP_SERVER_COMPONENT_NAME |
| 540 | + if self._clp_config.mcp_server is None: |
| 541 | + logger.info(f"The MCP Server is not configured, skipping {component_name} creation...") |
| 542 | + return EnvVarsDict() |
| 543 | + logger.info(f"Setting up environment for {component_name}...") |
| 544 | + |
| 545 | + logs_dir = self._clp_config.logs_directory / component_name |
| 546 | + validate_mcp_server_config(self._clp_config, logs_dir) |
| 547 | + logs_dir.mkdir(parents=True, exist_ok=True) |
| 548 | + |
| 549 | + env_vars = EnvVarsDict() |
| 550 | + |
| 551 | + # Connection config |
| 552 | + env_vars |= { |
| 553 | + "CLP_MCP_HOST": _get_ip_from_hostname(self._clp_config.mcp_server.host), |
| 554 | + "CLP_MCP_PORT": str(self._clp_config.mcp_server.port), |
| 555 | + } |
| 556 | + |
| 557 | + # Logging config |
| 558 | + env_vars |= { |
| 559 | + "CLP_MCP_LOGGING_LEVEL": self._clp_config.mcp_server.logging_level, |
| 560 | + } |
| 561 | + |
| 562 | + return env_vars |
| 563 | + |
531 | 564 | def _set_up_env_for_garbage_collector(self) -> EnvVarsDict: |
532 | 565 | """ |
533 | 566 | Sets up environment variables for the garbage collector component. |
@@ -627,6 +660,8 @@ def start(self) -> None: |
627 | 660 | cmd = ["docker", "compose", "--project-name", self._project_name] |
628 | 661 | if deployment_type == DeploymentType.BASE: |
629 | 662 | cmd += ["--file", "docker-compose.base.yaml"] |
| 663 | + if self._clp_config.mcp_server is not None: |
| 664 | + cmd += ["--profile", "mcp"] |
630 | 665 | cmd += ["up", "--detach", "--wait"] |
631 | 666 | subprocess.run( |
632 | 667 | cmd, |
@@ -750,6 +785,7 @@ def _set_up_env(self) -> None: |
750 | 785 | env_vars |= self._set_up_env_for_query_worker(num_workers) |
751 | 786 | env_vars |= self._set_up_env_for_reducer(num_workers) |
752 | 787 | env_vars |= self._set_up_env_for_webui(container_clp_config) |
| 788 | + env_vars |= self._set_up_env_for_mcp_server() |
753 | 789 | env_vars |= self._set_up_env_for_garbage_collector() |
754 | 790 |
|
755 | 791 | # Write the environment variables to the `.env` file. |
|
0 commit comments