Metadata-Version: 2.5
Name: rayrun-sdk
Version: 0.9.0
Summary: Python SDK for Rayrun embedded agents and MCP infrastructure
Project-URL: Documentation, https://ray.run/docs/public-api
Project-URL: Homepage, https://ray.run
Project-URL: Repository, https://github.com/rayrundev/rayrun
Author-email: Rayrun <support@ray.run>
License-Expression: MIT
Keywords: agents,mcp,model-context-protocol,rayrun
Requires-Python: >=3.9
Requires-Dist: httpx<1,>=0.28
Provides-Extra: test
Requires-Dist: pytest<9,>=8; extra == 'test'
Description-Content-Type: text/markdown

# Rayrun Python SDK

```sh
pip install rayrun-sdk
```

Create one short-lived MCP session for an application user:

```python
import os

from rayrun import Rayrun

with Rayrun(os.environ["RAYRUN_API_KEY"]) as rayrun:
    principal = rayrun.external_principals.upsert(
        "customer_123",
        display_name="Ada",
        metadata={"plan": "pro"},
    )
    session = rayrun.external_principals.create_session(
        principal["uid"],
        runtime_context={"accountId": "customer_123", "plan": "pro"},
    )

    page = rayrun.external_principals.list_sessions(principal["uid"], limit=50)
    if page["page"]["nextCursor"]:
        next_page = rayrun.external_principals.list_sessions(
            principal["uid"], cursor=page["page"]["nextCursor"], limit=50
        )

print(session["endpoint"], session["sessionToken"])
```

`AsyncRayrun` exposes the same methods for async applications. Use a key with
`principals:read`, `principals:write`, `sessions:read`, and `sessions:write`. Create a Connect Link
with `create_connect_link(principal_uid, connection_id)` when the user must authorize an upstream
OAuth account. Correlate the returned `uid` with `connectLinkUid` in either terminal webhook:
`external.authorization.completed` or `external.authorization.failed` (`provider_denied`,
`incomplete_response`, `authorization_failed`, or `expired`). A session created without
`tool_access_profile_uid` is read-only; pass an access profile to define an explicit tool ceiling that
includes approved mutations.
