referenced_works_in_paper
Retrieve the list of works cited in a specific academic paper using the OpenAlex API to support research analysis and literature review.
Instructions
Gets referenced works used in the specified paper using the OpenAlex API. Note: May return empty if the paper's full text is inaccessible.
Args: paper_id: An OpenAlex Work ID of the target paper. e.g., "https://openalex.org/W123456789"
Returns: A JSON object containing a list of paper ids used in the work, or an error message if the fetch fails.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paper_id | Yes |
Implementation Reference
- src/server.py:309-349 (handler)The main handler function for the 'referenced_works_in_paper' tool. It is decorated with @mcp.tool, which also serves as the registration. Fetches the paper details from OpenAlex API using the provided paper_id and extracts/returns the list of referenced works.@mcp.tool async def referenced_works_in_paper( paper_id: str, ) -> ListResult: """ Gets referenced works used in the specified paper using the OpenAlex API. Note: May return empty if the paper's full text is inaccessible. Args: paper_id: An OpenAlex Work ID of the target paper. e.g., "https://openalex.org/W123456789" Returns: A JSON object containing a list of paper ids used in the work, or an error message if the fetch fails. """ # Fetches search results from the OpenAlex API async with RequestAPI("https://api.openalex.org", default_params={"mailto": OPENALEX_MAILTO}) as api: logger.info(f"Fetching referenced works for paper_id={paper_id}") try: result = await api.aget(f"/works/{paper_id}") # Returns a message for when the search results are empty if result is None or len(result.get("referenced_works", []) or []) == 0: error_message = f"No referenced works found for paper_id={paper_id}." logger.info(error_message) raise ToolError(error_message) # Successfully returns the searched papers works = result.get("referenced_works", []) or [] success_message = f"Retrieved {len(works)} referenced works for paper_id={paper_id}." logger.info(success_message) return ListResult(data=works, count=len(works)) except httpx.HTTPStatusError as e: error_message = f"Request failed with status: {e.response.status_code}" logger.error(error_message) raise ToolError(error_message) except httpx.RequestError as e: error_message = f"Network error: {str(e)}" logger.error(error_message) raise ToolError(error_message)
- src/server.py:309-309 (registration)The @mcp.tool decorator registers the 'referenced_works_in_paper' tool with the FastMCP server.@mcp.tool