muse-code-sdk
The Python SDK for Muse Code: an asyncio-first client for driving a Muse Code agent over the Muse Session Protocol (MSP), with a thin synchronous wrapper for scripts and notebooks.
- Open and resume sessions against a spawned
muse servehost, or attach to one you already run. - Stream a turn's items and text deltas as async iterators; await the turn's server-authored outcome.
- Answer tool-approval requests with a handler you register.
- A client-side fold keeps a live, typed view of the session — items, session state, pending commands — with gap recovery after reconnects, and safe same-command retry that can never double-submit.
SyncMuseClientmirrors the same surface with blocking verbs.
Status: developer preview. Experimental protocol surfaces may change.
The generated MSP wire types live in the companion package
muse-code-msp and are never
restated here. One runtime dependency: pydantic, exact-pinned.
Python 3.10+. Fully typed (py.typed).
Install
pip install muse-code-sdk muse-code-msp
You also need the Muse Code CLI: a muse binary on PATH, or an explicit
path passed at spawn time.
Use
import asyncio
from muse_code import (
MuseClient, MuseClientSpawnOptions, SendUserTurnOptions, StartSessionOptions,
)
async def main() -> None:
client = await MuseClient.spawn(MuseClientSpawnOptions(
muse_bin="muse",
args=["serve"],
client_info={"name": "my-app", "version": "1.0.0"},
))
session = await client.start_session(StartSessionOptions(workspace_root="."))
turn = await session.send_user_turn(SendUserTurnOptions(
input=[{"type": "text", "text": "Summarize this repository."}],
composer_input="Summarize this repository.",
))
async for item in turn.items():
print(item)
await turn.completed
await client.close()
asyncio.run(main())
Documentation
- Guides, cookbook recipes, and the protocol reference: https://meta-models.github.io/muse-code-sdk/
- Python API reference: https://meta-models.github.io/muse-code-sdk/next/generated/python/
- Source and issues: https://github.com/meta-models/muse-code-sdk
Release files for muse-code-sdk 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| muse_code_sdk-1.3.1.tar.gz | 212.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| muse_code_sdk-1.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 327.2 kB
Release files / muse_code_sdk-1.3.1.tar.gz
| Download URL | muse_code_sdk-1.3.1.tar.gz |
|---|---|
| Size | 212.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9bcd872f03156f391eb70265e616c58f431e541266f5bdbc31dff0c6e4d51b02
|
|
BLAKE2b-256 checksum How to use checksums |
d8dfc76164e4b9b6a4ceee6708e9be2fa30c832e53c4c8f99cc3d1fdb2913ae5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency logRelease files / muse_code_sdk-1.3.1-py3-none-any.whl
| Download URL | muse_code_sdk-1.3.1-py3-none-any.whl |
|---|---|
| Size | 114.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
51e39bf922601a4305e0bf42230cab74fb6dd927ce658583e7320bbeab1bd2c5
|
|
BLAKE2b-256 checksum How to use checksums |
82f04ea2827103fd5519dbe06f930b98af957ca232a9876d67183486b4a8c37e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.
Transparency log