Skip to content

Commit 5af34d1

Browse files
feat(mcp-augment): implement AugmentAdapter
New adapter for Augment Code (auggie CLI + extensions) following the LMStudio pattern. Validates exactly-one transport (command XOR url) and type-field consistency (type=stdio requires command, etc.). No field mappings or structural transforms needed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8b22594 commit 5af34d1

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
"""Augment Code adapter for MCP host configuration.
2+
3+
Augment Code (auggie CLI + extensions) uses the same field set as Claude:
4+
command/args/env for stdio, url/headers for sse/http, with optional type discriminator.
5+
Config file: ~/.augment/settings.json, root key: mcpServers.
6+
"""
7+
8+
from typing import Any, Dict, FrozenSet
9+
10+
from hatch.mcp_host_config.adapters.base import AdapterValidationError, BaseAdapter
11+
from hatch.mcp_host_config.fields import AUGMENT_FIELDS
12+
from hatch.mcp_host_config.models import MCPServerConfig
13+
14+
15+
class AugmentAdapter(BaseAdapter):
16+
"""Adapter for Augment Code MCP host.
17+
18+
Augment Code uses the same configuration format as Claude:
19+
- Supports 'type' field for transport discrimination
20+
- Requires exactly one transport (command XOR url)
21+
"""
22+
23+
@property
24+
def host_name(self) -> str:
25+
"""Return the host identifier."""
26+
return "augment"
27+
28+
def get_supported_fields(self) -> FrozenSet[str]:
29+
"""Return fields supported by Augment Code."""
30+
return AUGMENT_FIELDS
31+
32+
def validate(self, config: MCPServerConfig) -> None:
33+
"""Validate configuration for Augment Code.
34+
35+
DEPRECATED: This method is deprecated and will be removed in v0.9.0.
36+
Use validate_filtered() instead.
37+
"""
38+
has_command = config.command is not None
39+
has_url = config.url is not None
40+
41+
if not has_command and not has_url:
42+
raise AdapterValidationError(
43+
"Either 'command' (local) or 'url' (remote) must be specified",
44+
host_name=self.host_name,
45+
)
46+
47+
if has_command and has_url:
48+
raise AdapterValidationError(
49+
"Cannot specify both 'command' and 'url' - choose one transport",
50+
host_name=self.host_name,
51+
)
52+
53+
if config.type is not None:
54+
if config.type == "stdio" and not has_command:
55+
raise AdapterValidationError(
56+
"type='stdio' requires 'command' field",
57+
field="type",
58+
host_name=self.host_name,
59+
)
60+
if config.type in ("sse", "http") and not has_url:
61+
raise AdapterValidationError(
62+
f"type='{config.type}' requires 'url' field",
63+
field="type",
64+
host_name=self.host_name,
65+
)
66+
67+
def validate_filtered(self, filtered: Dict[str, Any]) -> None:
68+
"""Validate filtered configuration for Augment Code.
69+
70+
Validates only fields that survived filtering (supported by Augment).
71+
Augment Code requires exactly one transport (command XOR url).
72+
73+
Args:
74+
filtered: Dictionary of filtered fields
75+
76+
Raises:
77+
AdapterValidationError: If validation fails
78+
"""
79+
has_command = "command" in filtered
80+
has_url = "url" in filtered
81+
82+
if not has_command and not has_url:
83+
raise AdapterValidationError(
84+
"Either 'command' (local) or 'url' (remote) must be specified",
85+
host_name=self.host_name,
86+
)
87+
88+
if has_command and has_url:
89+
raise AdapterValidationError(
90+
"Cannot specify both 'command' and 'url' - choose one transport",
91+
host_name=self.host_name,
92+
)
93+
94+
if "type" in filtered:
95+
config_type = filtered["type"]
96+
if config_type == "stdio" and not has_command:
97+
raise AdapterValidationError(
98+
"type='stdio' requires 'command' field",
99+
field="type",
100+
host_name=self.host_name,
101+
)
102+
if config_type in ("sse", "http") and not has_url:
103+
raise AdapterValidationError(
104+
f"type='{config_type}' requires 'url' field",
105+
field="type",
106+
host_name=self.host_name,
107+
)
108+
109+
def serialize(self, config: MCPServerConfig) -> Dict[str, Any]:
110+
"""Serialize configuration for Augment Code format.
111+
112+
Follows the validate-after-filter pattern:
113+
1. Filter to supported fields
114+
2. Validate filtered fields
115+
3. Return filtered (no transformations needed)
116+
"""
117+
filtered = self.filter_fields(config)
118+
self.validate_filtered(filtered)
119+
return filtered

0 commit comments

Comments
 (0)