MCP Mastery
About
c-01-runnable-contract

Runnable Contract

Prove you can ship invoke, batch, and stream without hiding a for-loop and calling it streaming.

warmup
python
~25 min

README

# c-01-runnable-contract

Implement the Runnable-shaped contract: `invoke`, `batch`, and `stream` with deterministic outputs. No frameworks required — just discipline.

## Validator

From repo root:

```bash
npm run challenge -- runnable-contract --track langchain
```

Or from this package directory:

```bash
cd challenges/langchain/c-01-runnable-contract
uv run python tests/validate.py
```

Hints

  • If stream buffers the whole string before yielding, you are cosplaying Iterable, not streaming.
  • Match the validator literally: double `n`, stringify the doubled value for stream chunks.
  • Batch must preserve ordering — shuffling outputs is an excellent way to fail quietly.

Acceptance

  • `npm run challenge -- runnable-contract --track langchain` exits 0
  • `invoke`, `batch`, and `stream` agree on the doubling rule for integer field `n`
  • Streaming yields each character of the decimal string (no extra separators)