# IBOL: a local MCP client example with source credit

This example lets an agent operator retrieve an IBOL companion reading guide
and give a human reader the author's name, the book citation and the source
locator beside the result. It uses a real local MCP session, without a model or
API key. It generates no legal interpretation.

The source is **Albert Tan Sin Hon, Insurance-Backed Offshore Liquidity:
Financial Law, Trust Governance and Regulatory Visibility at the PRC-Hong Kong
Interface** (University of Groningen Press, 2026),
<https://doi.org/10.21827/6ac3948159a9e>.

- Author and related work: <https://alberttansinhon.com/>
- Open Learning Companion: <https://alberttansinhon.com/ibol/>
- Enquiries: <mailto:info@alberttansinhon.com>
- Server source: <https://github.com/Albertito-AI/Albertito-AI/tree/main/scripts/ibol>
- Versioned MCP bundle: <https://github.com/Albertito-AI/Albertito-AI/releases/tag/ibol-mcp-v1.0.2>

## Requirements and explicit setup

Use Python 3.12 and the already-installed official **`mcp==1.30.0`** Python SDK,
matching the server's current pinned requirement. The client and server may use
the same existing virtual environment. Install and review dependencies before
running this example; the script never invokes a package manager or installs
anything. The server must already be extracted or checked out with its companion
data. A bare `mcp_server.py` copied away from those files is insufficient.

Choose the Python executable and server script yourself. The script starts that
exact interpreter with that one script argument, without a shell. Run only a
server you trust. It is a client example, not a sandbox for arbitrary programs.

The client and these three IBOL tools use local process pipes and files. They do
not fetch the publisher PDF, call a remote model, install dependencies or make
HTTP requests. URLs in the report are source references. The server script is
selected by its operator; these statements describe the documented IBOL server.

## Run from any directory

Replace the uppercase example paths with existing absolute paths. Keep the
virtual environment's Python path rather than resolving its symlink to a system
interpreter.

```sh
/ABSOLUTE/IBOL-VENV/bin/python /ABSOLUTE/EXAMPLE/ibol_agent_report.py \
  --server-python /ABSOLUTE/IBOL-VENV/bin/python \
  --server-script /ABSOLUTE/IBOL/scripts/mcp_server.py \
  --query protector \
  --format markdown
```

In a repository checkout, the server path is `scripts/ibol/mcp_server.py`.
In the extracted published bundle, it is `scripts/mcp_server.py`.
On Windows, use the existing virtual environment's `Scripts/python.exe` and
absolute Windows paths. The observed example receipt covers Linux, not a
separate Windows client trial.

The default output is JSON. This retains the complete provenance envelopes from
each of the three tool responses, plus the actual negotiated protocol and tool
annotations. Add `--format markdown` for a human-readable report with source
credit beside each returned guide. Redirect stdout explicitly if you want to
save a report. Errors go to stderr and return a nonzero process status. The
default session timeout is 30 seconds.

## What an agent calls

| MCP tool | Arguments | Purpose |
| --- | --- | --- |
| `get_book_metadata` | `{}` | Identify the book, author, publisher, edition cut-off and reuse terms. |
| `get_citation` | `{"style":"plain"}` | Obtain the server's bibliographic citation. |
| `search_guides` | `{"query":"protector","limit":3}` | Search the local companion titles, guides, goals and exercises. |

The client first initialises a normal `ClientSession` and calls `list_tools`.
It checks the three tools' explicit read-only, non-destructive, idempotent and
closed-world annotations. It then makes those three calls and checks that their
source DOI, author, companion URL and edition provenance agree. Tool annotations
are descriptive metadata, not proof that an arbitrary server is safe.

For integration into an existing Python agent, import the module and call
`await fetch_report(server_python, server_script, query, limit)` inside the
operator's own timeout. `readable_report(report)` renders the human report. Keep
`tool_results` with the result so downstream reports can retain source locators,
the legal cut-off and licence distinctions.

## Meaning and limits of the result

`search_guides` searches the companion, not the full book. Its displayed
paragraphs are companion summaries. They are not quotations verified against
the publisher PDF. A no-match result remains a no-match result; the client does
not generate an answer to fill the gap.

The book's legal cut-off is **1 August 2026**. The companion identifies itself
as an AI-assisted teaching supplement commissioned by the author and not
publisher-reviewed. The teaching material is **CC BY 4.0**; the published book
has its separate **CC BY-NC-ND 4.0** licence. This client preserves those source
labels and does not convert teaching material into current legal advice.

`observed-receipt.json` records the local implementation test. This is an
author-maintained example of real MCP interoperability. It does not establish
independent use, user adoption, endorsement or installation in every MCP host.

The example script is MIT licensed. Keep attribution when redistributing the
companion text and retain the source's separate book and teaching licences.
