Skip to main content
Glama
ngeojiajun

Code Snippet Server

by ngeojiajun

list_snippets

Filter and retrieve code snippets by language or tags from a centralized server, streamlining access to reusable code for efficient development.

Instructions

List snippets (can filter by language or tags)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
languageNoFilter by specific language
tagNoFilter by specific tag

Implementation Reference

  • Primary MCP tool handler for list_snippets: wraps engine.ListSnippets and returns JSON-formatted response
    private async listSnippets(args: any): Promise<GenericMCPResponse> {
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(await this.engine.ListSnippets(args), null, 2)
        }]
      };
    }
  • Core implementation of snippet listing with filtering by language, tag, and title
    async ListSnippets(query?: SnippetQuery): Promise<CodeSnippet[]> {
      // 単一のfilter関数で全フィルタリング条件を処理
      return this.snippets.filter(s => {
        if (query) {
          if (query.language && s.language.toLowerCase() !== query.language.toLowerCase()) {
            return false;
          }
    
          if (query.tag && !s.tags.some(t => t.toLowerCase() === query.tag!.toLowerCase())) {
            return false;
          }
    
          if (query.title && !s.title.toLowerCase().includes(query.title.toLowerCase() || '')) {
            return false;
          }
        }
        return true;
      });
    }
  • src/index.ts:70-85 (registration)
    Registration of the list_snippets tool in the ListTools response
      name: 'list_snippets',
      description: this.getLocalizedString("tool_list_snippets"),
      inputSchema: {
        type: 'object',
        properties: {
          language: {
            type: 'string',
            description: this.getLocalizedString("snippet_schema_language_filter")
          },
          tag: {
            type: 'string',
            description: this.getLocalizedString("snippet_schema_tag_filter")
          }
        }
      }
    },
  • Input schema for list_snippets tool defining optional language and tag parameters
    inputSchema: {
      type: 'object',
      properties: {
        language: {
          type: 'string',
          description: this.getLocalizedString("snippet_schema_language_filter")
        },
        tag: {
          type: 'string',
          description: this.getLocalizedString("snippet_schema_tag_filter")
        }
      }
    }
  • Type definition for SnippetQuery used in ListSnippets method, matching tool input schema
    export type SnippetQuery = {
      tag?: string,
      title?: string,
      language?: string
    };
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states 'List snippets' which implies a read-only operation, but doesn't address permissions, pagination, rate limits, or what happens if no filters are applied. This leaves significant gaps for a tool with no annotation coverage.

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?

The description is extremely concise and front-loaded, consisting of a single sentence that directly states the tool's purpose and filtering options. There is no wasted language or unnecessary elaboration, making it efficient for an agent to parse.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain return values, error conditions, or behavioral traits like pagination or permissions. For a list tool with filtering, more context is needed to guide the agent effectively.

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?

The schema description coverage is 100%, so the input schema already documents both parameters ('language' and 'tag') with clear descriptions. The description adds minimal value by mentioning filtering by language or tags, but doesn't provide additional syntax, format details, or usage examples beyond what the schema 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?

The description clearly states the tool's purpose with a specific verb ('List') and resource ('snippets'), and mentions filtering capabilities. However, it doesn't explicitly differentiate from sibling tools like 'create_snippet' or 'delete_snippet' beyond implying it's a read operation, which prevents a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives like 'create_snippet' or 'delete_snippet'. It mentions filtering options but doesn't specify contexts, prerequisites, or exclusions for usage, leaving the agent without clear direction.

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

Related 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/ngeojiajun/mcp-code-snippets'

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