Skip to main content

A FastAPI-style Python web framework with a Rust tokio/hyper core, and a built-in MCP server.

Project description

RustAPI

A FastAPI-style Python web framework backed by a Rust (tokio/hyper) engine — with a built-in MCP (Model Context Protocol) server on the same instance.

from rustapi import Engine
from pydantic import BaseModel

app = Engine()

class Item(BaseModel):
    name: str
    price: float

@app.get("/")
def root():
    return {"message": "hello"}

@app.post("/items")
def create_item(item: Item):
    return {"created": item.name, "price": item.price}

@app.tool()
def add(a: int, b: int) -> int:
    """Add two numbers."""
    return a + b

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8000)
  • GET/POST/PUT/DELETE routes with path params, query params, and Pydantic request-body validation
  • Auto-generated OpenAPI schema at /openapi.json, Swagger UI at /docs
  • MCP server at POST /mcp (JSON-RPC 2.0, Streamable HTTP transport): @app.tool(), @app.resource(uri), @app.prompt()
  • Multi-worker mode (workers=N, SO_REUSEPORT) and reload=True for dev
  • Async and sync handlers, dispatched off the request-handling thread so a slow handler doesn't stall other in-flight requests

Install

pip install rustapi-framework

Development

pip install maturin
maturin develop --release
pytest tests/ -v

What runs where

Routing, validation dispatch, JSON transport, and the MCP JSON-RPC envelope are Rust. Your handler bodies run as ordinary Python (CPython), same as any other Python web framework — that part doesn't change unless you write a handler as a native #[pyfunction] yourself (see rustapi.compute for an example of that pattern).

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

rustapi_framework-0.1.0-cp312-cp312-win_amd64.whl (819.3 kB view details)

Uploaded CPython 3.12Windows x86-64

rustapi_framework-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl (837.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

rustapi_framework-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl (771.5 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

Details for the file rustapi_framework-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for rustapi_framework-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a933f330df12ee56aa4d6af3c1219d7336c488167f106a576653d8fa8eb2c05d
MD5 086fb6782d2923f6f2149e531439774d
BLAKE2b-256 a5fb6f086a816e9f97daac052fb38ffc062bb3f0ae36d49b217c65cb35b963cc

See more details on using hashes here.

File details

Details for the file rustapi_framework-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for rustapi_framework-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 b7bac581a44bc191d2c4085ce9d9759054332a7f957515531e94d951e2c5bfcb
MD5 3c6ea16a3bbab0b70eefb251b78eb858
BLAKE2b-256 0d74b018bd70c0356f3db6ba9e1ff5e7c86bcd76429e757207c499fceefce296

See more details on using hashes here.

File details

Details for the file rustapi_framework-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rustapi_framework-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 17c5259bbee9eb27b07707a6a65d615a854e0b92d925b5b31613eda923272639
MD5 d07529635186c6dfc4812383d883df46
BLAKE2b-256 0d2f59f1828be4fd0322446210d70e5383b4a17dab6fdea4adc6eb0ee586a07c

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