Skip to content

Commit 59cc931

Browse files
feat(mcp-adapters): implement field transformations in CodexAdapter
1 parent 7ac8de1 commit 59cc931

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

hatch/mcp_host_config/adapters/codex.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import Any, Dict, FrozenSet
1010

1111
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
1313
from hatch.mcp_host_config.models import MCPServerConfig
1414

1515

@@ -100,6 +100,30 @@ def validate_filtered(self, filtered: Dict[str, Any]) -> None:
100100
host_name=self.host_name,
101101
)
102102

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+
103127
def serialize(self, config: MCPServerConfig) -> Dict[str, Any]:
104128
"""Serialize configuration for Codex format.
105129

0 commit comments

Comments
 (0)