Metadata-Version: 2.4
Name: mwps-client-dev
Version: 0.1.73
Summary: Official mwps client library: single entry point MwpsClient, one typed method per mwps command.
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: mcp-proxy-adapter>=8.11.10

# mwps-client

Official Python client for the `mwps` server. `MwpsClient` is the single
entry point: it hides transport selection, TLS material, request
correlation and error mapping behind one typed async method per
`mwps` command (see `mwps_client/mwps_client/client.py`).

The client calls the `mwps` server DIRECTLY. It connects to the server
address given as `base_url` (host and port), presenting the client
certificate `cert` and `key` when they are supplied and verifying the server
against `ca`. It does not go through MCP Proxy: there is no `call_server`
hop between the client and `mwps`. Callers reach `mwps` only through this
client.

## Public surface

- One async method per command: `session_init`, `session_update`,
  `add_command_to_session`, `remove_command_from_session`,
  `get_model_context`, `invoke_tool`, `mwps_chat`, `info`,
  `serving_model_set`, `serving_model_get`.
- `health()`: the health answer of the server (`status` `ok`) with its
  `version`, which equals the version `info` reports. An unreachable server
  raises `MwpsClientError`.
- `call(command, params)`: one command with a raw parameter map (the
  bounded way to send a parameter set the typed methods do not offer, for
  example for negative cases).
- `aclose()`: closes the transport.

A command-level failure (`success` false, for example `-32603`) is returned
as a dict; an adapter refusal (unknown command or parameter, missing
parameter) and every transport failure are raised as `MwpsClientError`.

## Working with a session

Everything the model does happens in a session:

- `mwps_chat(session_id, content, model=None, max_tool_rounds=None)` runs
  one turn of a session. There is no `stream` parameter and no tools-file
  parameter: the tools of a turn are the session tool list. The result has
  `message`, `history`, `usage` (`input_tokens`, `output_tokens`) and
  `truncated`.
- `invoke_tool(tool_name, arguments=None, *, session_id)` invokes one tool
  of the session tool list; `session_id` is required.
- The working model is ONE string `<provider>:<model>` (in `session_init`,
  `session_update` and `mwps_chat`). A bare model name is accepted only
  when exactly one macsc provider lists it as a chat model; otherwise the
  server answers `-32602` with the list of full strings.
- Command names are fleet names `<server>_<copy>:<command>`; the copy may
  be omitted, and a bare command name is accepted only when exactly one
  server has it (else `-32602` with the full names). The tools of mwps
  itself are `mwps:...`.
- A session expires after the server's `session_ttl_hours` (default 24)
  without use; every command that finds the session extends it.

## Model access

`mwps-client` talks only to `mwps` itself, never to a model. The `mwps`
server it calls never talks to a model directly either: macsc (Model
Access Core) is the sole gateway for model access, reached exclusively
through macsc's own client, `macore_client.MacClient` (package
`macore-client`); lmrs is reached only through macsc. See the server's
`info` command (`overview` section) or `src/mwps/docs/overview.md` in the
server repository for the full rule.

## Installation

```
pip install mwps-client
```

The client needs `mcp-proxy-adapter>=8.11.10` (installed with it).

## Usage

```python
import asyncio
from mwps_client import MwpsClient

async def main():
    client = MwpsClient(base_url="https://<host>:8015", ca="/path/to/ca.crt")
    print(await client.health())
    session = await client.session_init(model="<provider>:<model>")
    session_id = (session.get("data") or {}).get("session_id")
    result = await client.mwps_chat(session_id=session_id, content="Hello")
    print(result)
    await client.aclose()

asyncio.run(main())
```

## Version lockstep

`mwps-client` carries no version of its own: its published version is
always identical to the `mwps` server version it was generated against
(C-068, ClientServerVersionLockstep). Both packages read the same
repository-root `VERSION` file — `mwps_client/VERSION` is a symlink to
`../VERSION` — so a client published from a given deploy always matches
the server it talks to. The DEV pass of `build.sh` publishes the same code
as the distribution `mwps-client-dev`. See `pipeline/README.md` for the
release process that keeps the two in lockstep.
