Metadata-Version: 2.4
Name: liberrex-mcp-client
Version: 0.1.0
Summary: Call other platforms' tools on the Liberrex MCP mesh, from async or sync code, and hand them to an LLM as function-calling tools.
Author: Liberrex
License: Liberrex MCP client — Proprietary License
        
        Copyright (c) 2026 Liberrex. All rights reserved.
        
        1. Grant. Subject to these terms, Liberrex grants you a non-exclusive, non-transferable, revocable license to install and use
           this software, unmodified or modified, solely to integrate your own applications with the Liberrex platform while you
           (or the organisation you act for) hold a valid Liberrex subscription or a written evaluation agreement with Liberrex.
        
        2. Restrictions. You may not (a) use this software to access any service other than the Liberrex platform; (b) sell,
           sublicense, rent or distribute it on its own, except as an unmodifiable part of your application delivered to your end
           users; (c) remove or alter this notice; (d) use it to build a product that competes with the Liberrex platform.
        
        3. Ownership. Liberrex retains all rights, title and interest in this software. No other rights are granted, by implication
           or otherwise.
        
        4. Termination. This license ends automatically when your Liberrex subscription or evaluation ends, or if you breach these
           terms. On termination you must stop using the software.
        
        5. No warranty. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING MERCHANTABILITY,
           FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
        
        6. Limitation of liability. TO THE MAXIMUM EXTENT PERMITTED BY LAW, LIBERREX SHALL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
           SPECIAL OR CONSEQUENTIAL DAMAGES ARISING FROM THE USE OF THE SOFTWARE.
        
        7. Your agreement with Liberrex. If you have a signed agreement with Liberrex that covers this software, that agreement
           prevails over these terms.
        
        Contact: https://ai.liberrex.com
        
Project-URL: Homepage, https://ai.liberrex.com
Keywords: liberrex,mcp,model-context-protocol,ai,agents,integration
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Typing :: Typed
Classifier: License :: Other/Proprietary License
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: mcp<3,>=2.3
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
Requires-Dist: respx>=0.21; extra == "dev"
Requires-Dist: uvicorn>=0.30; extra == "dev"
Dynamic: license-file

# liberrex-mcp-client (Python)

Call the tools of other platforms on the **Liberrex MCP mesh** (Liberrex AI, Animatoria, the ERP…) from async or sync
code, and hand them to an LLM as function-calling tools. Implements the [mesh conventions](../../MCP_MESH.md); the
other side is [`liberrex-mcp-server`](../../mcp-server/python). TypeScript equivalent:
[`@liberrex/mcp-client`](../typescript).

```bash
pip install liberrex-mcp-client
```

## Configure the platforms you call

```bash
LIBERREX_MCP_PLATFORM=animatoria         # this platform's own name (trace origin)
LIBERREX_MCP_PLATFORMS='{"liberrex-ai": {"url": "https://ai-api.liberrex.com/mcp", "key": "lxp_…"},
                         "erp":         {"url": "https://erp.acme.tn/mcp", "key": "lxp_…", "timeout": 20}}'
```

Each platform issues your key (`liberrex-mcp-server new-key <your-name>`) and lists you in its `LIBERREX_MCP_PEERS`.
Keys are secrets: keep them server-side.

## Call tools

```python
from liberrex_mcp_client import Identity, Mesh, PlatformToolError

mesh = Mesh.from_env()
sara = Identity(user_id="42", tenant_id="biat", roles=("sales.read",), locale="fr")   # the signed-in user

recs = await mesh.call("liberrex-ai", "sales_recommendations",
                       {"mode": "next_best_product", "context": {"record": {"type": "Customer", "id": "C-118"}}},
                       identity=sara)

try:
    mesh.call_sync("erp", "send_reminder", {"invoice_id": "F-1024"}, identity=sara)   # Flask, Celery, scripts
except PlatformToolError as error:
    if error.code == "writes_disabled": ...
```

- The identity is the **signed-in person**, set by your code and never by a model. The called platform applies that
  person's permissions.
- `PlatformToolError.code` is a mesh code: `forbidden`, `not_found`, `identity_required`, `tenant_not_allowed`,
  `writes_disabled`, `rate_limited`… `PlatformUnavailable` means the platform was unreachable or refused the key.
- `list_tools(name)` is cached for 5 minutes. Each `RemoteTool` carries `input_schema`, `write`, `permission` and
  `category`.
- Inside a platform tool, pass `meta=ctx.forward_meta()` instead of `identity` to keep the trace across platforms.

## Give the tools to an LLM

```python
from liberrex_mcp_client import anthropic_tools, openai_tools, route

tools = await mesh.list_tools("animatoria")
specs = anthropic_tools([t for t in tools if not t.write])   # names: animatoria__production_ranking
platform, tool = route(call.name, tools)                     # back to ("animatoria", "production_ranking")
result = await mesh.call(platform, tool, call.input, identity=sara)
```

Get a human's approval before you run a `write` tool.

## Development

```bash
.venv/bin/pytest     # the end-to-end tests live with the server package (sdk/mcp-server/python/tests)
```
