Skip to main content
Glama

Crossref MCP 服务器

用于与 Crossref API 交互的模型上下文协议 (MCP) 服务器。

特征

  • 按标题搜索作品

  • 按作者搜索作品

  • 通过 DOI 获取工作详细信息

Related MCP server: Semantic Scholar MCP Server

安装

{ "mcpServers": { "crossref": { "command": "npx", "args": [ "-y", "@botanicastudios/crossref-mcp" ] } } }

用法

该服务器提供三个主要工具:

1. 按标题搜索

在 Crossref 中按标题搜索作品:

// Example: Search for works containing "quantum computing" in the title { "title": "quantum computing", "rows": 5 // Optional, defaults to 5 }

2. 按作者搜索

在 Crossref 中按作者搜索作品:

// Example: Search for works by "Einstein" { "author": "Einstein", "rows": 5 // Optional, defaults to 5 }

3. 通过 DOI 获取作品

使用 DOI 检索特定作品:

// Example: Get work with DOI "10.1088/1742-6596/1398/1/012023" { "doi": "10.1088/1742-6596/1398/1/012023" }

响应格式

所有响应均以以下格式的结构化 JSON 对象返回:

对于成功的搜索:

{ "status": "success", "query": { /* the original query parameters */ }, "count": 5, "results": [ { "title": "Work title", "authors": [ { "given": "First name", "family": "Last name", "name": "First name Last name" } ], "published": { "dateParts": [2023, 1, 15], "dateString": "2023-1-15" }, "type": "journal-article", "doi": "10.xxxx/xxxxx", "url": "https://doi.org/10.xxxx/xxxxx", "container": "Journal Name", "publisher": "Publisher Name", "issue": "1", "volume": "42", "abstract": "This is the abstract of the work, if available." } // additional results... ] }

对于单个 DOI 查找:

{ "status": "success", "query": { "doi": "10.xxxx/xxxxx" }, "result": { // work details as shown above } }

对于错误或无结果:

{ "status": "error" | "no_results" | "not_found", "message": "Error message" | null, "query": { /* the original query parameters */ } }

测试

该服务器附带使用 Vitest 的全面测试套件。测试涵盖所有可用工具,并涵盖各种场景,包括成功响应、空结果和错误处理。

运行测试

npm test

测试结构

这些测试使用 Vitest 的模拟功能来模拟 Crossref API 响应,而无需发出实际的网络请求。测试结构包括:

  1. 模拟数据:标题搜索、作者搜索和 DOI 查找的示例响应

  2. 模拟处理程序mcp-server-test-handlers.js中的处理程序函数的测试版本

  3. 测试用例:针对所有工具的测试,涵盖:

    • 成功的 API 响应

    • 空结果集

    • 错误处理和网络故障

扩展测试

要添加更多测试用例:

  1. 如果需要,将新的模拟数据添加到测试文件

  2. 在相关的描述块中创建额外的测试用例

  3. 使用mockFetchResponse()助手来模拟 API 响应

例子:

it("should handle a new edge case", async () => { // Mock the response mockFetchResponse({ // Your sample response data }); // Call the handler const result = await handlers.searchByTitle({ title: "example" }); // Assert the expected results expect(result).toMatchObject({ // Expected response structure }); });
One-click Deploy
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/botanicastudios/crossref-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server