Skip to content

Add ASCL tools for astrophysics code discovery#69

Open
pushwithak wants to merge 1 commit into
NASA-IMPACT:developfrom
pushwithak:add-ascl-tool
Open

Add ASCL tools for astrophysics code discovery#69
pushwithak wants to merge 1 commit into
NASA-IMPACT:developfrom
pushwithak:add-ascl-tool

Conversation

@pushwithak
Copy link
Copy Markdown

@pushwithak pushwithak commented Apr 13, 2026

Summary

Adds an MCP tool wrapping the Astrophysics Source Code Library (ASCL) for astrophysics code discovery.

Tool

ASCLSearchTool

Search ASCL by name, capability keyword, or ASCL id. Returns each code's ascl_id, title, authors (credit), abstract, all associated URLs (site_list), ADS bibcode of the ASCL record itself, ADS URLs for describing papers and papers that used the code, usage count, and view count.

The tool auto-detects id-shaped queries (1303.002, ascl:1303.002) and formats them as exact-match lookups, so one tool covers both name search and id lookup.

API quirks handled

  • PHP-serialized list fields: site_list, described_in, used_in come back as PHP-serialized strings — parsed via _parse_php_array.
  • Query quoting: The ASCL API requires q to be wrapped in quotes — returns 404 otherwise.
  • views type: comes back as a string; converted to int with a fallback to 0.

Design

  • Config: base_url (env override via ASCL_API_URL), timeout.
  • Per-request httpx.AsyncClient — matches the pattern of sde_search and the eie tools.
  • Errors returned via output.error instead of raising.
  • No shared helpers, no retry logic, no auth (ASCL is public).

Testing

tests/tools/test_ascl.py — 10 integration tests against the live ASCL API.

uv run pytest tests/tools/test_ascl.py -n0

@NISH1001
Copy link
Copy Markdown
Collaborator

@pushwithak this also has ADS as well? Could be just ASCL only PR.

@pushwithak
Copy link
Copy Markdown
Author

It was dependent since ascl was built on ads (it was using the same _helpers.py). I updated it as ASCL only.

@pushwithak
Copy link
Copy Markdown
Author

Updated. This has only ascl now.

One MCP tool wrapping the Astrophysics Source Code Library search API
(https://ascl.net/api/search/) for code discovery.

ASCLSearchTool: search ASCL for codes by name or capability, or look
up a specific entry by its ASCL id. Returns ascl_id, title, credit
(semicolon-separated authors), abstract, site_list (all URLs), bibcode
(the ASCL record's own ADS bibcode), described_in (ADS URLs for
description papers), used_in (ADS URLs for papers that used the code),
used_in_count, and views.

The tool auto-detects ASCL id-shaped queries (e.g. '1303.002',
'ascl:1303.002') and rewrites them as ascl_id:"..." for exact lookup,
so a single tool covers both name search and id lookup.

Design:
- ASCL API quirks handled inside the tool: list-valued fields
  (site_list, described_in, used_in) come back as PHP-serialized
  strings, parsed via _parse_php_array. `views` is a string and is
  converted to int.
- Query must be quoted ("...") — the API returns 404 otherwise.
- Per-request httpx.AsyncClient, errors returned via output.error,
  no retry logic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants