fastmcp-apps-sdk
Widgets SDK for FastMCP targeting OpenAI Apps SDK. It provides a simple @widget(...) decorator and helpers to:
- Register a
text/html+skybridgeresource with CSP hints - Expose a tool with
openai/outputTemplateand 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 .(orpip install -e .)uv run examples/server.pyngrok http 8080and use the HTTPS URL as the MCP endpoint.
Publish to PyPI
- Ensure your version in
pyproject.tomlis updated. - Build with uv:
uv build(creates wheel and sdist underdist/) - Publish with uv:
uv publish --token <pypi-token> - Alternative with Twine:
python -m pip install build twinepython -m buildtwine 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.
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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f6ae701e7bb528094a0c3daffe0b3edad68eef9e4db9bd5bfd611bf9916eea0
|
|
| MD5 |
d0b3d4a0480fb17bcac00a80c879c695
|
|
| BLAKE2b-256 |
f50804247317835a256a99d5cbef2743f9e3fcc0b599535439e82d9f06672201
|
File details
Details for the file fastmcp_apps_sdk-1.0.0-py3-none-any.whl.
File metadata
- Download URL: fastmcp_apps_sdk-1.0.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.7.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b6acf407bb8c16cfe50484fbdba7bac25cd93f77606787279555f0cce79077d
|
|
| MD5 |
28185af8a0440556280dc724a5cd9c08
|
|
| BLAKE2b-256 |
301066610aeb95511eb3eac3b8c6b0a38099361dd95de5fd970be2e4fbb56097
|