Streamlit MCP Server
Provides tools for building Streamlit applications, including components, layouts, charts, chat, navigation, state, authentication, and data connections; generates and validates Streamlit code.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Streamlit MCP Server
A comprehensive Model Context Protocol (MCP) server for building Streamlit applications with AI assistance. This server provides 106 tools (100% COMPLETE!) covering Streamlit components, from basic text elements to complex data visualizations, layouts, status indicators, media, chat interfaces, navigation, state management, authentication, and data connections.
Features
π― Key Capabilities
π End-to-End Orchestration: Complete workflow from drawing to validated implementation
π¨ Drawing Interpreter: Convert sketches and wireframes directly to code with automatic single/multi-page detection
β Built-in Validation: Validate implementations against plans and best practices
AI-Powered Page Planner: Analyzes requirements and generates complete page code with best practices
103 Streamlit Tools (100% COMPLETE! π): Comprehensive coverage of Streamlit components organized by official API structure
Code Generation: Automatic generation of properly formatted Streamlit code
Template Library: Pre-built templates for dashboards, data explorers, chat interfaces, and more
Best Practices: Built-in recommendations for component usage and app architecture
Resource Management: 11 tools for accessing guides, snippets, and templates
π New Workflow Tools
1. Orchestration Tool (orchestrate_app_from_drawing)
Complete end-to-end workflow:
Get Drawing β Interpret components and structure
Understand Components β Extract pages, features, dependencies
Plan Full App β Always start with full app plan (for multi-page)
Plan Each Page β Create individual page plans
Execute β Generate code for each page separately
Validate β Check against plans and requirements
2. Drawing Interpreter (interpret_page_drawing)
Enhanced with multi-page detection:
Auto-detects single-page vs multi-page apps
Routes to appropriate planning workflow
Creates full app plan + individual page plans for multi-page apps
Generates code with best practices
3. Validation Tool (validate_implementation)
Comprehensive code validation:
Component presence checks
Best practices compliance
Plan alignment verification
Scored feedback (0-100)
π Component Coverage
Display & Interaction (66 tools implemented β )
Text Elements (11 tools β ): titles, headers, markdown, code, LaTeX, dividers, badges
Input Widgets (10 tools β ): buttons, sliders, text inputs, selectors, file uploaders
Data Display (6 tools β ): dataframes, data editor, tables, metrics, JSON viewers, column config
Charts (12 tools β ): line, bar, area, scatter, map, Plotly, Altair, Vega-Lite, Bokeh, PyDeck, Graphviz, Pyplot
Layouts (9 tools β ): columns, tabs, expanders, containers, sidebar, popover, dialog, empty, forms
Status Elements (10 tools β ): progress bars, spinners, status containers, toast, success/error/info/warning messages, balloons, snow
Media Elements (5 tools β ): images, audio, video, logo, link buttons
Chat Elements (3 tools β ): chat messages, chat input, streaming output
Application Logic (25 tools implemented β )
Navigation (5 tools β ): st.navigation(), page links, page switching, query params
State Management (5 tools β ): session state init/get/set/clear, state patterns
Execution Flow (5 tools β ): fragments, reruns, stop, form submit, execution patterns
Authentication (5 tools β ): st.login(), st.logout(), st.user, auth patterns, OIDC config
Data Connections (5 tools β ): SQL, Snowflake, custom connections, connection config, patterns
Related MCP server: Chart Canvas MCP Server
Installation
Prerequisites
Python 3.10 or higher
Claude Code or another MCP client
Install from Source
Using UV (Recommended - Fast & Modern):
# Clone the repository
cd mcp_streamlit
# Install UV if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install the package with all dependencies
uv sync --all-extras
# Or use the automated setup script
./setup.shUsing pip (Traditional):
# Clone the repository
cd mcp_streamlit
# Install the package
pip install -e ".[dev]"Why UV?
UV is a modern Python package manager that's:
β‘ 10-100x faster than pip
π More reliable with lockfile-based resolution
πΎ Disk efficient with global caching
π― Better at resolving complex dependencies
Learn more: https://github.com/astral-sh/uv
Configuration
For Claude Code
Using UV (Recommended):
{
"mcpServers": {
"streamlit": {
"command": "uv",
"args": ["run", "python", "-m", "streamlit_mcp.server"],
"env": {}
}
}
}Using Python directly (if not using UV):
{
"mcpServers": {
"streamlit": {
"command": "python",
"args": ["-m", "streamlit_mcp.server"],
"env": {}
}
}
}For Other MCP Clients
The server uses stdio for communication.
With UV:
uv run python -m streamlit_mcp.serverWith Python directly:
python -m streamlit_mcp.serverUsage
π Recommended Workflow: Drawing to Production
NEW: Full Orchestration (Easiest Way!)
Use the orchestration tool for complete end-to-end workflow:
Ask Claude: "Use orchestrate_app_from_drawing with this description:
Multi-page sales dashboard app with 3 pages:
1. Home - Overview dashboard with KPIs and trend charts
2. Data Explorer - Upload and filter sales data
3. Settings - Configuration and user preferences
"The orchestrator will:
β Interpret your drawing/description
β Auto-detect single vs multi-page app
β Create full application plan (for multi-page)
β Create individual page plans
β Generate code for each page
β Validate everything against plans
Alternative: Step-by-Step Workflow
For more control, use tools individually:
Step 1: Interpret Drawing
interpret_page_drawing(
drawing_description="Dashboard with sidebar, 4 metrics, 2 charts, data table"
)Step 2: Review Plans (auto-created in ./plans/)
full_plan.md- Overall architecture (multi-page only)page_*.md- Individual page plans
Step 3: Generate Code for Each Page
plan_streamlit_page(
description="Home dashboard page",
page_type="dashboard"
)Step 4: Validate Implementation
validate_implementation(
code=your_page_code,
page_plan_file="./plans/page_home.md",
page_type="dashboard"
)1. Page Planning (Classic Approach)
Use the AI-powered page planner to get started:
Ask Claude: "Plan a dashboard page with metrics, charts, and data filtering"The planner will:
Analyze your requirements
Recommend optimal components
Suggest layout structure
Generate complete, runnable code
2. Component-by-Component Building
Add individual components as needed:
Ask Claude: "Add a title saying 'Sales Dashboard'"
β Generates: st.title("Sales Dashboard")
Ask Claude: "Add a slider from 0 to 100"
β Generates: st.slider("Label", min_value=0, max_value=100)
Ask Claude: "Add a Plotly chart for the data"
β Generates: st.plotly_chart(data, use_container_width=True)3. Example Workflows
Creating a Data Dashboard
1. "Plan a dashboard page with data upload, metrics, and charts"
2. "Add file uploader for CSV files"
3. "Add 4 metric cards in columns"
4. "Add a line chart and bar chart side by side"
5. "Add a data table at the bottom"Building a Chat Interface
1. "Plan a chat page with message history"
2. "Add chat message display"
3. "Add chat input widget"
4. "Add session state for message history"Creating a Multi-Page App
1. "Plan a multi-page app structure"
2. "Add navigation with pages for Home, Data, Settings"
3. "Add page configuration for wide layout"Available Tools
π Workflow & Planning Tools (NEW!)
Orchestration
orchestrate_app_from_drawing- Complete end-to-end workflow from drawing to validated implementationAuto-detects single vs multi-page apps
Creates full app plan + individual page plans
Generates code for each page
Validates everything
Planning
create_app_plan- Create comprehensive full application plan for multi-page appscreate_page_plan- Create detailed plan for individual pagesinterpret_page_drawing- Convert sketches/wireframes to code with smart routingplan_streamlit_page- AI-powered page designer (original planner)
Validation
validate_implementation- Validate code against plans and best practicesComponent validation
Best practices checks
Plan alignment verification
Scored feedback (0-100)
Text Elements
add_title- Add a title (st.title)add_header- Add a header (st.header)add_subheader- Add a subheader (st.subheader)add_markdown- Add markdown text (st.markdown)add_text- Add plain text (st.text)add_caption- Add caption text (st.caption)add_code- Display code with syntax highlighting (st.code)add_latex- Display LaTeX equations (st.latex)add_divider- Add horizontal divider (st.divider)add_html- Display raw HTML (st.html)add_badge- Add a badge (st.badge)
Input Widgets
add_button- Add a button (st.button)add_checkbox- Add a checkbox (st.checkbox)add_toggle- Add a toggle switch (st.toggle)add_radio- Add radio buttons (st.radio)add_selectbox- Add a dropdown (st.selectbox)add_multiselect- Add multi-select (st.multiselect)add_slider- Add a slider (st.slider)add_select_slider- Add a select slider (st.select_slider)add_text_input- Add text input (st.text_input)add_text_area- Add text area (st.text_area)add_number_input- Add number input (st.number_input)add_date_input- Add date picker (st.date_input)add_time_input- Add time picker (st.time_input)add_file_uploader- Add file uploader (st.file_uploader)add_camera_input- Add camera input (st.camera_input)add_color_picker- Add color picker (st.color_picker)
Page Planning
plan_streamlit_page- AI-powered page designerAnalyzes requirements
Recommends components
Suggests layout
Generates complete code
Provides alternatives
Architecture
Project Structure
streamlit_mcp/
βββ server.py # Main MCP server
βββ tools/
β βββ display/ # Display & interaction tools
β β βββ text.py # Text elements
β β βββ widgets.py # Input widgets
β β βββ data.py # Data display
β β βββ charts.py # Charts & visualizations
β β βββ media.py # Media elements
β β βββ layout.py # Layouts & containers
β β βββ chat.py # Chat elements
β β βββ status.py # Status elements
β βββ logic/ # Application logic tools
β β βββ auth.py # Authentication
β β βββ navigation.py # Navigation & pages
β β βββ execution.py # Execution flow
β β βββ state.py # State management
β β βββ connections.py # Data connections
β β βββ components.py # Custom components
β βββ config/ # Configuration tools
β β βββ page_config.py
β β βββ theme.py
β βββ planner.py # Page planner (KEY TOOL)
β βββ runtime.py # Server management
βββ templates/ # Template resources
βββ resources/ # MCP resources
βββ utils/ # Utilities
βββ codegen.py # Code generation
βββ schemas.py # JSON schemasCode Generation
The server uses a sophisticated code generation system that:
Manages imports automatically
Handles proper indentation
Validates parameters
Generates example data when needed
Follows Streamlit best practices
Tool Organization
Tools are organized following Streamlit's official API structure:
Display & Interaction - Page elements (text, data, charts, widgets, media, layouts, chat, status)
Application Logic - Authentication, navigation, execution, state, connections, components
Configuration - Page config, theming, options
Developer Tools - Testing, CLI
Examples
Example 1: Simple Dashboard
import streamlit as st
import pandas as pd
import numpy as np
st.set_page_config(
page_title="Dashboard",
page_icon="π",
layout="wide"
)
st.title("π Dashboard")
# Metrics
col1, col2, col3, col4 = st.columns(4)
with col1:
st.metric("Total Sales", "$45.2K", "+12%")
with col2:
st.metric("Customers", "1,234", "+5%")
with col3:
st.metric("Orders", "567", "-2%")
with col4:
st.metric("Revenue", "$89.4K", "+8%")
# Charts
data = pd.DataFrame(np.random.randn(20, 3), columns=['A', 'B', 'C'])
st.line_chart(data)Example 2: Data Explorer with Upload
import streamlit as st
import pandas as pd
st.title("π Data Explorer")
uploaded_file = st.file_uploader("Upload CSV", type=['csv'])
if uploaded_file:
df = pd.read_csv(uploaded_file)
st.metric("Rows", len(df))
st.metric("Columns", len(df.columns))
st.subheader("Data Preview")
st.dataframe(df)
st.subheader("Summary Statistics")
st.dataframe(df.describe())Example 3: Chat Interface
import streamlit as st
st.title("π¬ Chat")
if "messages" not in st.session_state:
st.session_state.messages = []
for message in st.session_state.messages:
with st.chat_message(message["role"]):
st.markdown(message["content"])
if prompt := st.chat_input("Your message"):
st.session_state.messages.append({"role": "user", "content": prompt})
with st.chat_message("user"):
st.markdown(prompt)
# Generate response
response = f"Echo: {prompt}"
with st.chat_message("assistant"):
st.markdown(response)
st.session_state.messages.append({"role": "assistant", "content": response})Development
Running Tests
Run all tests:
pytest tests/Run individual test files:
# Comprehensive server and tool tests
python tests/test_server.py
# Security vulnerability verification tests
python tests/test_security_fixes.py
# Drawing interpreter tests
python tests/test_drawing_tool.pyAdding New Tools
Create tool function in appropriate module
Add tool definition to TOOLS list
Register in server.py
Update documentation
Code Style
Follow PEP 8
Use type hints
Add docstrings
Run
blackandrufffor formatting
Roadmap
Phase 1 β COMPLETE
β Core server infrastructure
β Text elements (11 tools)
β Input widgets (10 tools)
β Page planner (key tool)
β Code generation utilities
β Resource management (11 tools)
Phase 2 β COMPLETE
β Charts & visualizations (12 tools)
β Layouts & containers (9 tools)
β Data display (6 tools)
Phase 3 β COMPLETE
β Status elements (10 tools)
β Media elements (5 tools)
Phase 4 β COMPLETE
β Chat elements (3 tools)
β Navigation (5 tools)
β State management (5 tools)
β Execution flow (5 tools)
Phase 5 β COMPLETE (100% MILESTONE!)
β Authentication (5 tools): st.login(), st.logout(), st.user, patterns, OIDC config
β Data connections (5 tools): SQL, Snowflake, custom connections, config, patterns
π ALL 103 CORE TOOLS IMPLEMENTED! 100% COMPLETE!
Phase 6 (Future Enhancement)
β³ Runtime management (3 tools)
β³ Additional templates
β³ Testing utilities
β³ CLI commands
Troubleshooting
Server Won't Start
Problem: ModuleNotFoundError: No module named 'mcp'
Solution (with UV):
# Install dependencies
uv sync --all-extras
# Verify installation
uv run python -c "from streamlit_mcp.server import run; print('β
Server ready!')"Solution (with pip):
# Install dependencies
pip install -e ".[dev]"
# Verify installation
python -c "from streamlit_mcp.server import run; print('β
Server ready!')"Problem: ImportError or other Python errors
Solution:
Check Python version:
python --version(need 3.10+)With UV:
uv sync --all-extrasWith pip: Try reinstalling:
pip install -e ".[dev]" --force-reinstallCheck for conflicting packages in your environment
Claude Code Integration Issues
Problem: Claude Code doesn't see the MCP server
Solution:
Check config file location:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
Verify JSON syntax (use a JSON validator)
Ensure the command path in config is correct:
With UV:
{ "mcpServers": { "streamlit": { "command": "uv", "args": ["run", "python", "-m", "streamlit_mcp.server"], "env": {} } } }With Python:
{ "mcpServers": { "streamlit": { "command": "python", // or full path: "/usr/bin/python3" "args": ["-m", "streamlit_mcp.server"], "env": {} } } }Restart Claude Code completely
Check Claude Code logs/console for error messages
Problem: Server starts but commands don't work
Solution:
Verify the server is listed: Ask Claude "List MCP servers"
Try a simple command: "Use streamlit MCP to add a title"
Check if other MCP servers work to isolate the issue
Generated Code Issues
Problem: Generated code has syntax errors
Solution:
Use the validator: "Use streamlit MCP validator to check this code"
Copy the error message and ask Claude to fix it
Check for missing imports or incorrect indentation
Problem: Streamlit raises deprecation warnings
Solution:
Check your Streamlit version:
uv run pip show streamlitorpip show streamlitUpdate if needed (UV):
uv sync --upgradeor (pip):pip install --upgrade streamlitSome features require Streamlit β₯1.40.0
Problem: Code runs but doesn't match expectations
Solution:
Validate against the plan: Use
validate_implementationtoolCheck the generated code carefully
Try regenerating with more specific description
Orchestrator/Planner Issues
Problem: Multi-page app detected as single-page (or vice versa)
Solution:
Be explicit in description: "Multi-page app with 3 pages: ..."
Use keywords: "pages", "navigation", "multi-page"
Use workflow_mode parameter:
workflow_mode="multi"or"single"
Problem: Generated plans are missing details
Solution:
Provide more detailed descriptions
Mention specific components: "4 metrics", "line chart", "data table"
Specify page types: "dashboard", "data_explorer", "chat"
Problem: Validation scores are low
Solution:
Check the suggestions in validation output
Ensure required components are present
Follow Streamlit best practices (caching, page config, etc.)
Use appropriate page type for validation
Common Errors
Error: FileNotFoundError when loading templates or resources
Solution:
Ensure you're in the project directory
Check that
streamlit_mcp/resources/andstreamlit_mcp/templates/existReinstall the package:
uv syncorpip install -e .
Error: Test failures
Solution:
# Run tests with verbose output
pytest tests/ -v
# Run specific test file
pytest tests/test_server.py -v
# Check for import issues
python -c "import streamlit_mcp"Error: Permission denied errors
Solution:
Check file permissions
On Unix/Mac:
chmod +x script.shWith UV: Try
uv sync --user(if supported)With pip: Try
pip install --user -e ".[dev]"
Performance Issues
Problem: Orchestrator is slow
Solution:
Set
validate_plans=Falsefor faster executionSet
generate_code=Falseif you only need plansBreak large apps into smaller chunks
Problem: Large apps take too long
Solution:
Use
create_page_planfor individual pages instead of full orchestrationGenerate pages separately
Cache intermediate results
Getting More Help
If problems persist:
Check the logs: Look for error messages in console output
Run diagnostics:
python tests/test_server.pyVerify environment:
pip list | grep -E "(mcp|streamlit)"Review examples: Check
examples/directory for working codeReport issues: Create a GitHub issue with:
Error message
Steps to reproduce
Python version
Environment details
Quick Diagnostics
Run this diagnostic script:
With UV:
# Check UV installation
uv --version
# Check Python version
python --version
# Check package installation
uv run python -c "import streamlit_mcp; print('β
Package imported')"
# Check MCP installation
uv run python -c "import mcp; print('β
MCP installed')"
# Run server import test
uv run python -c "from streamlit_mcp.server import run; print('β
Server can run')"
# Run basic tests
uv run pytest tests/test_server.py::test_imports -vWith pip:
# Check Python version
python --version
# Check package installation
python -c "import streamlit_mcp; print('β
Package imported')"
# Check MCP installation
python -c "import mcp; print('β
MCP installed')"
# Run server import test
python -c "from streamlit_mcp.server import run; print('β
Server can run')"
# Run basic tests
pytest tests/test_server.py::test_imports -vContributing
Contributions welcome! Areas of focus:
Implementing remaining tools
Adding templates
Improving code generation
Writing tests
Documentation
Resources
License
MIT License - See LICENSE file for details
Support
For issues, questions, or contributions:
GitHub Issues: [Create an issue]
Documentation: See README.md
Examples: See examples/ directory
Built with β€οΈ for the Streamlit and AI community
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
This server cannot be deployed
Maintenance
Related MCP Connectors
Let your AI agent build, preview and update web apps, download source and publish when you allow it.
Turn your app idea into IA, wireframes, PRD, style guides, and dev specs for coding agents.
Build, deploy and share small full-stack team apps from your AI chat. No account needed to start.
Design, save, and run outcome-aligned AI workflows and verifiers, with reliable image output.
Related MCP Servers
AlicenseBqualityFmaintenanceEnables AI-driven generation of UI components, full applications, and backend code across multiple frameworks (React, Vue, Angular, Svelte, HTML) with Figma integration and brand identity support.38161 npm2MIT- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to create interactive charts, diagrams, and tables displayed on a real-time dashboard, supporting multiple data sources with privacy-focused local execution.1MIT
- AlicenseBqualityDmaintenanceEnables AI assistants to scaffold, edit, live-preview, and deploy full-stack apps with built-in database, email, and push notification capabilities through natural language.19MIT
- AlicenseCqualityFmaintenanceEnables reasoning agents to turn PRDs into production-ready applications by discovering and reusing existing features, UI components, database models, and templates, then planning, scaffolding, validating, and preparing Git changes for review.29MIT