extract_info
Search for specific paper details across all topic directories using a paper ID. Returns JSON-formatted research information or an error if not found.
Instructions
Search for information about a specific paper across all topic directories.
Args: paper_id: The ID of the paper to look for
Returns: JSON string with paper information if found, error message if not found
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| paper_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- research_server.py:72-98 (handler)The extract_info tool handler function that searches for information about a specific paper across all topic directories in the papers folder. It iterates through topic directories, reads papers_info.json files, and returns the paper information as a JSON string if found.
@mcp.tool() def extract_info(paper_id: str) -> str: """ Search for information about a specific paper across all topic directories. Args: paper_id: The ID of the paper to look for Returns: JSON string with paper information if found, error message if not found """ for item in os.listdir(PAPER_DIR): item_path = os.path.join(PAPER_DIR, item) if os.path.isdir(item_path): file_path = os.path.join(item_path, "papers_info.json") if os.path.isfile(file_path): try: with open(file_path, "r") as json_file: papers_info = json.load(json_file) if paper_id in papers_info: return json.dumps(papers_info[paper_id], indent=2) except (FileNotFoundError, json.JSONDecodeError) as e: print(f"Error reading {file_path}: {str(e)}") continue return f"There's no saved information related to paper {paper_id}." - research_server.py:72-73 (registration)The @mcp.tool() decorator registers the extract_info function as an MCP tool with the FastMCP server.
@mcp.tool() def extract_info(paper_id: str) -> str: - research_server.py:73-73 (schema)Type hints defining the input schema (paper_id: str) and output schema (-> str) for the extract_info tool.
def extract_info(paper_id: str) -> str: - research_server_L-5.py:73-99 (handler)Alternative/backup implementation of the extract_info tool handler function in the L-5 version file. Identical logic to research_server.py - searches for paper information across topic directories.
@mcp.tool() def extract_info(paper_id: str) -> str: """ Search for information about a specific paper across all topic directories. Args: paper_id: The ID of the paper to look for Returns: JSON string with paper information if found, error message if not found """ for item in os.listdir(PAPER_DIR): item_path = os.path.join(PAPER_DIR, item) if os.path.isdir(item_path): file_path = os.path.join(item_path, "papers_info.json") if os.path.isfile(file_path): try: with open(file_path, "r") as json_file: papers_info = json.load(json_file) if paper_id in papers_info: return json.dumps(papers_info[paper_id], indent=2) except (FileNotFoundError, json.JSONDecodeError) as e: print(f"Error reading {file_path}: {str(e)}") continue return f"There's no saved information related to paper {paper_id}."