Skip to main content
Glama

get_snippet

Read-only

Retrieve specific content snippets from LightCMS using their unique ID for integration into websites and applications.

Instructions

Get a snippet by ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesSnippet ID (MongoDB ObjectID),required

Implementation Reference

  • The 'runQuery' function handles the chat query, fetching results from '/api/chat' and streaming them. This represents the client-side implementation of the chat logic.
    function runQuery(query, cfg, bodyId, inputId, sendId) {
      var body = document.getElementById(bodyId);
      var sendBtn = document.getElementById(sendId);
      var input = document.getElementById(inputId);
    
      body.innerHTML = '<div class="lc-loading"><div class="lc-dot"></div><div class="lc-dot"></div><div class="lc-dot"></div></div>';
      sendBtn.disabled = true;
    
      var loadingRemoved = false;
      var answerEl = null;
      var sourcesEl = null;
      var rawAnswer = '';
    
      function removeLoading() {
        if (!loadingRemoved) {
          var l = body.querySelector('.lc-loading');
          if (l) l.remove();
          loadingRemoved = true;
        }
      }
    
      function ensureAnswer() {
        if (!answerEl) {
          removeLoading();
          answerEl = document.createElement('div');
          answerEl.className = 'lc-answer';
          body.appendChild(answerEl);
        }
        return answerEl;
      }
    
      function handleEvent(evt) {
        if (evt.type === 'token' && evt.text) {
          rawAnswer += evt.text;
          ensureAnswer().innerHTML = renderMarkdown(rawAnswer);
          body.scrollTop = body.scrollHeight;
        } else if (evt.type === 'sources') {
          removeLoading();
          var results = evt.results || [];
          if (results.length === 0 && !answerEl) {
            body.innerHTML = '<p class="lc-no-results">No results found. Try rephrasing your question.</p>';
            return;
          }
          if (results.length > 0) {
            sourcesEl = document.createElement('div');
            sourcesEl.className = 'lc-sources';
            var html = '<div class="lc-sources-label">Sources</div>';
            for (var i = 0; i < results.length; i++) {
              var r = results[i];
              html += '<a class="lc-result" href="' + escHtml(r.url) + '">' +
                '<span class="lc-result-arrow">↗</span>' +
                '<span class="lc-result-title">' + escHtml(r.title) + '</span>' +
                '</a>';
            }
            sourcesEl.innerHTML = html;
            body.appendChild(sourcesEl);
            body.scrollTop = body.scrollHeight;
          }
        } else if (evt.type === 'done') {
          sendBtn.disabled = false;
          input.value = '';
          input.focus();
        }
      }
    
      fetch(baseURL + '/api/chat?q=' + encodeURIComponent(query))
        .then(function (res) {
          if (!res.ok || !res.body) throw new Error('HTTP ' + res.status);
          var reader = res.body.getReader();
          var decoder = new TextDecoder();
          var buffer = '';
    
          function pump() {
            return reader.read().then(function (result) {
              if (result.done) { sendBtn.disabled = false; return; }
              buffer += decoder.decode(result.value, { stream: true });
              var parts = buffer.split('\n\n');
              buffer = parts.pop();
              for (var i = 0; i < parts.length; i++) {
                var p = parts[i].trim();
                if (p.indexOf('data: ') === 0) {
                  try { handleEvent(JSON.parse(p.slice(6))); } catch (e) {}
                }
              }
              return pump();
            });
          }
          return pump();
        })
        .catch(function () {
          sendBtn.disabled = false;
          body.innerHTML = '<p class="lc-no-results">Something went wrong. Please try again.</p>';
        });
    }
Behavior3/5

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

Annotations declare readOnlyHint=true, establishing it as a safe read operation. The description adds the lookup mechanics ('by ID') confirming the schema intent, but provides no additional context on error behaviors (e.g., 404), rate limits, or return structure.

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?

Extremely brief (4 words) but appropriately sized for a single-parameter getter. The sentence is front-loaded and contains no redundant information, though its terseness borders on tautology with the tool name.

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

Completeness3/5

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

Adequate for a simple read operation with complete schema coverage and safety annotations. However, lacking an output schema, the description omits what fields or structure are returned, which could improve agent debugging.

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?

With 100% schema description coverage, the baseline is 3. The description mentions 'by ID', aligning with the parameter, but adds no syntax details, format examples, or semantic meaning beyond what the schema already provides.

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

Purpose4/5

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

States a specific verb ('Get'), resource ('snippet'), and lookup method ('by ID'). The 'by ID' phrasing implicitly distinguishes this from the sibling 'list_snippets' tool, though it does not explicitly name that alternative.

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

Usage Guidelines2/5

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

Provides no guidance on when to use this tool versus siblings like 'list_snippets' (for browsing) or 'search_content' (for querying). No prerequisites, error handling, or workflow context is mentioned.

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/jonradoff/lightcms'

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