Skip to main content
Glama
fantlab-mcp

fantlab-mcp

by waldfalke
README.md
# fantlab-mcp monorepo

MCP server for FantLab API focused on publisher normalization for book catalogs.

## License model

This repository is **source-available for non-commercial research and educational use**.
Commercial use is prohibited without separate permission.
See `LICENSE`.

Note:
- this is a non-commercial research license, not OSI open-source.

## Monorepo layout

```text
fantlab-mcp/
  packages/
    fantlab-mcp-python/
      src/fantlab_mcp/
  tests/
  scripts/
  docs/ (planned)
```

## What it solves

- Reliable publisher resolution via ISBN (primary path).
- Fallback candidate search for noisy publisher names.
- Batch mode for enrichment/patch workflows.

## Tools

- `resolve_publishers_by_isbn(isbn)`
- `search_publisher_candidates(name_raw, include_no_matches=false, max_candidates=10)`
- `resolve_publisher_from_record(publisher_raw, isbn="", title="")`
- `batch_resolve_publishers(records[])`

Each tool returns explicit contract fields:
- `ok`
- `confidence` (`high|medium|low|none`)
- `evidence`
- `error` (if failed)

## Install

```bash
pip install -e .
```

or from Git:

```bash
pip install "git+https://github.com/<your-org>/fantlab-mcp.git@v0.1.0"
```

## Run

```bash
fantlab-mcp
```

Env vars:
- `FANTLAB_MCP_TRANSPORT` (`stdio` by default)
- `FANTLAB_TIMEOUT_SEC` (default `12`)
- `FANTLAB_RETRIES` (default `2`)
- `FANTLAB_CACHE_TTL_SEC` (default `43200`)

## MCP config example

```json
{
  "mcpServers": {
    "fantlab": {
      "command": "fantlab-mcp",
      "env": {
        "FANTLAB_TIMEOUT_SEC": "12",
        "FANTLAB_RETRIES": "2",
        "FANTLAB_CACHE_TTL_SEC": "43200"
      }
    }
  }
}
```

## Local smoke

```bash
python scripts/smoke_live.py
```

## Development

```bash
python -m py_compile packages/fantlab-mcp-python/src/fantlab_mcp/*.py
python -m pytest
```

## Notes

- ISBN path is authoritative: `search-editions -> edition/{id} -> creators.publishers`.
- Name-only search is fallback and should be treated as lower confidence.