-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathpn_packages.py
More file actions
86 lines (66 loc) · 2.52 KB
/
Copy pathpn_packages.py
File metadata and controls
86 lines (66 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""An app to demo the usage and responses of the pn_packages tool."""
import panel as pn
import panel_material_ui as pmui
from holoviz_mcp.client import call_tool
ABOUT = """
# Panel List Packages Tool
The `pn_packages` tool lists all installed packages that provide Panel `Viewable` components.
## Purpose
Discover what Panel-related packages are available in your environment.
This helps you understand which packages you can use in the 'package' parameter of other tools.
## Returns
A list of package names that provide Panel components, sorted alphabetically.
**Examples:** `["panel"]` or `["panel", "panel_material_ui"]`
"""
@pn.cache
async def panel_list_packages() -> list[str]:
"""Demo the usage and responses of the pn_packages tool."""
response = await call_tool(
tool_name="pn_packages",
parameters={},
)
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(
label="About",
icon="info",
description="Click to learn about the Panel List Packages 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: pn_packages Tool Demo",
header=[pmui.Row(pn.HSpacer(), about_button, github_button, sizing_mode="stretch_width")],
main=[main],
)
if pn.state.served:
create_app().servable()