update_categories
Fetch and update the latest category taxonomy from arxiv.org to ensure accurate categorization and organization of research papers in the MCP server.
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:167-173 (registration)Registration of the 'update_categories' tool using the @app.tool decorator in FastMCP, including annotations for title, readOnlyHint, and openWorldHint.@app.tool( annotations={ "title": "Update arXiv Categories", "readOnlyHint": False, "openWorldHint": True } )
- mcp_simple_arxiv/server.py:174-187 (handler)The handler function for 'update_categories' tool. It calls the helper update_taxonomy_file() to refresh the taxonomy.json, then formats and returns a success message listing the 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
- Core helper function that writes the built-in CATEGORIES dictionary to taxonomy.json file and returns it. This is invoked by the tool handler to 'update' the taxonomy.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
- mcp_simple_arxiv/server.py:174-175 (schema)Function signature and docstring defining the tool's input (none) and output (str), serving as the schema.def update_categories() -> str: """Update the stored category taxonomy by fetching the latest version from arxiv.org"""