Skip to main content

Pydantic v2 schemas and FastMCP decorators for chuk-mcp-ui Views

Project description

chuk-view-schemas

Pydantic v2 schemas and FastMCP decorators for chuk-mcp-ui Views.

Build MCP Apps with interactive UI — charts, maps, tables, dashboards — from Python, with zero JavaScript.

Install

# Schemas only
pip install chuk-view-schemas

# With FastMCP decorator support
pip install chuk-view-schemas[fastmcp]

Quick Start

from mcp.server.fastmcp import FastMCP
from chuk_view_schemas.fastmcp import chart_tool
from chuk_view_schemas.chart import ChartContent, ChartDataset

mcp = FastMCP("my-server")

@chart_tool(mcp, "show_popularity")
async def show_popularity(chart_type: str = "bar") -> ChartContent:
    """Show programming language popularity as an interactive chart."""
    return ChartContent(
        chartType=chart_type,
        title="Language Popularity",
        data=[
            ChartDataset(
                label="Usage %",
                values=[
                    {"label": "Python", "value": 31.0},
                    {"label": "JavaScript", "value": 25.2},
                    {"label": "Rust", "value": 18.1},
                ],
            )
        ],
    )

The @chart_tool decorator handles:

  • Registering the ui:// resource URI pointing to the hosted chart view
  • Wrapping the return in a CallToolResult with content + structuredContent
  • Generating a text fallback for the LLM

Available Decorators

from chuk_view_schemas.fastmcp import (
    map_tool,        # Interactive Leaflet map
    chart_tool,      # Bar, line, pie, scatter, etc.
    datatable_tool,  # Sortable, filterable table
    form_tool,       # JSON Schema driven form
    markdown_tool,   # Rich markdown rendering
    video_tool,      # HTML5 video player
    pdf_tool,        # PDF viewer
    dashboard_tool,  # Multi-panel layout
    split_tool,      # Two-panel side-by-side
    tabs_tool,       # Tabbed panels
    detail_tool,     # Single record display
    counter_tool,    # Big number with delta
    code_tool,       # Syntax highlighted code
    progress_tool,   # Progress bars
    confirm_tool,    # Confirmation dialog
    json_tool,       # JSON tree viewer
    status_tool,     # Traffic light status
    view_tool,       # Generic (any view type)
)

Schemas

All schemas are Pydantic v2 models with camelCase aliases for JSON serialization:

from chuk_view_schemas import (
    ChartContent, ChartDataset,
    MapContent, MapLayer,
    DataTableContent, Column,
    FormContent,
    DashboardContent, Panel,
    SplitContent, SplitPanel,
    TabsContent, Tab,
    MarkdownContent,
    VideoContent,
    PdfContent,
)

View Inference

Automatically suggest the best view for your data:

from chuk_view_schemas import infer_view

suggestion = infer_view([{"lat": 51.5, "lon": -0.1, "name": "London"}])
# ViewSuggestion(view="map", confidence=0.80, reason="Objects contain lat/lon fields")

Hosted Views

All views are pre-built and hosted at versioned URLs on Fly.io:

https://chuk-mcp-ui-views.fly.dev/chart/v1
https://chuk-mcp-ui-views.fly.dev/map/v1
https://chuk-mcp-ui-views.fly.dev/datatable/v1
...

The decorators point at these URLs automatically. Your Python server never serves HTML.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chuk_view_schemas-0.1.0.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chuk_view_schemas-0.1.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file chuk_view_schemas-0.1.0.tar.gz.

File metadata

  • Download URL: chuk_view_schemas-0.1.0.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for chuk_view_schemas-0.1.0.tar.gz
Algorithm Hash digest
SHA256 37d7d39c5eb14eda5d383bd00f8f7ec292771f2c452e218a54087d97729d4777
MD5 1f14a88d72a841eeb7e601c6eaed65d0
BLAKE2b-256 204c1ee095c80fc7056e2be5c407b61a77fa19bc04224febad310f3dbfd31c7d

See more details on using hashes here.

File details

Details for the file chuk_view_schemas-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for chuk_view_schemas-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23cf6d10d6cf53eb188ce94187f7cef2a1c33bbefd6f30e6b3a7a7e2c15b77a8
MD5 badbe6e306daec3323df57731c513883
BLAKE2b-256 cc64015803df0f80a03fb16d9bec00ad73899e56454302fd1860fe222c06310c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page