Fix PyPI regex and switch Bicep modules to /api/bicep-modules endpoint
catalog.py: Fix HTML parsing regex — pypi-server.i80.dk uses relative hrefs like href="pkg-name/" not /simple/pkg-name/. Use simpler <a> text extractor. modules.py: Replace /call-tool POST (wrong) with GET /api/bicep-modules (new REST endpoint added to DevOpsMCP). Simpler, no MCP protocol overhead.
This commit is contained in:
@@ -55,12 +55,11 @@ class BicepModuleCatalog:
|
||||
|
||||
@classmethod
|
||||
async def _fetch_from_devops_mcp(cls) -> list[dict[str, Any]]:
|
||||
"""Call DevOpsMCP list_bicep_modules tool via HTTP."""
|
||||
url = f"{DEVOPS_MCP_URL}/call-tool"
|
||||
payload = {"tool": "list_bicep_modules", "arguments": {}}
|
||||
"""Call DevOpsMCP /api/bicep-modules REST endpoint."""
|
||||
url = f"{DEVOPS_MCP_URL}/api/bicep-modules"
|
||||
|
||||
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=20)) as session:
|
||||
async with session.post(url, json=payload) as resp:
|
||||
async with session.get(url) as resp:
|
||||
if resp.status != 200:
|
||||
raise RuntimeError(f"DevOpsMCP returned {resp.status}")
|
||||
data = await resp.json()
|
||||
|
||||
@@ -64,14 +64,16 @@ class PypiCatalog:
|
||||
resp.raise_for_status()
|
||||
html = await resp.text()
|
||||
|
||||
# Parse simple index HTML — each <a href="/simple/pkg-name/"> pkg-name </a>
|
||||
# Parse simple index HTML — each <a href="pkg-name/">pkg-name</a><br>
|
||||
# The pypi-server.i80.dk simple index uses relative hrefs: href="pkg-name/"
|
||||
import re
|
||||
for match in re.finditer(r'href="[^"]+/([^/]+)/"[^>]*>([^<]+)<', html):
|
||||
pkg_name = match.group(2).strip()
|
||||
for match in re.finditer(r'<a\s+href="[^"]*">([^<]+)</a>', html):
|
||||
pkg_name = match.group(1).strip()
|
||||
if pkg_name:
|
||||
packages.append({
|
||||
"name": pkg_name,
|
||||
"label": pkg_name,
|
||||
"detail": f"i80 package — pypi-server.i80.dk",
|
||||
"detail": "i80 package — pypi-server.i80.dk",
|
||||
"sort_prefix": "0_i80_", # sorts before standard packages
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user