Skip to main content

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 serve host, 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, or pass it as ResumeSessionOptions(on_approval=...), with on_approval_error=... for its failures, so approvals still pending at resume reach it.
  • Answer the agent's questions: list them with session.fold.pending_user_inputs() and answer with session.answer_user_input.
  • 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.
  • SyncMuseClient mirrors 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; it is installed with this package, pinned to the same version. One further runtime dependency: pydantic, exact-pinned. Python 3.10+. Fully typed (py.typed).

Install

pip install muse-code-sdk

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

Metadata

Release files for muse-code-sdk 1.4.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for muse-code-sdk 1.4.12
File Size Uploaded Provenance Actions
muse_code_sdk-1.4.12.tar.gz 272.0 kB With provenance Details for muse_code_sdk-1.4.12.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for muse-code-sdk 1.4.12
File Interpreter ABI Platform Actions
muse_code_sdk-1.4.12-py3-none-any.whl Python 3 none any Details for muse_code_sdk-1.4.12-py3-none-any.whl

Total release size: 399.2 kB

Release files / muse_code_sdk-1.4.12.tar.gz

Download URL muse_code_sdk-1.4.12.tar.gz
Size 272.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f9f5da23efacf8e5d780d5daa722f9a09447862444df3fe2da7f4d69aa7a1509
BLAKE2b-256 checksum
How to use checksums
9df3cad8e69c32d4666fc317c914fd03cf1832a31a16b8a1dcdb3b04e1f1adc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 22, 2026.

Transparency log

Release files / muse_code_sdk-1.4.12-py3-none-any.whl

Download URL muse_code_sdk-1.4.12-py3-none-any.whl
Size 127.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c91333d8529fb990469552bf58c51c55ae573d8f416a27fca040a1ccfa3b865
BLAKE2b-256 checksum
How to use checksums
7c32f0402eee5c448235e1129e80be6ab01509ecde7e5896d91ac83585479556
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Oct 22, 2026.

Transparency log

Security for muse-code-sdk 1.4.12

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for muse_code_sdk-1.4.12.tar.gz

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 Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page