From c550a4963ea2a8481086aaecf94b3de4e39c8d4c Mon Sep 17 00:00:00 2001 From: Henrik Jess Nielsen Date: Sun, 10 May 2026 12:48:13 +0200 Subject: [PATCH] Fix PyPI regex and switch Bicep modules to /api/bicep-modules endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit catalog.py: Fix HTML parsing regex — pypi-server.i80.dk uses relative hrefs like href="pkg-name/" not /simple/pkg-name/. Use simpler 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. --- ilsp/bicep_lsp/modules.py | 7 +++---- ilsp/python_lsp/catalog.py | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ilsp/bicep_lsp/modules.py b/ilsp/bicep_lsp/modules.py index d29b137..0b015ee 100644 --- a/ilsp/bicep_lsp/modules.py +++ b/ilsp/bicep_lsp/modules.py @@ -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() diff --git a/ilsp/python_lsp/catalog.py b/ilsp/python_lsp/catalog.py index b36b448..7213f7a 100644 --- a/ilsp/python_lsp/catalog.py +++ b/ilsp/python_lsp/catalog.py @@ -64,16 +64,18 @@ class PypiCatalog: resp.raise_for_status() html = await resp.text() - # Parse simple index HTML — each pkg-name + # Parse simple index HTML — each pkg-name
+ # 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() - packages.append({ - "name": pkg_name, - "label": pkg_name, - "detail": f"i80 package — pypi-server.i80.dk", - "sort_prefix": "0_i80_", # sorts before standard packages - }) + for match in re.finditer(r'([^<]+)', html): + pkg_name = match.group(1).strip() + if pkg_name: + packages.append({ + "name": pkg_name, + "label": pkg_name, + "detail": "i80 package — pypi-server.i80.dk", + "sort_prefix": "0_i80_", # sorts before standard packages + }) return packages