Skip to main content

The Python interface for methods — base structures for structured outputs and the base runner for executing methods via API.

Project description

mthds

The Python implementation of the MTHDS Protocol — a typed client for any MTHDS runner, plus the base structures that methods are defined in.

Learn more at mthds.ai and browse the Hub at mthds.sh.

Looking for the command line? The mthds CLI ships as the npm package (mthds-js). This Python package is a library — it has no CLI.

Installation

pip install mthds

What's in the box

  • The protocol (mthds.protocol) — MTHDSProtocol, the five-route interface every runner implements (execute, start, validate, models, version); the wire models (RunResult, ModelDeck, ValidationReport, VersionInfo); and the domain shapes methods are built from (concept, stuff, working_memory, pipe_output, pipeline_inputs).
  • Runners (mthds.runners) — MthdsAPIClient (mthds.runners.api.client), the HTTP client for any MTHDS-Protocol server plus the hosted run-lifecycle (polling) extension; and PipelexRunner (mthds.runners.pipelex.runner), which shells out to a locally installed pipelex CLI.
  • Package management (mthds.package) — read, lock, and resolve METHODS.toml manifests.

See docs/runners.md for the protocol + runners reference.

Quick start

Run a method against any MTHDS-Protocol server with the API runner, MthdsAPIClient:

import asyncio

from mthds.runners.api.client import MthdsAPIClient


async def main() -> None:
    async with MthdsAPIClient() as client:
        # Discovery handshake
        version = await client.version()
        print(version.protocol_version)

        # Run a method and wait for the result — start → poll → result in one call
        result = await client.start_and_wait(pipe_code="my_pipe", inputs={"topic": "owls"})
        print(result.main_stuff)


asyncio.run(main())

execute runs synchronously; start returns immediately with a pipeline_run_id; start_and_wait does the whole async lifecycle in one call. validate, models, and version round out the protocol surface.

Need local execution instead of an API? PipelexRunner (mthds.runners.pipelex.runner) implements the same MTHDSProtocol by shelling out to an installed pipelex CLI — no API key.

Configuration

MthdsAPIClient() reads its config from ~/.mthds/config — the same file the mthds CLI (npm) reads and writes, so configuring either configures both. Environment variables take precedence:

Variable Description Default
MTHDS_API_KEY API authentication key (empty)
MTHDS_BASE_URL API base URL — any MTHDS Protocol server http://localhost:8081

This client targets the open-source pipelex-api runner, so it defaults to a local instance (http://localhost:8081, pipelex-api's default port). Point MTHDS_BASE_URL at any other MTHDS-Protocol server to use it instead. You can also pass api_key / base_url straight to MthdsAPIClient(...).

To set the config from a terminal, use the npm CLI (mthds config set api-key …) or edit ~/.mthds/config directly.

Related packages

  • mthds (npm) — the mthds CLI (install methods, run, configure) + TypeScript client.
  • Pipelex — the reference full-featured runner.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mthds-0.7.0.tar.gz (136.4 kB view details)

Uploaded Source

Built Distribution

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

mthds-0.7.0-py3-none-any.whl (57.9 kB view details)

Uploaded Python 3

File details

Details for the file mthds-0.7.0.tar.gz.

File metadata

  • Download URL: mthds-0.7.0.tar.gz
  • Upload date:
  • Size: 136.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mthds-0.7.0.tar.gz
Algorithm Hash digest
SHA256 35e8c9d5f4b27e86fec02245f72bc2eb9c849790d39a8ffe6dcb001e7fe7d4cb
MD5 58f130588d9e343ec87319fe678dc6a7
BLAKE2b-256 e6fe52bf1818f41b71658f24ee78dfe24730c04c1066e8b434f39fe23823cbb4

See more details on using hashes here.

Provenance

The following attestation bundles were made for mthds-0.7.0.tar.gz:

Publisher: publish.yml on mthds-ai/mthds-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mthds-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: mthds-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 57.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mthds-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e371b73ba259899f5ba0b460809d00f176ac44ad773073a3ebb6c10ee207866
MD5 3b809068d40934f0f336489c8055696d
BLAKE2b-256 b79ff12c6de8a2ed9938a5914559639921ded8275f42b8c43ac1af35fe7a488f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mthds-0.7.0-py3-none-any.whl:

Publisher: publish.yml on mthds-ai/mthds-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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