Skip to main content
Glama

Get Code Snippets

gt_snippets
Read-onlyIdempotent

Fetch ranked code snippets from a library’s official docs by topic and language; cached per version with refresh to re-index. Solves finding relevant examples without guessing.

Instructions

Ranked code snippets (title, language, code, source URL) from a library's own docs, by topic and language. Cached per version; refresh:true re-indexes. Prose docs: gt_get_docs. Real-project usage: gt_examples.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "libraryId": "<libraryId>"
    },
    "name": "gt_snippets"
  }
}

Input Schema

NameRequiredDescriptionDefault
topicNoFilter, e.g. 'middleware'. Empty = all.
refreshNoRe-fetch and re-index
versionNoe.g. '15'
languageNoe.g. 'typescript'
libraryIdYesPlain name, GroundTruth ID, or docs URL
maxSnippetsNo
projectPathNoProject root, to read the installed version

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changedv8.1.1
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • changedInput schema / properties / language / description
      Previous value: -"Filter to a single language: 'typescript', 'python', 'rust', 'go', 'bash', etc."New value: +"e.g. 'typescript'"
    • changedInput schema / properties / libraryId / description
      Previous value: -"Library ID from gt_resolve_library (e.g. 'vercel/next.js', 'npm:express') or a direct docs URL"New value: +"Plain name, GroundTruth ID, or docs URL"
    • removedInput schema / properties / maxSnippets / description
      Removed value: -"Max snippets to return (default 10, max 30)"
    • changedInput schema / properties / projectPath / description
      Previous value: -"Absolute project path. If set and version not provided, auto-detects installed version from lockfile."New value: +"Project root, to read the installed version"
    • changedInput schema / properties / refresh / description
      Previous value: -"Skip cache and refetch + reindex snippets"New value: +"Re-fetch and re-index"
    • changedInput schema / properties / topic / description
      Previous value: -"Topic to filter snippets by. Examples: 'middleware', 'server actions', 'rate limiting'. Empty = all snippets."New value: +"Filter, e.g. 'middleware'. Empty = all."
    • changedInput schema / properties / version / description
      Previous value: -"Version to pin docs to, e.g. '15', 'v4.0.0'. Caches snippet index per version."New value: +"e.g. '15'"
  2. Addedv7.0.1

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already declare readOnlyHint, idempotentHint, and non-destructive behavior, so the safety profile is covered. The description adds genuinely non-structured context: results are 'cached per version' and 'refresh:true re-indexes', which tells the agent about staleness and that refresh triggers a heavier re-fetch path. It does not describe ranking criteria or result ordering, keeping it below 5.

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

Conciseness5/5

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

Three short sentences, front-loaded with what the tool returns, then a behavioral note, then sibling routing. No filler or repeated information; the telegraphic 'Prose docs: gt_get_docs' style is efficient rather than obscure.

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?

With 7 parameters, no output schema, and an open-world hint, the description usefully enumerates return fields and notes version-scoped caching. Gaps remain around ranking/ordering semantics and how maxSnippets or projectPath interact with version resolution, though the schema descriptions cover most of that ground.

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 86%, so the schema already documents topic, language, version, refresh, projectPath, and maxSnippets in detail. The description's 'by topic and language' and 'Cached per version; refresh:true re-indexes' largely restate what the schema says, adding little interpretive value. Baseline 3 is appropriate when the schema carries the weight.

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?

States a specific resource and what it returns: 'Ranked code snippets (title, language, code, source URL) from a library's own docs, by topic and language.' The scope qualifiers ('library's own docs', 'ranked') distinguish it from a generic search tool, and the sibling routing at the end removes ambiguity about what kind of content this returns.

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

Usage Guidelines4/5

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

Routes the agent explicitly: 'Prose docs: gt_get_docs. Real-project usage: gt_examples.' This gives concrete alternatives with a selection condition (docs-prose vs. real-project usage). It stops short of a full when-to-use/when-not framing — it never says when this tool is the wrong choice beyond those two contrasts — so 4 rather than 5.

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