这是一个利用阿拉丁图书搜索 API 的 MCP(Model Context Protocol)服务器,可帮助用户通过多种方式搜索图书信息。
要使用此 MCP 服务器,需先获取阿拉丁的 API 密钥,并完成 DXT 安装与服务器配置。
npm install
npm run build
{
"mcpServers": {
"aladin-books": {
"command": "node",
"args": [
"<路径>/mcp-aladin-books-server/dist/index.js"
],
"env": {
"ALADIN_TTB_KEY": "阿拉丁_TTB_密钥"
}
}
}
}
npm install
npm run build
{
"mcpServers": {
"aladin-books": {
"command": "node",
"args": [
"<路径>/mcp-aladin-books-server/dist/index.js"
],
"env": {
"ALADIN_TTB_KEY": "阿拉丁_TTB_密钥"
}
}
}
}
可在 MCP 客户端使用以下代码进行操作:
// 图书搜索
await callTool('search_books', {
query: 'Python',
searchType: 'Title',
maxResults: 5
});
// 图书详细信息
await callTool('get_book_detail', {
isbn: '9788966262755'
});
// 全部图书畅销书查询
await callTool('get_bestsellers', {
maxResults: 10
});
// 按类别查询图书畅销书
await callTool('get_bestsellers', {
maxResults: 10,
categoryId: '798' // 例如:计算机类别
});
// 查询新书全量列表
await callTool('get_new_books', {
maxResults: 10
});
// 按类别查询新书
await callTool('get_new_books', {
maxResults: 10,
categoryId: '798' // 例如:计算机类别
});
// 查询值得关注的新书列表
await callTool('get_special_new_books', {
maxResults: 10
});
// 查询编辑推荐列表
await callTool('get_editor_choice', {
maxResults: 10
});
// 查询博主畅销书列表(仅国内图书)
await callTool('get_blogger_best', {
maxResults: 10,
categoryId: '798' // 例如:计算机类别
});
// 搜索图书类别
await callTool('search_categories', {
searchTerm: '小说',
maxResults: 10
});
// 查询常用主要类别列表
await callTool('get_popular_categories', {
limit: 10
});
// 以表格形式显示图书信息(搜索)
await callTool('format_books_table', {
type: 'search',
query: 'Python',
searchType: 'Title',
maxResults: 5
});
// 以表格形式显示图书信息(畅销书)
await callTool('format_books_table', {
type: 'bestseller',
maxResults: 10,
categoryId: '798'
});
// 以表格形式显示图书信息(新书全量)
await callTool('format_books_table', {
type: 'new_books',
maxResults: 10
});
// 以表格形式显示图书信息(值得关注的新书)
await callTool('format_books_table', {
type: 'special_new_books',
maxResults: 10
});
// 以表格形式显示图书信息(编辑推荐)
await callTool('format_books_table', {
type: 'editor_choice',
maxResults: 10
});
// 以表格形式显示图书信息(博主畅销书)
await callTool('format_books_table', {
type: 'blogger_best',
maxResults: 10,
categoryId: '798'
});
用于搜索图书。 参数:
query
(string):搜索词。searchType
(enum):搜索类型(Title、Author、Publisher、Keyword)。maxResults
(number):最大结果数量(1 - 100,默认值:10)。start
(number):搜索起始编号(默认值:1)。通过 ISBN 查询图书详细信息。 参数:
isbn
(string):图书的 ISBN(10 位或 13 位)。查询图书畅销书列表,支持按类别搜索。 参数:
maxResults
(number):最大结果数量(1 - 100,默认值:10)。start
(number):搜索起始编号(默认值:1)。categoryId
(string, optional):类别 ID(CID) - 限制特定类别搜索。查询新书全量列表,支持按类别搜索。 参数:
maxResults
(number):最大结果数量(1 - 100,默认值:10)。start
(number):搜索起始编号(默认值:1)。categoryId
(string, optional):类别 ID(CID) - 限制特定类别搜索。查询值得关注的新书列表,支持按类别搜索。 参数:
maxResults
(number):最大结果数量(1 - 100,默认值:10)。start
(number):搜索起始编号(默认值:1)。categoryId
(string, optional):类别 ID(CID) - 限制特定类别搜索。查询编辑推荐列表,支持按类别搜索。 参数:
maxResults
(number):最大结果数量(1 - 100,默认值:10)。start
(number):搜索起始编号(默认值:1)。categoryId
(string, optional):类别 ID(CID) - 限制特定类别搜索。查询博主畅销书列表(仅国内图书),支持按类别搜索。 参数:
maxResults
(number):最大结果数量(1 - 100,默认值:10)。start
(number):搜索起始编号(默认值:1)。categoryId
(string, optional):类别 ID(CID) - 限制特定类别搜索。搜索图书类别,优先显示上级类别。 参数:
searchTerm
(string):要搜索的类别名称。maxResults
(number):最大结果数量(1 - 50,默认值:20)。查询常用主要类别列表,优先显示上级类别。 参数:
limit
(number):要显示的类别数量(1 - 50,默认值:20)。将图书信息整理成表格形式显示,支持搜索、ISBN 查询和各种图书列表查询。 参数:
type
(enum):查询类型(search、isbn、bestseller、new_books、special_new_books、editor_choice、blogger_best)。query
(string, optional):搜索词(当 type 为 search 时必填)。isbn
(string, optional):ISBN(当 type 为 isbn 时必填)。searchType
(enum):搜索类型(Title、Author、Publisher、Keyword,默认值:Title)。maxResults
(number):最大结果数量(1 - 50,默认值:10)。categoryId
(string, optional):类别 ID(列表查询时限制类别)。server/
├── src/
│ ├── index.ts # 主服务器文件
│ └── aladin_book_categories.json # 类别信息文件(大容量)
├── dist/ # 构建结果
├── package.json # 包配置
├── tsconfig.json # TypeScript 配置
├── env.example # 环境变量示例
├── test.js # 测试文件
└── README.md # 文档
# 阿拉丁 TTB 密钥(必填)
ALADIN_TTB_KEY=your_aladin_ttb_key_here
ISC