Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
98 changes: 98 additions & 0 deletions src/holoviz_mcp/apps/hv_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
"""An app to demo the usage and responses of the hv_list tool."""

import panel as pn
import panel_material_ui as pmui

from holoviz_mcp.client import call_tool

ABOUT = """
# HoloViews List Elements Tool

The `hv_list` tool lists all available HoloViews visualization elements.

## Purpose

Discover what visualization elements you can create with HoloViews. Elements are the
building blocks for composing complex visualizations.

## Use Cases

- Explore available visualization options before creating plots
- Understand what element types are supported in your environment
- Find the right element name to use with HoloViews

## Returns

A sorted list of all HoloViews element names available in the current environment.

**Examples:** `['Annotation', 'Area', 'Arrow', 'Bars', 'Curve', 'Scatter', ...]`

## Next Steps

After discovering elements with this tool, use:

- [`hv_get`](./hv_get) - Get detailed documentation for a specific element
"""


@pn.cache
async def hv_list_elements() -> list[str]:
"""Fetch the list of HoloViews elements via the hv_list tool."""
response = await call_tool(
tool_name="hv_list",
parameters={},
)
return response.data


async def create_content():
"""Create the styled content displaying HoloViews elements as chips."""
items = await hv_list_elements()
count = pmui.Typography(
f"Found {len(items)} elements",
variant="subtitle1",
sx={"color": "text.secondary", "mb": 2},
)
chips = pmui.FlexBox(
*[pmui.Chip(item, variant="outlined", color="primary", size="small") for item in items],
sizing_mode="stretch_width",
)
return pmui.Column(count, chips, sizing_mode="stretch_width")


def create_app():
"""Create the Panel Material UI app for demoing the hv_list tool."""
about_button = pmui.IconButton(
label="About",
icon="info",
description="Click to learn about the HoloViews List Elements Tool.",
sizing_mode="fixed",
color="light",
margin=(10, 0),
)
about = pmui.Dialog(ABOUT, close_on_click=True, width=0)
about_button.js_on_click(args={"about": about}, code="about.data.open = true")

github_button = pmui.IconButton(
label="Github",
icon="star",
description="Give HoloViz-MCP a star on GitHub",
sizing_mode="fixed",
color="light",
margin=(10, 0),
href="https://github.com/MarcSkovMadsen/holoviz-mcp",
target="_blank",
)

content = pn.panel(create_content, loading_indicator=True)
main = pmui.Container(about, content)

return pmui.Page(
title="HoloViz-MCP: hv_list Tool Demo",
header=[pmui.Row(pn.HSpacer(), about_button, github_button, sizing_mode="stretch_width")],
main=[main],
)


if pn.state.served:
create_app().servable()
19 changes: 17 additions & 2 deletions src/holoviz_mcp/apps/hvplot_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ async def hvplot_list_plot_types() -> list[str]:
return response.data


async def create_content():
"""Create the styled content displaying hvPlot plot types as chips."""
items = await hvplot_list_plot_types()
count = pmui.Typography(
f"Found {len(items)} plot types",
variant="subtitle1",
sx={"color": "text.secondary", "mb": 2},
)
chips = pmui.FlexBox(
*[pmui.Chip(item, variant="outlined", color="primary", size="small") for item in items],
sizing_mode="stretch_width",
)
return pmui.Column(count, chips, sizing_mode="stretch_width")


def create_app():
"""Create the Panel Material UI app for demoing the hvplot_list tool."""
about_button = pmui.IconButton(
Expand All @@ -57,7 +72,6 @@ def create_app():
about = pmui.Dialog(ABOUT, close_on_click=True, width=0)
about_button.js_on_click(args={"about": about}, code="about.data.open = true")

# GitHub button
github_button = pmui.IconButton(
label="Github",
icon="star",
Expand All @@ -69,7 +83,8 @@ def create_app():
target="_blank",
)

main = pmui.Container(about, pn.pane.JSON(hvplot_list_plot_types, theme="dark", depth=3, sizing_mode="stretch_width"))
content = pn.panel(create_content, loading_indicator=True)
main = pmui.Container(about, content)

return pmui.Page(
title="HoloViz-MCP: hvplot_list Tool Demo",
Expand Down
19 changes: 17 additions & 2 deletions src/holoviz_mcp/apps/pn_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ async def panel_list_packages() -> list[str]:
return response.data


async def create_content():
"""Create the styled content displaying Panel packages as chips."""
items = await panel_list_packages()
count = pmui.Typography(
f"Found {len(items)} package{'s' if len(items) != 1 else ''}",
variant="subtitle1",
sx={"color": "text.secondary", "mb": 2},
)
chips = pmui.FlexBox(
*[pmui.Chip(item, variant="outlined", color="primary", size="small") for item in items],
sizing_mode="stretch_width",
)
return pmui.Column(count, chips, sizing_mode="stretch_width")


def create_app():
"""Create the Panel Material UI app for demoing the pn_packages tool."""
about_button = pmui.IconButton(
Expand All @@ -46,7 +61,6 @@ def create_app():
about = pmui.Dialog(ABOUT, close_on_click=True, width=0)
about_button.js_on_click(args={"about": about}, code="about.data.open = true")

# GitHub button
github_button = pmui.IconButton(
label="Github",
icon="star",
Expand All @@ -58,7 +72,8 @@ def create_app():
target="_blank",
)

main = pmui.Container(about, pn.pane.JSON(panel_list_packages, theme="dark", depth=3, sizing_mode="stretch_width"))
content = pn.panel(create_content, loading_indicator=True)
main = pmui.Container(about, content)

return pmui.Page(
title="HoloViz-MCP: pn_packages Tool Demo",
Expand Down
2 changes: 1 addition & 1 deletion src/holoviz_mcp/apps/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class SearchConfiguration(param.Parameterized):
doc="Filter results to a specific project. Select 'all' for all projects.",
)

max_results = param.Integer(default=2, bounds=(1, 50), doc="Maximum number of search results to return")
max_results = param.Integer(default=5, bounds=(1, 50), doc="Maximum number of search results to return")

content = param.Selector(
default="truncated",
Expand Down
15 changes: 8 additions & 7 deletions src/holoviz_mcp/apps/skill_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import panel_material_ui as pmui
import param

from holoviz_mcp.holoviz_mcp.data import get_skill
from holoviz_mcp.holoviz_mcp.data import list_skills
from holoviz_mcp.core.skills import get_skill
from holoviz_mcp.core.skills import list_skills

pn.extension()

Expand Down Expand Up @@ -71,12 +71,13 @@ def __init__(self, **params):
pn.state.location.sync(self, parameters=["name"])

def _load_skills(self):
"""Load available skills½."""
"""Load available skills."""
try:
skills = list_skills()
self.param.skill.objects = skills
if skills and self.skill is None:
self.skill = skills[0] # Default to first skill
skill_entries = list_skills()
skill_names = [entry["name"] for entry in skill_entries]
self.param.skill.objects = skill_names
if skill_names and self.skill is None:
self.skill = skill_names[0]
except Exception as e:
self.param.skill.objects = []
self.content = f"**Error loading skills:** {e}"
Expand Down
Loading
Loading