referenced_works_in_paper
Identify all referenced works cited in a specific academic paper using OpenAlex API data to support citation 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 handler function for the 'referenced_works_in_paper' tool. It fetches the specified paper from OpenAlex API and extracts the 'referenced_works' list, returning it as a ListResult. The @mcp.tool decorator registers it as an MCP tool.@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/schemas.py:141-144 (schema)Pydantic model used as the return type for the tool, defining the output schema as a list of strings (referenced work IDs) with a count.class ListResult(BaseModel): data: List[str] = Field(default_factory=list) count: Optional[int] = None
- src/server.py:309-309 (registration)The @mcp.tool decorator registers the function as an MCP tool.@mcp.tool