add_to_library
Add selected papers to an existing NASA ADS library by providing the library ID and bibcodes to organize astronomical research collections.
Instructions
Add papers to an existing library. Provide library ID and list of bibcodes to add.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| library_id | Yes | Library ID (from list_libraries) | |
| bibcodes | Yes | List of bibcodes to add to the library |
Implementation Reference
- src/nasa_ads_mcp/server.py:771-797 (handler)The core handler function that executes the tool: sends POST request to ADS API to add bibcodes to the specified library.async def add_to_library(library_id: str, bibcodes: list[str]) -> list[TextContent]: """Add papers to a library.""" try: payload = { "bibcode": bibcodes, "action": "add" } response = requests.post( f"{ADS_API_BASE}/biblib/documents/{library_id}", headers=HEADERS, json=payload, timeout=30 ) response.raise_for_status() return [TextContent( type="text", text=f"✓ Added {len(bibcodes)} paper(s) to library {library_id}" )] except Exception as e: logger.error(f"Error adding to library: {e}") return [TextContent( type="text", text=f"Error adding to library: {str(e)}" )]
- src/nasa_ads_mcp/server.py:236-257 (registration)Tool registration in list_tools(), including name, description, and input schema definition.Tool( name="add_to_library", description=( "Add papers to an existing library. " "Provide library ID and list of bibcodes to add." ), inputSchema={ "type": "object", "properties": { "library_id": { "type": "string", "description": "Library ID (from list_libraries)", }, "bibcodes": { "type": "array", "items": {"type": "string"}, "description": "List of bibcodes to add to the library", }, }, "required": ["library_id", "bibcodes"], }, ),
- src/nasa_ads_mcp/server.py:307-311 (registration)Dispatch logic in the central call_tool() function that invokes the add_to_library handler with parsed arguments.elif name == "add_to_library": return await add_to_library( library_id=arguments["library_id"], bibcodes=arguments["bibcodes"] )
- src/nasa_ads_mcp/server.py:242-256 (schema)Input schema definition for the tool, specifying required parameters library_id and bibcodes.inputSchema={ "type": "object", "properties": { "library_id": { "type": "string", "description": "Library ID (from list_libraries)", }, "bibcodes": { "type": "array", "items": {"type": "string"}, "description": "List of bibcodes to add to the library", }, }, "required": ["library_id", "bibcodes"], },