Repository avatar
Other Tools
v0.1.2
active

apiverify

io.github.kumar-miskin/apiverify

Check if a Python API exists in an exact PyPI version, from source. verified/not_found/unknown.

Documentation

apiverify

Status: 0.1.2 fixes the wrong answers that independent evaluations found in 0.1.0 and 0.1.1. A final independent retest of the supported syntax boundary passed on 69 synthetic cases (42 decisive and correct, 27 abstained, 0 wrong). That is not proof of broad reliability: on real libraries it abstained on about 49% of probes, and one class-vs-instance attribute ambiguity remains. Not compared with other tools; no evidence yet that it helps agents. 0.1.0 could return not_found for names that exist at runtime (members inherited from object, members generated by class decorators, members attached after the class body, names made via globals()/exec) and verified for conditional names (TYPE_CHECKING-only, del-ed, version-gated). 0.1.2 now answers cannot_verify for those, limits unpacking (only .py/.pyi, 100 MB total, 8 MB per file) and validates inputs. Expect many cannot_verify answers (the evaluation saw 46% abstention on lazily loaded or re-exporting libraries such as pydantic 2). Monkeypatching from a different module cannot be seen. Do not treat this as proven reliable.

Does this Python API exist in this exact package version? apiverify answers from the published source of that version, not from docs or model memory.

Three answers only:

  • verified: found in the source. Returns file, line, signature, and deprecation signals. Kind instance attribute means it is assigned on self in a method, not necessarily on the class itself.
  • not_found: every lookup path was followed and the name is absent from the release's source, within the supported syntax boundary below. This is a source-only result, not a runtime guarantee.
  • cannot_verify: the answer depends on something static analysis cannot settle (module-level __getattr__, a base class or re-export from outside the package, a file that will not parse). The agent should not assume either way.

It downloads the release from PyPI, checks the sha256 PyPI lists for it, unpacks it safely, and reads it with ast. It never imports or runs package code. No dependencies.

Use

python -m apiverify.cli requests.Session.get --version 2.31.0
python -m apiverify.cli requests.exceptions.JSONDecodeError -v 2.26.0   # not_found
python -m apiverify.cli requests.exceptions.JSONDecodeError -v 2.27.0   # verified
python -m apiverify.cli PIL.Image.open -v 10.0.0 --package pillow -k mode

Exit code: 0 verified, 1 not_found, 2 cannot_verify.

Install

pip install apiverify
uvx --from apiverify apiverify-mcp     # run the MCP server without installing (note: the package is `apiverify`; there is no package named `apiverify-mcp`)

As an MCP server (stdio)

Tool: verify_python_api with symbol, version, optional package, kwargs.

Run command (any client): uvx --from apiverify apiverify-mcp. Pin a version with apiverify==0.1.2. Needs uv installed. Config location and shape differ per client; checked against each client's docs on 2026-11-26:

  • Claude Code: claude mcp add apiverify -- uvx --from apiverify apiverify-mcp
  • Claude Desktop (claude_desktop_config.json) and Cursor (mcp.json) both use a top-level mcpServers object:
{ "mcpServers": { "apiverify": { "command": "uvx", "args": ["--from", "apiverify", "apiverify-mcp"] } } }
  • VS Code / Copilot: its config format is changing; use its guided "Add Server" flow, choose "Command (stdio)" and enter the run command above. Not tested by us.
  • Other MCP clients: add a stdio server with that command. Not tested by us.

We have only smoke-tested the server over stdio (initialize + tools/list); we have not run it inside each client above.

(From a clone you can also use python -m apiverify.mcp_server.)

Suggested line for an agent's instructions file (AGENTS.md / CLAUDE.md): "Before calling a library API you are not certain exists in the project's pinned version, call verify_python_api. Treat cannot_verify as unknown, not as yes."

Tested scope (see eval/)

Unit tests: python -m unittest discover -s tests (offline fixtures, 14 tests).

Runtime comparison: python eval/run_eval.py installs exact versions of requests (4), click (3) and flask (3), asks Python itself whether each candidate symbol exists, and compares. This is the author's own run on the cases the tool was built against, so it does not show reliability (see the warning above). Result in eval/last_run.txt: 2,411 correct, 0 false positives, 0 false negatives, 442 abstentions (all flask, mostly names re-exported from werkzeug/jinja2, which live outside the flask artifact), 2 instance attributes not scored.

Supported syntax boundary (a static checker, not a Python interpreter)

verified / not_found are only returned for plain module-level code: def, class, simple assignments, import / from ... import (including relative and star imports inside the same artifact), plain-name base classes, Class.attr = value at module level, and literal __slots__. Anything else that could add, remove or hide a name gives cannot_verify: conditional definitions (version/platform/feature checks, unless both branches define it), TYPE_CHECKING-only names, del, class or alias rebinding, class decorators, metaclasses, __getattr__, globals()/exec/eval/setattr, loops that assign attributes, and external base classes or re-exports. It cannot see another module patching the class at import time.

Limits

  • Python on PyPI only. No JavaScript, Rust or Go yet.
  • Static analysis. Names created at runtime are reported as cannot_verify, not guessed.
  • Not scored in the eval: keyword-argument checks, deprecation signals, and instance attribute results.
  • The eval's candidates mostly come from names that exist in some version, with only a few decoys per library, so it measures version differences well and hallucinated names weakly. It is three libraries, not a benchmark.
  • It has not been compared against Context7 or any retrieval tool. That comparison needs an agent harness and model spend, and is not done.
  • No evidence yet that developers would pay for it or that agents call it unprompted.
  • Needs network access to pypi.org and files.pythonhosted.org. Artifacts are cached in $APIVERIFY_CACHE.

Reaching agents

See DISTRIBUTION.md.

PYPI
apiverify
Install Command
pip install apiverify
Runtime: uvx