Skip to main content
Glama
VKneider

Slice.js Documentation MCP

by VKneider

search_docs

Search Slice.js documentation by keyword or phrase to find relevant information quickly. This tool returns specific documentation sections based on your search query.

Instructions

Searches across all docs by keyword/phrase

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
max_resultsNo

Implementation Reference

  • The main search_docs tool implementation including tool definition, schema validation with zod, and the execute handler that searches through all documentation files for matching keywords/phrases and returns results with snippets
    export const searchDocsTool = {
      name: "search_docs",
      description: "Searches across all docs by keyword/phrase",
      parameters: z.object({
        query: z.string(),
        max_results: z.number().optional().default(5),
      }),
      execute: async (args: { query: string; max_results: number }) => {
        if (!isInitialized) await initializeDocsStructure();
        const { query, max_results } = args;
        const results: any[] = [];
    
        for (const doc of DOCS_STRUCTURE) {
          const content = await fetchDocContent(doc.id);
          if (!content) continue;
    
          const lines = content.split('\n');
          for (let i = 0; i < lines.length; i++) {
            const line = lines[i];
            if (line.toLowerCase().includes(query.toLowerCase())) {
              const snippet = line.trim();
              results.push({
                doc_id: doc.id,
                title: doc.title,
                relevance_score: 1, // simple match
                snippet,
                path: doc.path,
              });
              if (results.length >= max_results) break;
            }
          }
          if (results.length >= max_results) break;
        }
    
        return JSON.stringify(results);
      },
    };
  • src/index.ts:1-21 (registration)
    Server initialization and tool registration - imports searchDocsTool and adds it to the FastMCP server on line 15
    #!/usr/bin/env node
    
    import { FastMCP } from "fastmcp";
    import { listDocsTool } from "./tools/list-docs.js";
    import { searchDocsTool } from "./tools/search-docs.js";
    import { getDocContentTool } from "./tools/get-doc-content.js";
    import { getLlmFullContextTool } from "./tools/get-llm-full-context.js";
    
    const server = new FastMCP({
      name: "Slice.js Documentation MCP",
      version: "1.0.0",
    });
    
    server.addTool(listDocsTool);
    server.addTool(searchDocsTool);
    server.addTool(getDocContentTool);
    server.addTool(getLlmFullContextTool);
    
    server.start({
      transportType: "stdio",
    });
  • Input parameter schema using zod - defines required 'query' string and optional 'max_results' number with default of 5
    parameters: z.object({
      query: z.string(),
      max_results: z.number().optional().default(5),
    }),
  • Helper function fetchDocContent() that retrieves document content from GitHub with caching support, used by search_docs to get document content for searching
    export async function fetchDocContent(docId: string): Promise<string | null> {
      const cached = getCached(docId);
      if (cached) {
        console.error(`[MCP] Cache hit for doc: ${docId}`);
        return cached;
      }
    
        console.error(`[MCP] Cache miss for doc: ${docId}, fetching from GitHub`);
      const doc = DOCS_STRUCTURE.find(d => d.id === docId);
      if (!doc) return null;
    
      const url = `${BASE_URL}${doc.path}`;
      try {
        const response = await fetch(url);
        if (!response.ok) throw new Error(`HTTP ${response.status}`);
        const content = await response.text();
        setCache(docId, content);
        console.error(`[MCP] Fetched and cached doc: ${docId}`);
        return content;
      } catch (error) {
        console.error(`[MCP] Error fetching ${url}:`, error);
        return null;
      }
    }
  • Helper function initializeDocsStructure() that builds the DOCS_STRUCTURE from llm.txt on GitHub and manages the isInitialized flag, called by search_docs on first execution
    export async function initializeDocsStructure(): Promise<void> {
      if (isInitialized) return;
    
      try {
        let llmContent = getCached('llm.txt');
        if (!llmContent) {
          console.error('[MCP] Fetching llm.txt to build docs structure');
          const url = `${BASE_URL}llm.txt`;
          const response = await fetch(url);
          if (!response.ok) throw new Error(`HTTP ${response.status}`);
          llmContent = await response.text();
          setCache('llm.txt', llmContent);
        } else {
          console.error('[MCP] Using cached llm.txt to build docs structure');
        }
        // Parse DOCS_STRUCTURE from llm.txt
        DOCS_STRUCTURE = parseDocsFromLlmTxt(llmContent);
        isInitialized = true;
        console.error(`[MCP] Initialized docs structure with ${DOCS_STRUCTURE.length} documents`);
      } catch (error) {
        console.error('[MCP] Failed to initialize docs structure:', error);
        DOCS_STRUCTURE = [];
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the search scope ('across all docs') but lacks critical behavioral details: it doesn't specify if results are paginated, what the return format is (e.g., list of titles or full content snippets), or any rate limits. For a search tool with zero annotation coverage, this is insufficient.

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 a single, efficient sentence with zero waste. It's front-loaded and appropriately sized for a simple tool, making it easy to parse quickly.

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 tool's moderate complexity (search with 2 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't explain return values, error conditions, or behavioral constraints, leaving significant gaps for the agent to infer.

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

Parameters2/5

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

Schema description coverage is 0%, meaning parameters are undocumented in the schema. The description mentions 'keyword/phrase' which hints at the 'query' parameter, but it doesn't explain 'max_results' or provide any syntax details (e.g., query operators). It adds minimal value beyond the bare schema, failing to compensate for the coverage gap.

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 action ('Searches') and target resource ('across all docs') with the method ('by keyword/phrase'). It distinguishes this from siblings like 'get_doc_content' (retrieves specific content) and 'list_docs' (likely lists without search). However, it doesn't explicitly differentiate from 'get_llm_full_context', which might be a more comprehensive search, so it's not a perfect 5.

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. It doesn't mention when to prefer 'search_docs' over 'list_docs' or 'get_llm_full_context', nor does it specify prerequisites like needing a query. This leaves the agent with minimal context for tool selection.

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/VKneider/slicejs-mcp'

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