Get the FREE Ultimate OpenClaw Setup Guide →

lihil

2X faster ASGI web framework for python, offering high-level development, low-level performance.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio raceychan-lihil python -m lihil

How to use

Lihil is a Python-based web framework designed to make Python the mainstream language for web development. It provides strong typing, extensive testing support, and features like dependency injection, OpenAPI generation, WebSocket support, and an extensible plugin system. The README highlights its emphasis on performance, testability, and enterprise-ready capabilities, including a dedicated WebSocket Hub (SocketHub) that enables class-based channels, topic-based broadcasting, and DI-friendly access to dependencies inside channel handlers. You can start by installing Lihil with its standard feature set, then define routes, endpoints, and WebSocket handlers, leveraging the built-in DI system and OpenAPI documentation generation to build robust APIs. The toolkit is designed to work with ASGI servers (e.g., uvicorn) and aims to integrate AI-focused features and plugins into your application workflow.

To use Lihil, install the package and run the server via the Python module entry point. You can create HTTP routes, WebSocket routes, and channels, and you can also integrate advanced features such as SSE, OpenAPI docs, and a plugin system. The README emphasizes testing support (including Starlette TestClient compatibility) and the ability to inject dependencies and services into route handlers and channels. This makes it suitable for large-scale applications where type hints, error messages, and docstrings improve developer experience and maintainability.

How to install

Prerequisites:

  • Python 3.10 or newer
  • A Python environment (virtualenv recommended)

Step-by-step installation:

  1. Create and activate a virtual environment (optional but recommended): python -m venv .venv source .venv/bin/activate # on Unix/macOS .venv\Scripts\activate # on Windows

  2. Install Lihil with standard features (includes uvicorn support): pip install "lihil[standard]"

  3. Run a minimal app (example):

    This runs the Lihil application as a module

    python -m lihil

  4. Access your API docs and endpoints as configured in your lihil app. For additional features (AI integration, plugins, etc.), install or configure as per your project needs. You can also refer to the project README for specific examples like configuring routes, WebSocket hubs, and DI usage.

Additional notes

Notes and tips:

  • Lihil requires Python 3.10+ and supports ASGI servers like uvicorn; ensure your runtime environment has an ASGI server available.
  • The framework provides strong typing, automatic parameter parsing/validation, and OpenAPI documentation generation. Take advantage of these features to produce robust and well-documented APIs.
  • If you plan to use WebSockets, explore the SocketHub API: subclass ChannelBase, define a topic, and implement on_join/on_message/on_leave. Use bus broadcasting to publish messages to subscribed topics.
  • The plugin system enables you to integrate external libraries as if they were built-in features. When applying multiple plugins to endpoints, be mindful of the Onio Pattern (setup vs runtime execution).
  • For AI-related workflows, Lihil positions itself to integrate AI agents and workflows; refer to documentation and examples mentioned in the README (e.g., LIHIL_COPILOT guidance) for best practices.
  • If you encounter issues, check dependency compatibility (Python versions, uvicorn compatibility), and ensure your environment is configured for ASGI operation and DI-based injection.

Related MCP Servers

Sponsor this space

Reach thousands of developers