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.

pyrustapi-0.1.0-cp312-cp312-win_amd64.whl (819.2 kB view details)

Uploaded CPython 3.12Windows x86-64

pyrustapi-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl (836.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

pyrustapi-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (727.4 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyrustapi-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl (771.4 kB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: pyrustapi-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 819.2 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for pyrustapi-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 28a1362692da9d95d14c2a2d4dfeefc58606d23502963661a153df9575d750d4
MD5 0609c5a4f9660bb782d78f07d3b24d3b
BLAKE2b-256 06259c8f31d923e0806ad63bbd6ab4e7560f97fa253ffa75f9eed344744b7cbb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrustapi-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 8d14aa1d2005d8b79ef7d318b494b18a6575ca303237d9da39bee37251cfd989
MD5 0b71f7afbbc2bf4df3f706cc60fbf682
BLAKE2b-256 091c0abe81cc8e0bc32a5988a60e76c62e6667ce5772e45f7aa02b9e22633ed0

See more details on using hashes here.

File details

Details for the file pyrustapi-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyrustapi-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 16974fb1a45b4149810795df0d0fa1bad406a762cbe245a35593fd8869880647
MD5 f35621ad97e244de6465edd3c84e8dfe
BLAKE2b-256 dcb1ec661999928f9c370a600c6e437bf05ad1bf3cf1c672da8ac2a0f9fc07dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrustapi-0.1.0-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 234a9ed614a6f2a48cf391587d70e1e50cb0050b40cb05452ff553d42a9dad0a
MD5 5dc68acd8cb0646e68ea53a9e7256958
BLAKE2b-256 76f85eb9a74215f1deccbbe733e7321062862cb1fd94c4941a3ff6fb2b33eb6f

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