|
9 | 9 | from typing import Any, Dict, FrozenSet |
10 | 10 |
|
11 | 11 | from hatch.mcp_host_config.adapters.base import AdapterValidationError, BaseAdapter |
12 | | -from hatch.mcp_host_config.fields import CODEX_FIELDS |
| 12 | +from hatch.mcp_host_config.fields import CODEX_FIELDS, CODEX_FIELD_MAPPINGS |
13 | 13 | from hatch.mcp_host_config.models import MCPServerConfig |
14 | 14 |
|
15 | 15 |
|
@@ -100,6 +100,30 @@ def validate_filtered(self, filtered: Dict[str, Any]) -> None: |
100 | 100 | host_name=self.host_name, |
101 | 101 | ) |
102 | 102 |
|
| 103 | + def apply_transformations(self, filtered: Dict[str, Any]) -> Dict[str, Any]: |
| 104 | + """Apply Codex-specific field transformations. |
| 105 | +
|
| 106 | + Codex uses different field names than the universal schema: |
| 107 | + - args → arguments |
| 108 | + - headers → http_headers |
| 109 | + - includeTools → enabled_tools (for cross-host sync from Gemini) |
| 110 | + - excludeTools → disabled_tools (for cross-host sync from Gemini) |
| 111 | +
|
| 112 | + Args: |
| 113 | + filtered: Dictionary of validated, filtered fields |
| 114 | +
|
| 115 | + Returns: |
| 116 | + Transformed dictionary with Codex field names |
| 117 | + """ |
| 118 | + result = filtered.copy() |
| 119 | + |
| 120 | + # Apply field mappings |
| 121 | + for universal_name, codex_name in CODEX_FIELD_MAPPINGS.items(): |
| 122 | + if universal_name in result: |
| 123 | + result[codex_name] = result.pop(universal_name) |
| 124 | + |
| 125 | + return result |
| 126 | + |
103 | 127 | def serialize(self, config: MCPServerConfig) -> Dict[str, Any]: |
104 | 128 | """Serialize configuration for Codex format. |
105 | 129 |
|
|
0 commit comments