Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/holoviz_mcp/holoviz_mcp/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,32 @@ def _get_example_paths(self, project: str, limit: int = 5) -> list[str]:
except BaseException:
return []

def _resolve_path_by_suffix(self, path: str, project: str) -> str | None:
"""Find a stored source_path ending with *path* when the exact lookup misses.

Returns the full path only when exactly one candidate matches; None otherwise.
"""
try:
results = self.collection.get(
where={"project": project},
include=["metadatas"],
)
if not results["metadatas"]:
return None

all_paths = {_normalize_source_path(str(m.get("source_path", ""))) for m in results["metadatas"] if m.get("source_path")}

suffix = "/" + path.lstrip("/")
matches = [p for p in all_paths if p.endswith(suffix) or p == path]

if len(matches) == 1:
return matches[0]
return None
except (KeyboardInterrupt, SystemExit):
raise
except BaseException:
return None

def _reconstruct_document_content(self, source_path: str, project: str) -> str:
"""Reconstruct full document content from its chunks in ChromaDB.

Expand Down Expand Up @@ -2418,6 +2444,13 @@ async def get_document(self, path: str, project: str, ctx: Context | None = None

# Reconstruct full content from chunks
merged_content = self._reconstruct_document_content(normalized_path, project)

if not merged_content:
resolved_path = self._resolve_path_by_suffix(normalized_path, project)
if resolved_path:
normalized_path = resolved_path
merged_content = self._reconstruct_document_content(normalized_path, project)

if not merged_content:
# Provide example paths from this project to help discoverability
example_paths = self._get_example_paths(project, limit=5)
Expand Down
6 changes: 2 additions & 4 deletions src/holoviz_mcp/holoviz_mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,7 @@ def _load_skill_utf8(self):
raise FileNotFoundError(f"Skill directory not found: {self._skill_path}")

if not main_file.exists():
raise FileNotFoundError(
f"Main skill file not found: {main_file}. "
f"Expected {self._main_file_name} in {self._skill_path}"
)
raise FileNotFoundError(f"Main skill file not found: {main_file}. " f"Expected {self._main_file_name} in {self._skill_path}")

content = main_file.read_text(encoding="utf-8")
frontmatter, body = _skill_provider_module.parse_frontmatter(content)
Expand Down Expand Up @@ -793,6 +790,7 @@ def _add_skills_provider():
provider = SkillsDirectoryProvider(roots=roots, supporting_files="resources")
mcp.add_provider(provider)


_add_agent_resources()
_add_skills_provider()

Expand Down
Loading