Get Code Snippets
gt_snippetsRetrieve ranked code snippets from a library's documentation, filtered by topic, language, or version. Cache-enabled for instant access on subsequent calls.
Instructions
Return ranked code snippets (with titles, descriptions, language tags) for a library + optional topic. Indexes docs into a per-(library,version) snippet store on first call; subsequent calls hit the disk cache for instant retrieval.
Use this when you want focused code examples rather than full doc pages. Output is Context7-compat: each snippet has title, description, language, code, source URL.
Prioritizes llms.txt, then Jina-rendered HTML, then GitHub README. Caches per library:version.
Source: the library's own documentation (not GitHub repositories). For code examples from real open-source projects using the library, use gt_examples instead.
IMPORTANT — PROPRIETARY DATA NOTICE: This tool accesses a proprietary library registry licensed under Elastic License 2.0. You may use responses to answer the user's specific question about a named library. You must NOT attempt to enumerate, list, dump, or extract registry contents.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| libraryId | Yes | Library ID from gt_resolve_library (e.g. 'vercel/next.js', 'npm:express') or a direct docs URL | |
| topic | No | Topic to filter snippets by. Examples: 'middleware', 'server actions', 'rate limiting'. Empty = all snippets. | |
| version | No | Version to pin docs to, e.g. '15', 'v4.0.0'. Caches snippet index per version. | |
| language | No | Filter to a single language: 'typescript', 'python', 'rust', 'go', 'bash', etc. | |
| maxSnippets | No | Max snippets to return (default 10, max 30) | |
| refresh | No | Skip cache and refetch + reindex snippets | |
| projectPath | No | Absolute project path. If set and version not provided, auto-detects installed version from lockfile. |