Skip to main content
Glama

Get Code Snippets

gt_snippets
Read-onlyIdempotent

Return code snippets from library documentation, filtered by topic, language, or version. Indexes docs on first call and caches for quick retrieval.

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

TableJSON Schema
NameRequiredDescriptionDefault
libraryIdYesLibrary ID from gt_resolve_library (e.g. 'vercel/next.js', 'npm:express') or a direct docs URL
topicNoTopic to filter snippets by. Examples: 'middleware', 'server actions', 'rate limiting'. Empty = all snippets.
versionNoVersion to pin docs to, e.g. '15', 'v4.0.0'. Caches snippet index per version.
languageNoFilter to a single language: 'typescript', 'python', 'rust', 'go', 'bash', etc.
maxSnippetsNoMax snippets to return (default 10, max 30)
refreshNoSkip cache and refetch + reindex snippets
projectPathNoAbsolute project path. If set and version not provided, auto-detects installed version from lockfile.
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already provide readOnlyHint=true, destructiveHint=false, idempotentHint=true. The description adds that it caches per library:version, indexes on first call, and prioritizes specific sources. It also includes a proprietary data notice. No contradictions. The description adds meaningful behavioral context beyond annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the main purpose, then provides usage guidance, a sibling distinction, and a legal notice. Each sentence adds value, though the proprietary notice could be considered slightly verbose. Overall, it is well-structured and reasonably concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers the tool's purpose, usage guidelines, behavioral nuances (caching, source prioritization), and output structure (title, description, language, code, source URL). With 7 parameters and no output schema, this is adequate. It could potentially include more detail about ranking or error cases, but it's sufficient for most use cases.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so all parameters have descriptions. The tool description itself does not add additional parameter-level details beyond the schema. The baseline score of 3 is appropriate because the schema already provides clear semantics for each parameter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Return ranked code snippets' and specifies the resource (library + optional topic). It distinguishes from sibling 'gt_examples' by noting that this tool uses library documentation rather than real-world projects. This provides a specific verb and resource, with sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly says 'Use this when you want focused code examples rather than full doc pages' and 'For code examples from real open-source projects using the library, use gt_examples instead.' It also notes the source prioritization (llms.txt, Jina, README). This provides clear when-to-use and when-not-to-use guidance with a named alternative.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rm-rf-prod/GroundTruth-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server