mcp-open-library
MCP Open Library
一个用于 Open Library API 的模型上下文协议 (MCP) 服务器,使 AI 助手能够搜索图书和作者信息。
概述
本项目实现了一个 MCP 服务器,为 AI 助手提供与 Open Library 交互的工具。它允许通过书名搜索图书信息、通过姓名搜索作者、使用 Open Library 键检索详细的作者信息,以及使用 Open Library ID (OLID) 获取作者照片的 URL。服务器返回图书和作者信息的结构化数据。
Related MCP server: bookstore-mcp-server
功能
按书名搜索图书:使用书名搜索图书 (
get_book_by_title)。按姓名搜索作者:使用姓名搜索作者 (
get_authors_by_name)。获取作者详情:使用 Open Library 键检索特定作者的详细信息 (
get_author_info)。获取作者照片:使用 Open Library ID (OLID) 获取作者照片的 URL (
get_author_photo)。获取图书封面:使用各种标识符(ISBN、OCLC、LCCN、OLID、ID)获取图书封面图片的 URL (
get_book_cover)。按 ID 获取图书:使用各种标识符(ISBN、LCCN、OCLC、OLID)检索详细的图书信息 (
get_book_by_id)。
安装
通过 Smithery 安装
要通过 Smithery 自动为 Claude Desktop 安装 MCP Open Library:
npx -y @smithery/cli install @8enSmith/mcp-open-library --client claude手动安装
# Clone the repository
git clone https://github.com/8enSmith/mcp-open-library.git
cd mcp-open-library
# Install dependencies
npm install
# Build the project
npm run build使用方法
运行服务器
确保您运行的是 node v22.21.1(它可能在较新版本的 node 上也能工作,但我测试时使用的是这个版本)。如果您安装了
nvm,请运行nvm use。在
mcp-open-library根目录下运行npm run build接下来运行
npm run inspector。构建完成后,点击带有MCP_PROXY_AUTH_TOKEN查询字符串参数的 URL 以打开检查器。在检查器中,选择 'STDIO' 传输方式
确保命令设置为 'build/index.js'
点击检查器中的 'Connect' 按钮 - 您现在将连接到服务器
点击右上角菜单栏中的 'Tools'
尝试运行一个工具,例如点击 get_book_by_title
搜索一本书,例如在书名框中输入 'The Hobbit',然后点击 'Run Tool'。服务器随后将返回图书详情。
与 MCP 客户端配合使用
此服务器实现了模型上下文协议,这意味着它可以被任何兼容 MCP 的 AI 助手或客户端使用,例如 Claude Desktop。服务器公开了以下工具:
get_book_by_title:按书名搜索图书信息get_authors_by_name:按姓名搜索作者信息get_author_info:使用 Open Library 作者键获取特定作者的详细信息get_author_photo:使用 Open Library 作者 ID (OLID) 获取作者照片的 URLget_book_cover:使用特定标识符(ISBN、OCLC、LCCN、OLID 或 ID)获取图书封面图片的 URLget_book_by_id:使用特定标识符(ISBN、LCCN、OCLC 或 OLID)获取详细的图书信息
get_book_by_title 输入示例:
{
"title": "The Hobbit"
}get_book_by_title 输出示例:
[
{
"title": "The Hobbit",
"authors": [
"J. R. R. Tolkien"
],
"first_publish_year": 1937,
"open_library_work_key": "/works/OL45883W",
"edition_count": 120,
"cover_url": "https://covers.openlibrary.org/b/id/10581294-M.jpg"
}
]get_authors_by_name 输入示例:
{
"name": "J.R.R. Tolkien"
}get_authors_by_name 输出示例:
[
{
"key": "OL26320A",
"name": "J. R. R. Tolkien",
"alternate_names": [
"John Ronald Reuel Tolkien"
],
"birth_date": "3 January 1892",
"top_work": "The Hobbit",
"work_count": 648
}
]get_author_info 输入示例:
{
"author_key": "OL26320A"
}get_author_info 输出示例:
{
"name": "J. R. R. Tolkien",
"personal_name": "John Ronald Reuel Tolkien",
"birth_date": "3 January 1892",
"death_date": "2 September 1973",
"bio": "John Ronald Reuel Tolkien (1892-1973) was a major scholar of the English language, specializing in Old and Middle English. He served as the Rawlinson and Bosworth Professor of Anglo-Saxon and later the Merton Professor of English Language and Literature at Oxford University.",
"alternate_names": ["John Ronald Reuel Tolkien"],
"photos": [6791763],
"key": "/authors/OL26320A",
"remote_ids": {
"viaf": "95218067",
"wikidata": "Q892"
},
"revision": 43,
"last_modified": {
"type": "/type/datetime",
"value": "2023-02-12T05:50:22.881"
}
}get_author_photo 输入示例:
{
"olid": "OL26320A"
}get_author_photo 输出示例:
https://covers.openlibrary.org/a/olid/OL26320A-L.jpgget_book_cover 输入示例:
{
"key": "ISBN",
"value": "9780547928227",
"size": "L"
}get_book_cover 输出示例:
https://covers.openlibrary.org/b/isbn/9780547928227-L.jpgget_book_cover 工具接受以下参数:
key:标识符类型(可选值:ISBN、OCLC、LCCN、OLID或ID)value:标识符的值size:可选的封面尺寸(S为小,M为中,L为大,默认为L)
get_book_by_id 输入示例:
{
"idType": "isbn",
"idValue": "9780547928227"
}get_book_by_id 输出示例:
{
"title": "The Hobbit",
"authors": [
"J. R. R. Tolkien"
],
"publishers": [
"Houghton Mifflin Harcourt"
],
"publish_date": "October 21, 2012",
"number_of_pages": 300,
"isbn_13": [
"9780547928227"
],
"isbn_10": [
"054792822X"
],
"oclc": [
"794607877"
],
"olid": [
"OL25380781M"
],
"open_library_edition_key": "/books/OL25380781M",
"open_library_work_key": "/works/OL45883W",
"cover_url": "https://covers.openlibrary.org/b/id/8231496-M.jpg",
"info_url": "https://openlibrary.org/books/OL25380781M/The_Hobbit",
"preview_url": "https://archive.org/details/hobbit00tolkien"
}get_book_by_id 工具接受以下参数:
idType:标识符类型(可选值:isbn、lccn、oclc、olid)idValue:标识符的值
可以在此处查看此工具在 Claude Desktop 中使用的示例:
Docker
您可以使用 Docker 测试此 MCP 服务器。为此,请先运行:
docker build -t mcp-open-library .
docker run -p 8080:8080 mcp-open-library然后,您可以通过检查器测试在 Docker 中运行的服务器,例如:
npm run inspector http://localhost:8080开发
项目结构
src/index.ts- 服务器主实现src/types.ts- TypeScript 类型定义src/index.test.ts- 测试套件
可用脚本
npm run build- 构建 TypeScript 代码npm run watch- 监视更改并重新构建npm test- 运行测试套件npm run format- 使用 Prettier 格式化代码npm run inspector- 针对服务器运行 MCP 检查器
运行测试
npm test贡献
欢迎贡献!请随时提交拉取请求。
致谢
Available Tools
7 toolsget_author_infoGet author detailsARead-only
Get detailed information for a specific author using their Open Library Author Key (e.g. OL23919A).
Inputs: author_key (required).
get_author_photoGet author photo URLARead-only
Get the URL for an author's photo using their Open Library Author ID (OLID e.g. OL23919A). Reports when no photo exists rather than returning a URL to a blank placeholder.
Inputs: olid (required).
get_authors_by_nameFind authors by nameARead-only
Search for author information on Open Library. Returns at most limit authors (default 10) together with num_found, the total number of matches; page through them with offset. Each result's key can be passed to get_author_info for that author's full record.
Inputs: name (required), limit, offset.
get_book_by_idGet book by identifierARead-only
Get detailed information about a book using its identifier (ISBN, LCCN, OCLC, OLID).
Inputs: idType (required), idValue (required).
get_book_by_titleFind books by titleARead-only
Search for a book by its title on Open Library. Returns at most limit results (default 10) together with num_found, the total number of matches; page through them with offset. Each result carries best_edition — one edition of the work, with its isbn_13/isbn_10 where Open Library has them, and its edition_key, which can be passed to get_book_by_id as { idType: "olid" } for that edition's full record.
Inputs: title (required), limit, offset.
get_book_coverGet book cover URLARead-only
Get the URL for a book's cover image using a key (ISBN, OCLC, LCCN, OLID, ID) and value. Reports when no cover exists rather than returning a URL to a blank placeholder.
Inputs: key (required), value (required), size.
search_booksSearch booksARead-only
Search Open Library across titles, authors, subjects, places, people, publishers and ISBNs. Provide at least one search criterion: q, title, author, subject, place, person, publisher, isbn; combining several narrows the search. Returns at most limit results (default 10) together with num_found, the total number of matches; page through them with offset. Each result carries best_edition — one edition of the work, with its isbn_13/isbn_10 where Open Library has them, and its edition_key, which can be passed to get_book_by_id as { idType: "olid" } for that edition's full record.
Inputs: q, isbn, sort, limit, +8 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Most tools are clearly separated by resource and action, but get_book_by_title overlaps heavily with search_books since it returns the same result structure and is essentially a subset of the general search. The book/author detail and cover/photo tools are unambiguous.
Naming mostly follows a consistent get_<resource>_by_<qualifier> pattern, e.g. get_book_by_id, get_book_by_title, get_author_photo. search_books breaks the get_ convention but remains readable and predictable alongside the others.
Seven tools is well-scoped for a read-only Open Library server. Each tool addresses a distinct lookup need without the collection feeling bloated or thin.
The surface covers general book search, book lookup by ID/title, author search, author details, author photos, and book covers. Minor gaps exist, such as no direct endpoint for works or edition lists beyond indirection through edition_key, but core reading workflows are covered.
Maintenance
Related MCP Connectors
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
The Mercado Pago MCP Server implements the Model Context Protocol to provide AI agents and LLMs with access to Mercado Pago's APIs and tools within compatible development environments. It acts as an intermediary that translates Mercado Pago resources into executable functions (tools) that AI applications can invoke to perform actions and automate flows. The server simplifies integration, enables using documentation to implement or improve code, and optimizes operations through natural language interactions without manual implementations.
A Model Context Protocol server for Wix AI tools
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
Related MCP Servers
- FlicenseBqualityDmaintenanceA Model Context Protocol server implementation that can be run directly or through Docker, enabling AI assistants to interact with external systems through the MCP standard.2-
- FlicenseNot gradedqualityDmaintenanceAn MCP server that exposes tools for querying a bookstore inventory, allowing AI agents to search and retrieve book information via the Model Context Protocol.1-
- AlicenseNot gradedqualityBmaintenanceAn MCP server that enables searching books and authors, fetching editions, browsing subjects, and resolving cover images from Open Library.267 npm4Apache 2.0
- AlicenseNot gradedqualityCmaintenanceMCP server for Google Books API, enabling volume details, ISBN lookup, and bookshelf access via natural language queries.88 npm1MIT