update_categories
Fetch and update the arXiv paper category taxonomy to ensure accurate classification of research documents.
Instructions
Update the stored category taxonomy by fetching the latest version from arxiv.org
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_simple_arxiv/server.py:174-186 (handler)The main handler function for the update_categories tool, which invokes the helper to update the taxonomy file and returns a formatted success message listing primary categories.def update_categories() -> str: """Update the stored category taxonomy by fetching the latest version from arxiv.org""" try: taxonomy = update_taxonomy_file() result = "Successfully updated category taxonomy.\n\n" result += f"Found {len(taxonomy)} primary categories:\n" for primary, data in taxonomy.items(): result += f"- {primary}: {data['name']} ({len(data['subcategories'])} subcategories)\n" return result except Exception as e: logger.error(f"Error updating taxonomy: {e}") # FastMCP will handle raising this as a proper JSON-RPC error raise e
- mcp_simple_arxiv/server.py:167-173 (registration)Registers the 'update_categories' tool in the FastMCP app with metadata annotations including title and operational hints.@app.tool( annotations={ "title": "Update arXiv Categories", "readOnlyHint": False, "openWorldHint": True } )
- Supporting function that generates and persists the arXiv category taxonomy to a JSON file from built-in data, used by the tool handler.def update_taxonomy_file(): """ Create taxonomy.json from the built-in categories. Returns the taxonomy dictionary. """ print(f"Creating taxonomy file at {TAXONOMY_FILE}...") with open(TAXONOMY_FILE, 'w', encoding='utf-8') as f: json.dump(CATEGORIES, f, indent=2, ensure_ascii=False) print("Done!") return CATEGORIES