Skip to main content

Widgets SDK for FastMCP targeting OpenAI Apps SDK (outputTemplate + widget helpers).

Project description

fastmcp-apps-sdk

Widgets SDK for FastMCP targeting OpenAI Apps SDK. It provides a simple @widget(...) decorator and helpers to:

  • Register a text/html+skybridge resource with CSP hints
  • Expose a tool with openai/outputTemplate and widget metadata
  • Return structured content + narration with build_widget_tool_response

Install

  • pip: pip install fastmcp-apps-sdk
  • uv: uv add fastmcp-apps-sdk

Usage

from fastmcp import FastMCP
from fastmcp_apps_sdk import widget, build_widget_tool_response, register_decorated_widgets

@widget(
    identifier="hello-widget",
    title="Hello Widget",
    template_uri="ui://widget/hello.html",
    invoking="Saying hello",
    invoked="Said hello",
    html='<div id="hello-root"></div><script type="module" src="https://example.com/hello.js"></script>',
)
def hello(name: str = "world"):
    return build_widget_tool_response(
        response_text=f"Hello {name}!",
        structured_content={"name": name},
    )

mcp = FastMCP(name="demo", instructions="Demo widgets")
register_decorated_widgets(mcp)
mcp.run(transport="http", host="0.0.0.0", port=8080)

Examples

  • See examples/ for Solar System and Pizza widgets.
  • Run locally (with uv):
    • uv pip install -e . (or pip install -e .)
    • uv run examples/server.py
    • ngrok http 8080 and use the HTTPS URL as the MCP endpoint.

Publish to PyPI

  • Ensure your version in pyproject.toml is updated.
  • Build with uv: uv build (creates wheel and sdist under dist/)
  • Publish with uv: uv publish --token <pypi-token>
  • Alternative with Twine:
    • python -m pip install build twine
    • python -m build
    • twine upload dist/*

Notes

  • No auth, env vars, or external tools are included in this package.
  • The example server intentionally runs without authentication for easy testing.

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

fastmcp_apps_sdk-1.0.0.tar.gz (59.7 kB view details)

Uploaded Source

Built Distribution

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

fastmcp_apps_sdk-1.0.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file fastmcp_apps_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: fastmcp_apps_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 59.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for fastmcp_apps_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8f6ae701e7bb528094a0c3daffe0b3edad68eef9e4db9bd5bfd611bf9916eea0
MD5 d0b3d4a0480fb17bcac00a80c879c695
BLAKE2b-256 f50804247317835a256a99d5cbef2743f9e3fcc0b599535439e82d9f06672201

See more details on using hashes here.

File details

Details for the file fastmcp_apps_sdk-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastmcp_apps_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8b6acf407bb8c16cfe50484fbdba7bac25cd93f77606787279555f0cce79077d
MD5 28185af8a0440556280dc724a5cd9c08
BLAKE2b-256 301066610aeb95511eb3eac3b8c6b0a38099361dd95de5fd970be2e4fbb56097

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