Skip to main content

light-chat-ui

Lightweight chat UI for AG-UI agents, served from a FastAPI app. It bundles the @vemonet/light-chat JS package, no frontend build needed.

pip install light-chat-ui
from fastapi import FastAPI
from light_chat_ui import chat_router

app = FastAPI()

# Chat page at `/`, sending messages to the AG-UI endpoint at `chat`, relative to the page
app.include_router(
    chat_router(
        path="/",
        url="chat",
        title="My agent",
        favicon="favicon.ico",
        # Other keyword arguments are passed as options of the JS `Chat`
        welcome="## How can I help you today?",
        examples=["What can you do?"],
        settings={"models": ["gpt-5", "kimi-k3"]},
    )
)

The script is served next to the page: /light-chat.js for a page at /, /ui/light-chat.js for a page at /ui/.

Tool UIs of MCP servers

With a Pydantic AI agent, the interactive UIs of MCP tools (MCP Apps and MCP-UI) are shown in the chat. Install the mcp-apps extra:

pip install "light-chat-ui[mcp-apps]"

Use a UIToolset for each MCP server with UIs, and answer the MCP requests of widgets in the AG-UI endpoint with proxied_response:

from fastapi import FastAPI, Request, Response
from light_chat_ui import chat_router
from light_chat_ui.mcp_apps import PROXIED_REQUEST, UIToolset, proxied_response
from pydantic_ai import Agent
from pydantic_ai.ui.ag_ui import AGUIAdapter

# MCP servers by URL, or an `MCPServer` / `FastMCP` instance called in-process. The `id` routes widget requests
toolsets = [UIToolset("https://mcp.excalidraw.com/mcp", id="excalidraw")]
agent = Agent("openai:gpt-5", toolsets=toolsets)
app = FastAPI()


@app.post("/chat")
async def chat(request: Request) -> Response:
    body = await request.json()
    # MCP request from a widget, e.g. reading its UI resource or calling a tool of its server
    if PROXIED_REQUEST in (body.get("forwardedProps") or {}):
        return await proxied_response(body, toolsets)
    return await AGUIAdapter.dispatch_request(request, agent=agent)


app.include_router(chat_router(path="/", url="chat"))

The agent only forwards, the chat decides what to render:

  • UIToolset is a Pydantic AI MCPToolset sending each tool result to the chat in an AG-UI mcp-apps activity, with the raw MCP result and the tool _meta. The model gets the text content of the result, tools only visible to apps (_meta.ui.visibility) are hidden from it, and connection errors name the server
  • proxied_response runs resources/read, tools/call and tools/list requests of widgets on their server, and returns the MCP result in the RUN_FINISHED event. The chat only lets widgets call tools visible to apps

Widgets can also add context for the model with ui/update-model-context, sent as AG-UI context with the next request, e.g. add it to the instructions. See the demo server for a complete agent.

Logging

setup_logging formats the logs of all libraries like uvicorn (INFO: message), replacing handlers set by others, e.g. the MCP SDK. It hides the log line of each HTTP request, outgoing ones of httpx and the uvicorn access log, unless request_logs=True:

from light_chat_ui import setup_logging

setup_logging()  # or setup_logging("DEBUG", request_logs=True)

Development

From the repo root, build the JS package, copy it in src/light_chat_ui/static, and build the wheel in packages/python/dist:

vp run build:py

Metadata

Release files for light-chat-ui 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for light-chat-ui 0.0.3
File Size Uploaded Provenance Actions
light_chat_ui-0.0.3.tar.gz 91.9 kB Without provenance Details for light_chat_ui-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for light-chat-ui 0.0.3
File Interpreter ABI Platform Actions
light_chat_ui-0.0.3-py3-none-any.whl Python 3 none any Details for light_chat_ui-0.0.3-py3-none-any.whl

Total release size: 185.4 kB

Release files / light_chat_ui-0.0.3.tar.gz

Download URL light_chat_ui-0.0.3.tar.gz
Size 91.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d6e545a62c1e143aabc5f266707e890f72fd598b75d569b682f280a0e9b89e2c
BLAKE2b-256 checksum
How to use checksums
e125239859d512162b3ed68db9bcae42ddb92ff656a374c464880afab9d9bff3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / light_chat_ui-0.0.3-py3-none-any.whl

Download URL light_chat_ui-0.0.3-py3-none-any.whl
Size 93.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30b36d65ce6a192bf7c7c5961259e5f2476b1debed8bc0d09067b95a57a3826b
BLAKE2b-256 checksum
How to use checksums
a17bbcfd8c77518d06fcc4b1cc549b54cb5df32f2639b4077d04a7c13939cc06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for light-chat-ui 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page