Skip to content

fix: resolve doc_get paths missing project-specific prefix#160

Merged
MarcSkovMadsen merged 1 commit into
MarcSkovMadsen:mainfrom
AR21SM:fix/holoviz-get-document
Mar 7, 2026
Merged

fix: resolve doc_get paths missing project-specific prefix#160
MarcSkovMadsen merged 1 commit into
MarcSkovMadsen:mainfrom
AR21SM:fix/holoviz-get-document

Conversation

@AR21SM

@AR21SM AR21SM commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

closes #132

Verification

Ran: pixi run pytest tests/docs_mcp/test_issue.py


import pytest
from fastmcp import Client

from holoviz_mcp.holoviz_mcp.server import mcp


@pytest.mark.integration
@pytest.mark.asyncio
async def test_doc_get_without_prefix():
    """Issue #132: doc_get should resolve paths that omit the project-specific prefix."""
    client = Client(mcp)
    async with client:
        # This path omits the 'doc/' prefix that is stored in the index
        result = await client.call_tool(
            "doc_get",
            {"path": "how_to/callbacks/examples/streaming_tabulator.md", "project": "panel"},
        )
        assert result.data
        assert result.data.title
        assert result.data.content
        assert len(result.data.content) > 100


@pytest.mark.integration
@pytest.mark.asyncio
async def test_doc_get_with_prefix_still_works():
    """doc_get should continue to work with the full prefixed path."""
    client = Client(mcp)
    async with client:
        result = await client.call_tool(
            "doc_get",
            {"path": "doc/how_to/callbacks/examples/streaming_tabulator.md", "project": "panel"},
        )
        assert result.data
        assert result.data.title
        assert result.data.content


@pytest.mark.integration
@pytest.mark.asyncio
async def test_search_then_doc_get_roundtrip():
    """Verify that source_path from search results can be used directly in doc_get."""
    client = Client(mcp)
    async with client:
        # Search for streaming tabulator
        search_result = await client.call_tool(
            "search",
            {"query": "streaming tabulator callbacks", "project": "panel", "content": False, "max_results": 3},
        )
        assert search_result.data, "Search returned no results for 'streaming tabulator'"

        # Try to fetch each result using doc_get
        for doc in search_result.data:
            result = await client.call_tool(
                "doc_get",
                {"path": doc.source_path, "project": doc.project},
            )
            assert result.data, f"doc_get failed for source_path='{doc.source_path}', project='{doc.project}'"
            assert result.data.content, f"doc_get returned empty content for '{doc.source_path}'"


@pytest.mark.integration
@pytest.mark.asyncio
async def test_doc_list_then_doc_get_roundtrip_panel():
    """Verify that source_path from doc_list can always be used in doc_get for panel."""
    client = Client(mcp)
    async with client:
        # List all panel docs
        list_result = await client.call_tool("doc_list", {"project": "panel"})
        assert list_result.data, "doc_list returned no results for 'panel'"

        # Try first 5 documents
        for doc_summary in list_result.data[:5]:
            result = await client.call_tool(
                "doc_get",
                {"path": doc_summary.source_path, "project": "panel"},
            )
            assert result.data, f"doc_get failed for source_path='{doc_summary.source_path}'"

output

configfile: pyproject.toml
plugins: anyio-4.11.0, asyncio-1.3.0, cov-7.0.0
asyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=function, asyncio_default_test_loop_scope=function       
collected 4 items                                               

tests\docs_mcp\test_issue.py ....                         [100%]

====================== 4 passed in 2.46s ======================= 

@AR21SM AR21SM requested a review from MarcSkovMadsen as a code owner March 4, 2026 15:06

@MarcSkovMadsen MarcSkovMadsen left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see pre-commit failing. otherwise looks fine. Much appreciated.

@AR21SM AR21SM force-pushed the fix/holoviz-get-document branch from 407ac64 to d43b8b1 Compare March 7, 2026 05:00
@MarcSkovMadsen MarcSkovMadsen merged commit bf75f37 into MarcSkovMadsen:main Mar 7, 2026
15 checks passed
@MarcSkovMadsen

Copy link
Copy Markdown
Owner

Thanks for the contribution. Much appreciated.

@AR21SM

AR21SM commented Mar 7, 2026

Copy link
Copy Markdown
Contributor Author

hi @MarcSkovMadsen if possible can we make a script kind off for this ?? #35

@AR21SM AR21SM deleted the fix/holoviz-get-document branch March 7, 2026 05:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix holoviz_get_document

2 participants