Skip to content

Commit ee44530

Browse files
Merge pull request #15 from CrackingShells/dev
fix: access to entrypoints
2 parents 6a76c37 + b70503b commit ee44530

File tree

5 files changed

+115
-19
lines changed

5 files changed

+115
-19
lines changed

hatch_validator/core/pkg_accessor_base.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,43 @@ def get_entry_point(self, metadata: Dict[str, Any]) -> Any:
101101
return self.next_accessor.get_entry_point(metadata)
102102
raise NotImplementedError("Entry point accessor not implemented for this schema version")
103103

104+
def get_mcp_entry_point(self, metadata: Dict[str, Any]) -> Any:
105+
"""Get MCP entry point from metadata.
106+
107+
Default behavior: delegate to next accessor in chain if available.
108+
109+
Args:
110+
metadata (Dict[str, Any]): Package metadata
111+
112+
Returns:
113+
Any: MCP entry point value
114+
115+
Raises:
116+
NotImplementedError: If there is no next accessor and this method is not overridden
117+
"""
118+
if self.next_accessor:
119+
return self.next_accessor.get_mcp_entry_point(metadata)
120+
raise NotImplementedError("MCP entry point accessor not implemented for this schema version"
121+
)
122+
123+
def get_hatch_mcp_entry_point(self, metadata: Dict[str, Any]) -> Any:
124+
"""Get Hatch MCP entry point from metadata.
125+
126+
Default behavior: delegate to next accessor in chain if available.
127+
128+
Args:
129+
metadata (Dict[str, Any]): Package metadata
130+
131+
Returns:
132+
Any: Hatch MCP entry point value
133+
134+
Raises:
135+
NotImplementedError: If there is no next accessor and this method is not overridden
136+
"""
137+
if self.next_accessor:
138+
return self.next_accessor.get_hatch_mcp_entry_point(metadata)
139+
raise NotImplementedError("Hatch MCP entry point accessor not implemented for this schema version")
140+
104141
def get_tools(self, metadata: Dict[str, Any]) -> Any:
105142
"""Get tools from metadata.
106143

hatch_validator/package/package_service.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,32 @@ def get_entry_point(self) -> Any:
122122
raise ValueError("Package metadata is not loaded.")
123123
return self._accessor.get_entry_point(self._metadata)
124124

125+
def get_mcp_entry_point(self) -> Any:
126+
"""Get the MCP entry point from the package metadata.
127+
128+
Returns:
129+
Any: MCP entry point value.
130+
131+
Raises:
132+
ValueError: If metadata is not loaded.
133+
"""
134+
if not self.is_loaded():
135+
raise ValueError("Package metadata is not loaded.")
136+
return self._accessor.get_mcp_entry_point(self._metadata)
137+
138+
def get_hatch_mcp_entry_point(self) -> Any:
139+
"""Get the Hatch MCP entry point from the package metadata.
140+
141+
Returns:
142+
Any: Hatch MCP entry point value.
143+
144+
Raises:
145+
ValueError: If metadata is not loaded.
146+
"""
147+
if not self.is_loaded():
148+
raise ValueError("Package metadata is not loaded.")
149+
return self._accessor.get_hatch_mcp_entry_point(self._metadata)
150+
125151
def get_tools(self) -> Any:
126152
"""Get the tools from the package metadata.
127153

hatch_validator/package/v1_1_0/accessor.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,30 @@ def is_local_dependency(self, dep, root_dir: Optional[Path] = None):
4646
def get_entry_point(self, metadata):
4747
return metadata.get('entry_point')
4848

49+
def get_mcp_entry_point(self, metadata):
50+
"""Until v1.2.1, MCP entry point is the same as the main entry point.
51+
Hence, this is equivalent to calling get_entry_point().
52+
53+
Args:
54+
metadata (dict): Package metadata
55+
56+
Returns:
57+
Any: MCP entry point value
58+
"""
59+
return self.get_entry_point(metadata)
60+
61+
def get_hatch_mcp_entry_point(self, metadata):
62+
"""For v1.2.1, Hatch MCP entry point is the same as the main entry point.
63+
Hence, this is equivalent to calling get_entry_point().
64+
65+
Args:
66+
metadata (dict): Package metadata
67+
68+
Returns:
69+
Any: Hatch MCP entry point value
70+
"""
71+
return self.get_entry_point(metadata)
72+
4973
def get_tools(self, metadata):
5074
return metadata.get('tools', [])
5175

hatch_validator/package/v1_2_1/accessor.py

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,34 @@ def can_handle(self, schema_version: str) -> bool:
3030
return schema_version == "1.2.1"
3131

3232
def get_entry_point(self, metadata):
33-
"""Get entry point from metadata for v1.2.1.
34-
35-
Returns the dual entry point object containing both FastMCP server
36-
and HatchMCP wrapper file paths.
37-
33+
"""From v1.2.1, returns the same as get_mcp_entry_point().
34+
3835
Args:
3936
metadata (dict): Package metadata
40-
37+
38+
Returns:
39+
Any: Dual entry point value
40+
"""
41+
return metadata.get('entry_point').get('mcp_server')
42+
43+
def get_mcp_entry_point(self, metadata):
44+
"""Get MCP entry point from metadata.
45+
46+
Args:
47+
metadata (dict): Package metadata
48+
49+
Returns:
50+
Any: MCP entry point value
51+
"""
52+
return self.get_entry_point(metadata)
53+
54+
def get_hatch_mcp_entry_point(self, metadata):
55+
"""Get Hatch MCP entry point from metadata.
56+
57+
Args:
58+
metadata (dict): Package metadata
59+
4160
Returns:
42-
dict: Dual entry point object with keys:
43-
- 'mcp_server': FastMCP server file path
44-
- 'hatch_mcp_server': HatchMCP wrapper file path
45-
46-
Example:
47-
{
48-
"mcp_server": "mcp_arithmetic.py",
49-
"hatch_mcp_server": "hatch_mcp_arithmetic.py"
50-
}
61+
Any: Hatch MCP entry point value
5162
"""
52-
entry_point = metadata.get('entry_point')
53-
logger.debug(f"Retrieved dual entry point: {entry_point}")
54-
return entry_point
63+
return metadata.get('entry_point').get('hatch_mcp_server')

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "hatch-validator"
7-
version = "0.7.0"
7+
version = "0.7.1"
88
authors = [
99
{ name = "Hatch Team" },
1010
]

0 commit comments

Comments
 (0)