How to stop Claude hallucinating APIs for a library it half-knows
When to use: You're integrating a library and Claude keeps inventing method names that don't exist.
Prerequisites
- Know the library's GitHub path — e.g.
pydantic/pydantic-ai— paste the owner/repo into gitmcp.io
Flow
-
Add GitMCP pointed at the libraryAdd the GitMCP server for
pydantic/pydantic-aito my config, then list the top-level docs files.✓ Copied→ Tool returns README.md plus /docs tree — no fabricated paths -
Ask against real sourceUsing the GitMCP for pydantic-ai, show me the actual constructor signature for
Agent— quote it from source, don't summarize.✓ Copied→ Exact signature with source file + line ref -
Verify by runningWrite a minimal runnable example using only what you saw in the repo. If something is missing, say so — don't guess.✓ Copied→ Example compiles; Claude flags any missing pieces
Outcome: Working integration that matches the library's actual API, not a plausible-sounding fiction.
Pitfalls
- Library is in a monorepo subdirectory — Use the
treetool first to find the right package root before reading