Skip to content

Commit 1e81a24

Browse files
feat(mcp-host-config): add field support constants
1 parent f9adf0a commit 1e81a24

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

hatch/mcp_host_config/fields.py

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
"""
2+
Field constants for MCP host configuration adapter architecture.
3+
4+
This module defines the source of truth for field support across MCP hosts.
5+
All adapters reference these constants to determine field filtering and mapping.
6+
"""
7+
8+
from typing import FrozenSet
9+
from enum import Enum
10+
11+
12+
# ============================================================================
13+
# Universal Fields (supported by ALL hosts)
14+
# ============================================================================
15+
16+
UNIVERSAL_FIELDS: FrozenSet[str] = frozenset({
17+
"command", # Executable path/name for local servers
18+
"args", # Command arguments for local servers
19+
"env", # Environment variables (all transports)
20+
"url", # Server endpoint URL for remote servers (SSE transport)
21+
"headers", # HTTP headers for remote servers
22+
})
23+
24+
25+
# ============================================================================
26+
# Type Field Support
27+
# ============================================================================
28+
29+
# Hosts that support the 'type' discriminator field (stdio/sse/http)
30+
# Note: Gemini, Kiro, Codex do NOT support this field
31+
TYPE_SUPPORTING_HOSTS: FrozenSet[str] = frozenset({
32+
"claude-desktop",
33+
"claude-code",
34+
"vscode",
35+
"cursor",
36+
})
37+
38+
39+
# ============================================================================
40+
# Host-Specific Field Sets
41+
# ============================================================================
42+
43+
# Fields supported by Claude Desktop/Code (universal + type)
44+
CLAUDE_FIELDS: FrozenSet[str] = UNIVERSAL_FIELDS | frozenset({
45+
"type", # Transport discriminator
46+
})
47+
48+
# Fields supported by VSCode (Claude fields + envFile + inputs)
49+
VSCODE_FIELDS: FrozenSet[str] = CLAUDE_FIELDS | frozenset({
50+
"envFile", # Path to environment file
51+
"inputs", # Input variable definitions (VSCode only)
52+
})
53+
54+
# Fields supported by Cursor (Claude fields + envFile, no inputs)
55+
CURSOR_FIELDS: FrozenSet[str] = CLAUDE_FIELDS | frozenset({
56+
"envFile", # Path to environment file
57+
})
58+
59+
# Fields supported by LMStudio (universal + type)
60+
LMSTUDIO_FIELDS: FrozenSet[str] = CLAUDE_FIELDS
61+
62+
# Fields supported by Gemini (no type field, but has httpUrl and others)
63+
GEMINI_FIELDS: FrozenSet[str] = UNIVERSAL_FIELDS | frozenset({
64+
"httpUrl", # HTTP streaming endpoint URL
65+
"timeout", # Request timeout in milliseconds
66+
"trust", # Bypass tool call confirmations
67+
"cwd", # Working directory for stdio transport
68+
"includeTools", # Tools to include (allowlist)
69+
"excludeTools", # Tools to exclude (blocklist)
70+
# OAuth configuration
71+
"oauth_enabled",
72+
"oauth_clientId",
73+
"oauth_clientSecret",
74+
"oauth_authorizationUrl",
75+
"oauth_tokenUrl",
76+
"oauth_scopes",
77+
"oauth_redirectUri",
78+
"oauth_tokenParamName",
79+
"oauth_audiences",
80+
"authProviderType",
81+
})
82+
83+
# Fields supported by Kiro (no type field)
84+
KIRO_FIELDS: FrozenSet[str] = UNIVERSAL_FIELDS | frozenset({
85+
"disabled", # Whether server is disabled
86+
"autoApprove", # Auto-approved tool names
87+
"disabledTools", # Disabled tool names
88+
})
89+
90+
# Fields supported by Codex (no type field, has field mappings)
91+
CODEX_FIELDS: FrozenSet[str] = UNIVERSAL_FIELDS | frozenset({
92+
"cwd", # Working directory
93+
"env_vars", # Environment variables to whitelist/forward
94+
"startup_timeout_sec", # Server startup timeout
95+
"tool_timeout_sec", # Tool execution timeout
96+
"enabled", # Enable/disable server
97+
"enabled_tools", # Allow-list of tools
98+
"disabled_tools", # Deny-list of tools
99+
"bearer_token_env_var",# Env var containing bearer token
100+
"http_headers", # HTTP headers (Codex naming)
101+
"env_http_headers", # Header names to env var names mapping
102+
})
103+
104+
105+
# ============================================================================
106+
# Field Mappings (universal name → host-specific name)
107+
# ============================================================================
108+
109+
# Codex uses different field names for some universal/shared fields
110+
CODEX_FIELD_MAPPINGS: dict[str, str] = {
111+
"args": "arguments", # Codex uses 'arguments' instead of 'args'
112+
"headers": "http_headers", # Codex uses 'http_headers' instead of 'headers'
113+
"includeTools": "enabled_tools", # Gemini naming → Codex naming
114+
"excludeTools": "disabled_tools", # Gemini naming → Codex naming
115+
}
116+
117+
118+
# ============================================================================
119+
# Metadata Fields (never serialized to host config files)
120+
# ============================================================================
121+
122+
# Fields that are Hatch metadata and should NEVER appear in serialized output
123+
EXCLUDED_ALWAYS: FrozenSet[str] = frozenset({
124+
"name", # Server name is key in the config dict, not a field value
125+
})
126+

0 commit comments

Comments
 (0)