μ∗ - python micro framework based around data-star, inspired by PocketBase
Find a file
magicalhack f5cdee3569 Add MCP tool support, refactor context and module loading
- Introduce @tool decorator and McpContext for registering MCP tools with optional Pydantic args
- Add FastMCP server integration with SSE mount at /mcp, lifecycle management
- Rename Context → HttpContext, extract BaseContext for shared DB access
- Replace file-glob discovery with package-based import (import_user_package)
- Move render logic from html.py to lib/render.py
- Rename test dummy routes.py → __init__.py to match package import model
- Strip basecoat defaults from Config, add static file serving in dev
- Generate __init__.py in `ms init` scaffolding
- Hot reload now watches for file creation and moves, not just modifications
2026-03-20 18:39:00 -04:00
bin switch to ty 2026-02-21 09:13:35 -05:00
src/microstar Add MCP tool support, refactor context and module loading 2026-03-20 18:39:00 -04:00
tests Add MCP tool support, refactor context and module loading 2026-03-20 18:39:00 -04:00
.gitignore initial commit 2026-01-31 00:31:26 -05:00
.pre-commit-config.yaml initial commit 2026-01-31 00:31:26 -05:00
LICENSE initial commit 2026-01-31 00:31:26 -05:00
mise.toml initial commit 2026-01-31 00:31:26 -05:00
pyproject.toml Add MCP tool support, refactor context and module loading 2026-03-20 18:39:00 -04:00
README.md initial commit 2026-01-31 00:31:26 -05:00

μ∗

A Python web framework for building real-time, progressively enhanced web applications. HTML-in-Python with zero-config database and automatic real-time updates.

Philosophy

  • HTML-first: Build UIs with pure Python using htpy
  • Real-time by default: SSE streaming via datastar
  • Backend-in-a-box: Built-in SQLite with JSON storage
  • Decorator-driven: Routes, hooks, jobs, cron — all via decorators

Install

pip install microstar

Quick Start

# routes.py
from microstar import page, action, Context
from microstar.html import div, h1, button, data, actions

@page("/")
async def home(ctx: Context):
    ctx.title = "My App"
    return div()[
        h1()["Hello μ∗"],
        button(data.on("click", actions.post("/clicked")))["Click me"],
        div(id="output")
    ]

@action("/clicked", methods=["POST"])
async def clicked(ctx: Context):
    ctx.inner("#output")
    yield div()["Clicked!"]
microstar  # starts server on :6262

Features

  • Pages & Actions — Declarative routes with streaming SSE responses
  • Databasectx.db.insert(), query(), update(), delete() with JSON storage
  • Hooks@before, @after, @on for intercepting DB operations
  • Variants — Render records in different formats, auto-broadcast on changes
  • Jobs@job + run_job() for background task queue
  • Cron@cron("*/5 * * * *") for scheduled tasks
  • Commands@command for custom CLI commands
  • Consolemicrostar console for interactive REPL with DB access