Skip to main content

Serve an existing Streamlit app as an MCP server — agents drive it natively, no browser.

Project description

streamlit-mcp

Serve any Streamlit app as an MCP server. Agents introspect your app's widgets, set values, click buttons, and read the rendered output and session_state — natively, over MCP, with no browser automation.

pip install streamlit-mcp          # or run with no install via: uvx streamlit-mcp ...

# serve an app over MCP (stdio for local clients)
streamlit-mcp serve app.py
# ...or HTTP/SSE on loopback for local networked agents
streamlit-mcp serve app.py --transport http --port 8000

# drive it yourself from the terminal (same engine the agent uses)
streamlit-mcp inspect app.py
streamlit-mcp call app.py --set "Name=agent" --click "Save" --read

Streamlit has no callback graph — it reruns the whole script per interaction — so streamlit-mcp drives the app headlessly through Streamlit's own test runtime (streamlit.testing.v1.AppTest) and returns the semantic element tree, not pixels. Gradio and Dash already shipped native app-as-MCP; this fills the Streamlit gap.

Use it with an MCP client

Claude Desktop / Cursor — add to your MCP config (claude_desktop_config.json or .cursor/mcp.json):

{
  "mcpServers": {
    "streamlit-mcp": {
      "command": "uvx",
      "args": ["streamlit-mcp", "serve", "/absolute/path/to/your/app.py"]
    }
  }
}

Claude Code:

claude mcp add streamlit-mcp -- uvx streamlit-mcp serve /absolute/path/to/your/app.py

uvx runs the published package with no prior install. stdio (the default) is the right transport for local clients.

Tools exposed to agents

Tool What it does
list_widgets / get_layout introspect widgets (kind, label, value, constraints)
set_widget(identifier, value) set a widget and rerun
click(identifier) click a button and rerun
read_output() the rendered element tree, agent-readable
get_state() the app's session_state

Supported widgets (v1): text_input, number_input, text_area, slider, selectbox, multiselect, checkbox, radio, button, date_input. Unsupported elements (file_uploader, custom components, st.chat, fragments) are reported explicitly, never silently dropped.

Human ↔ agent parity

Everything an agent can do over MCP, a human can do via the CLI — both call the same engine. The read-only mode and widget allow-list guardrails apply identically to both surfaces.

Security / trust model

  • app_path is executed as trusted code in the server process (that's how AppTest runs it). Only serve apps you trust.
  • get_state / read_output expose the app's session_state to the caller — do not put secrets there.
  • HTTP/SSE is loopback-only in v1. A bearer-token primitive exists, but it is not yet enforced on the transport, so serve refuses to bind HTTP/SSE to a non-loopback host. Use stdio for local clients, or HTTP/SSE on 127.0.0.1. Enforced networked auth is the top follow-up (see CHANGELOG.md).

License

MIT

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

streamlit_mcp-0.1.1.tar.gz (183.1 kB view details)

Uploaded Source

Built Distribution

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

streamlit_mcp-0.1.1-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_mcp-0.1.1.tar.gz.

File metadata

  • Download URL: streamlit_mcp-0.1.1.tar.gz
  • Upload date:
  • Size: 183.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for streamlit_mcp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 02fc92a8a0479a832bba0bad5288f781571d86f651850f09fe0f43a9fd7f6f82
MD5 885a5b8dd38f0c43a9a49b6491de9440
BLAKE2b-256 97196ca6969d00913c18a961919a7062764ca80b178a59ff3473cad4135bde41

See more details on using hashes here.

File details

Details for the file streamlit_mcp-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: streamlit_mcp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for streamlit_mcp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1022ba51e636d02c2239c005beb66d68f7f1f9db7e75651f8d54e57db8543c49
MD5 5a41ae5d6bbf112033b67069ae87ab2e
BLAKE2b-256 2700520332284f5a6281568bde62c00b1c7bae69f46d04f420cd5d0da184a6f5

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