apiverify
<!-- mcp-name: io.github.kumar-miskin/apiverify -->
# 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 # or: uvx apiverify-mcp (MCP server)
```
## As an MCP server (stdio)
Tool: `verify_python_api` with `symbol`, `version`, optional `package`, `kwargs`.
```json
{ "mcpServers": { "apiverify": { "command": "uvx", "args": ["--from", "apiverify", "apiverify-mcp"] } } }
```
(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`.
TDQS
Scored across 1 tool
There is only one tool, so there is nothing to confuse it with. Its purpose—checking whether a named Python symbol exists in an exact released PyPI version—is stated precisely, including the meaning of each of the three return statuses.
The single name `verify_python_api` follows a clear verb_noun snake_case convention. With one tool there is no opportunity for convention drift, and the name reads unambiguously.
One tool is thin in absolute terms, but the server's scope is deliberately narrow (verify a single symbol against one pinned release), so a single entry point is defensible rather than a mismatch. It stops short of 5 only because a minimal second surface (e.g. listing available names or versions) would round out the workflow.
The tool covers the full lifecycle of its stated purpose: input a package, version and symbol, and receive verified/not_found/cannot_verify with supporting location data. Minor gaps exist—no batch verification and no way to enumerate exported names or discover valid versions—but agents can work around these by issuing repeated calls.