Skip to main content

z3950-mcp

CI PyPI License: MIT

Install in Claude Desktop Install in Cursor Install in VS Code

Install YAZ firstbrew install yaz (macOS) or apt-get install yaz (Debian/Ubuntu). Z39.50 is spoken by yaz-client, a system binary no installer can ship; the buttons install the server around it. Without YAZ the server still starts and every search returns an explicit yaz-client not found error.

A desktop app does not inherit your shell's PATH, so the server also looks in Homebrew's usual locations on its own. If YAZ lives somewhere unusual, point YAZ_CLIENT at the binary (the Claude Desktop installer offers a field for it).

An MCP server that lets an AI assistant search library catalogs over Z39.50 and get back structured MARC 21 records.

It talks to catalogs through YAZ (yaz-client) and parses the returned records with pymarc, so you get clean, standards-based bibliographic data — not scraped HTML.

Why

Most Polish (and international) library OPACs — Prolib/Integro, Virtua, Aleph, Alma, Koha — expose a Z39.50 server, the decades-old library-standard search protocol. It returns MARC 21, which is far more reliable to consume than scraping a web catalog. This server puts that behind two simple MCP tools.

Requirements

  • Python ≥ 3.10
  • The YAZ toolkit (yaz-client):
    • macOS: brew install yaz
    • Debian/Ubuntu: apt-get install yaz

The binary is looked up on PATH first, then in /opt/homebrew/bin and /usr/local/bin. Those two exist because a desktop MCP host — Claude Desktop, Cursor — is launched from the GUI and inherits launchd's PATH (/usr/bin:/bin:/usr/sbin:/sbin), which contains no Homebrew: without the fallback, a correctly installed YAZ would still look missing.

Set YAZ_CLIENT to an absolute path to override the search entirely. A value that is not executable is an error rather than a reason to keep looking — otherwise a typo would surface much later as a confusing "not found".

Install

git clone https://github.com/mpasternak/z3950-mcp
cd z3950-mcp
uv sync

Tools

list_targets()

Lists the preconfigured catalogs — see Public Z39.50 resources below. Each entry's key can be passed to search.

search(target, query, by="any", start=1, count=5, include_raw_marc=false)

Searches a catalog and returns parsed MARC records.

  • target — a registry key above, or an ad-hoc host:port/database string.
  • by — index to search: any, title, author, subject, isbn, issn, publisher, year, lccn, id, or pqf to pass query through as a raw PQF query.
  • count — how many records to return (max 50). Use count=1 with a narrow query (e.g. by ISBN) to fetch a single full record.
  • include_raw_marc — also include the full MARC record as text.

Example result for search("bn", "Pan Tadeusz", by="title", count=1):

{
  "target": "bn-nl.alma.exlibrisgroup.com:1921/48OMNIS_NLOP",
  "query": "@attr 1=4 \"Pan Tadeusz\"",
  "hits": 1406,
  "returned": 1,
  "records": [
    {
      "control_number": "991000041299705066",
      "title": "Pan Tadeusz czyli Ostatni zajazd na Litwie : historia szlachecka...",
      "author": "Mickiewicz, Adam (1798-1855)",
      "year": "1994",
      "isbn": ["8370010938"],
      "publisher": "\"Alfa-Wero\"",
      "language": "pol",
      "subjects": ["Poezja polska -- 19 w."]
    }
  ]
}

Public Z39.50 resources

Catalogs below were verified reachable (2026-07) — they return live MARC 21. Ones with a key are built in (search("bn", …)); the rest you pass as an ad-hoc host:port/database.

Polish

key library connection
bn Biblioteka Narodowa bn-nl.alma.exlibrisgroup.com:1921/48OMNIS_NLOP

The National Library has the broadest Polish holdings. Most other Polish libraries expose Z39.50 only through the KaRo federation and don't publish their host/port openly — to find more:

English / international

key library connection
loc Library of Congress (Voyager) z3950.loc.gov:7090/VOYAGER
loc-lcdb Library of Congress (LCDB) lx2.loc.gov:210/LCDB
nkc Národní knihovna ČR aleph.nkp.cz:9991/NKC
demo Index Data demo (test) z3950.indexdata.com:210/marc

The Library of Congress also serves a MARC-8 database at lx2.loc.gov:210/LCDB_MARC8 (pymarc transcodes it to Unicode). The Index Data server is a tiny demo database, handy for testing this MCP without hitting a real library.

Examples

search("demo", "computer")                           # tiny test database — smoke test
search("bn", "Lem Solaris")                          # Polish National Library
search("loc", "9780262033848", by="isbn")            # Library of Congress, by ISBN
search("nkc", "Kafka", by="author", count=3)         # Czech National Library
search("aleph.nkp.cz:9991/NKC", "Švejk")             # same, as an ad-hoc target

Use with Claude Code / Claude Desktop

Claude Code (CLI)

Register the server with claude mcp add. The -s user scope makes it available in all your projects; drop it for the current project only.

Straight from the public repo (no clone needed):

claude mcp add z3950 -s user -- uvx --from git+https://github.com/mpasternak/z3950-mcp z3950-mcp

From PyPI once released:

claude mcp add z3950 -s user -- uvx z3950-mcp

From a local checkout (for development):

claude mcp add z3950 -s user -- uv run --directory /path/to/z3950-mcp z3950-mcp

Remove it again with claude mcp remove z3950 -s user.

Claude Desktop (JSON config)

Add to claude_desktop_config.json (stdio transport):

{
  "mcpServers": {
    "z3950": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/mpasternak/z3950-mcp", "z3950-mcp"]
    }
  }
}

Adding catalogs

Append a Target(...) to _TARGETS in src/z3950_mcp/targets.py, or just pass an ad-hoc host:port/database to search. Finding a library's Z39.50 coordinates: the IRSpy registry lists many; some (e.g. NUKAT) provide them on request.

Development

uv run pytest              # unit tests (offline)
uv run pytest -m integration   # live tests against BN + LoC (network + yaz)
uv run ruff check .

Releasing

Releases publish to PyPI via Trusted Publishing (OIDC — no API tokens). Publishing a GitHub Release (or pushing a v* tag) triggers .github/workflows/publish.yml, which builds and uploads from the pypi environment. The PyPI project must have a matching trusted publisher (repo mpasternak/z3950-mcp, workflow publish.yml, environment pypi).

License

MIT — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

z3950_mcp-0.1.2.tar.gz (86.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

z3950_mcp-0.1.2-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file z3950_mcp-0.1.2.tar.gz.

File metadata

  • Download URL: z3950_mcp-0.1.2.tar.gz
  • Upload date:
  • Size: 86.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for z3950_mcp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9ae0224f755d09d0655818bbb9f05d263931719f0e388f7a018210ab1fdee2d4
MD5 94cc35e33791b69d89a1cf4709c48472
BLAKE2b-256 333f8d07e1e48caa2366849a779537d0e902d9878a2cf7e3eb5da709b97ba5f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for z3950_mcp-0.1.2.tar.gz:

Publisher: publish.yml on mpasternak/z3950-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file z3950_mcp-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: z3950_mcp-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for z3950_mcp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c805c1362b6027abae2f5b0772d84c64233c1e9a77824d8e5e34f71f9b9fa556
MD5 957760d2e011c1039a5db9bf25316451
BLAKE2b-256 0a72fd817bcc563b93251a729a86fbcefc254398e6deb5be5eec20aa75af9d98

See more details on using hashes here.

Provenance

The following attestation bundles were made for z3950_mcp-0.1.2-py3-none-any.whl:

Publisher: publish.yml on mpasternak/z3950-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page