Skip to main content

Expose AnyWidget interfaces as interactive MCP Apps

Project description

anywidget-mcp

PyPI License: MIT

anywidget-mcp runs AnyWidgets inside AI conversations. You can interact with a widget directly, and the model can respond to your input.

Start with a widget from an existing package, or bring the same widget you use in Jupyter or marimo.

Read the documentation.

Try an AnyWidget

Requires Python 3.11 or newer. Start Wigglystuff's ColorPicker with one command:

uvx --with wigglystuff anywidget-mcp serve wigglystuff:ColorPicker --port 8010

Connect a host that supports MCP Apps to http://127.0.0.1:8010/mcp, then ask:

Use color_picker so I can choose a color.

The picker opens in the conversation. Choose a color, then ask the model which color you chose. The model reads the picker's current color when it answers.

Getting started walks through this flow in Inspector Chat.

But why?

💬 Stay in context: A standalone web app sends you to a separate page. An MCP App stays in the conversation, exchanges data through MCP, and runs in a host-controlled sandbox. With your consent, it can ask the host to use tools you already connected.

🧩 Skip the scaffolding: Building an MCP App directly means wiring together tools, UI resources, browser code, the host connection, and shared state. anywidget-mcp handles that integration. You define an AnyWidget that keeps browser behavior and Python state in one component.

🧪 Develop in notebooks: The same widget runs in Jupyter and marimo. Create it from Python, inspect its state, and use marimo's reactive execution to test scenarios before serving it through MCP.

🧰 Combine widgets: One server can expose multiple widgets as separate tools, or one call can open several together. Combine widgets from the AnyWidget gallery into an interactive environment for the task, then add your own.

✨ Invent at runtime: When you cannot enumerate every useful interface in advance, serve create_anywidget. Supply Python source directly or ask an agent to invent a fresh AnyWidget during the conversation. Use that natural-language loop to develop widgets and test concepts. Run the factory in a sandbox because supplied source executes with the MCP server's permissions.

Install in a project

Install anywidget-mcp in the Python environment that owns your widget code:

uv pip install anywidget-mcp

Bring your own AnyWidget

Point the CLI at your AnyWidget's import path:

anywidget-mcp serve my_widgets:MyWidget

Or start the server from Python:

from anywidget_mcp import serve
from my_widgets import MyWidget

serve(MyWidget)

MyWidget remains the same anywidget.AnyWidget subclass you use in notebooks. Browser changes stay synchronized with its Python traits.

When the widget needs data from the conversation, use a Python function that accepts the input and returns an AnyWidget. This function is a widget factory. Pass input to widgets covers that workflow, multiple widgets, and existing MCP servers.

Documentation

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

anywidget_mcp-0.0.2.tar.gz (149.3 kB view details)

Uploaded Source

Built Distribution

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

anywidget_mcp-0.0.2-py3-none-any.whl (160.1 kB view details)

Uploaded Python 3

File details

Details for the file anywidget_mcp-0.0.2.tar.gz.

File metadata

  • Download URL: anywidget_mcp-0.0.2.tar.gz
  • Upload date:
  • Size: 149.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for anywidget_mcp-0.0.2.tar.gz
Algorithm Hash digest
SHA256 bf2f690cbffe40ee29b54ecb58c986e9dda272cd050de99f4b044609814fa3ec
MD5 0eb9dfe9664e88936850ab24ae1cd6fd
BLAKE2b-256 400e4eb42092d132d9eadfaf84e11c8de16cbd8be6b42a47cb9b434c7659562e

See more details on using hashes here.

Provenance

The following attestation bundles were made for anywidget_mcp-0.0.2.tar.gz:

Publisher: publish.yml on peter-gy/anywidget-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file anywidget_mcp-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: anywidget_mcp-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 160.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for anywidget_mcp-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d22f9365abdfe24ef9f6d9f9fcdccf60a670a827a000411d98c6c6f2b291c4dc
MD5 bed5261d34ff3ae2d70b6cda09f923ef
BLAKE2b-256 5ed950a392e3c0a6340bde0749d53a1d5f149d1c920a6ecbeadd777fc7802751

See more details on using hashes here.

Provenance

The following attestation bundles were made for anywidget_mcp-0.0.2-py3-none-any.whl:

Publisher: publish.yml on peter-gy/anywidget-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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