Skip to main content
Glama
johnpapa
by johnpapa

fetch-peacock-docs

Retrieves Peacock for VS Code documentation from GitHub and provides answers to your questions about the extension.

Instructions

Fetches the Peacock for VS Code extension docs from its GitHub repository and answers questions based on the documentation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe question to answer based on the Peacock documentation

Implementation Reference

  • src/index.ts:25-46 (registration)
    The tool 'fetch-peacock-docs' is registered on the MCP server. It accepts a 'query' string (zod-validated) and delegates to handleDocumentationQuery.
    server.tool(
      "fetch-peacock-docs",
      "Fetches the Peacock for VS Code extension docs from its GitHub repository and answers questions based on the documentation  ",
      { query: z.string().describe("The question to answer based on the Peacock documentation") },
      async ({ query }) => {
        try {
          const { text } = await handleDocumentationQuery(query);
          return {
            content: [{ type: "text", text }],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error searching Peacock documentation: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • handleDocumentationQuery is the core handler: initializes the docs cache if needed, then searches documentation and code files for the query and returns relevant sections.
    export async function handleDocumentationQuery(query: string): Promise<{ text: string }> {
      // Initialize cache if needed
      if (!isDocsCacheInitialized) {
        isDocsCacheInitialized = await initializeDocsCache();
        if (!isDocsCacheInitialized) {
          return { text: "Failed to initialize documentation cache. Please try again later." };
        }
      }
    
      // Check if cache is empty
      if (Object.keys(docsCache).length === 0 && Object.keys(codeCache).length === 0) {
        return { text: "No files were found in the Peacock repository." };
      }
    
      // Handle listing available files
      if (query.toLowerCase().includes("available") && query.toLowerCase().includes("files")) {
        return {
          text: `Available documentation files:\n${docFilesList.join("\n")}\n\nAvailable code files:\n${codeFilesList.join(
            "\n"
          )}`,
        };
      }
    
      // Search documentation and code
      const { results, sources } = searchAll(query);
      if (!results) {
        return { text: `No information related to "${query}" was found in the Peacock documentation or code.` };
      }
    
      return { text: `Information related to "${query}":\n\n${results}\n\nSources: ${sources.join(", ")}` };
    }
  • searchAll searches both docsCache and codeCache for query matches, extracting relevant sections via processMatchingMarkdownSection and processMatchingCodeSection.
    export function searchAll(query: string): { results: string; sources: string[] } {
      const queryLower = query.toLowerCase();
      const relevantContent: string[] = [];
      const sources: string[] = [];
    
      // Search documentation files
      for (const [filePath, content] of Object.entries(docsCache)) {
        if (!content.toLowerCase().includes(queryLower)) continue;
    
        const lines = content.split("\n");
        for (let i = 0; i < lines.length; i++) {
          if (lines[i].toLowerCase().includes(queryLower)) {
            const { content: sectionContent, endIndex } = processMatchingMarkdownSection(lines, i, queryLower);
            if (sectionContent) {
              relevantContent.push(sectionContent);
              sources.push(filePath);
            }
            i = endIndex;
          }
        }
      }
    
      // Search code files
      for (const [filePath, content] of Object.entries(codeCache)) {
        if (!content.toLowerCase().includes(queryLower)) continue;
    
        const lines = content.split("\n");
        for (let i = 0; i < lines.length; i++) {
          if (lines[i].toLowerCase().includes(queryLower)) {
            const { content: sectionContent, endIndex } = processMatchingCodeSection(lines, i, queryLower, filePath);
            if (sectionContent) {
              relevantContent.push(sectionContent);
              sources.push(filePath);
            }
            i = endIndex;
          }
        }
      }
    
      return {
        results: relevantContent.join("\n\n---\n\n"),
        sources: [...new Set(sources)],
      };
    }
  • initializeDocsCache fetches the README.md, docs/ and src/ directories from the Peacock GitHub repo, caching documentation (.md) and code (.ts/.js/.tsx/.jsx) files.
    export async function initializeDocsCache(): Promise<boolean> {
      try {
        // Process root README
        await processDocumentationFile("README.md");
    
        // Process docs directory
        const docsItems = await fetchDirectoryContents("docs");
        await processDirectoryItems(docsItems);
    
        // Process src directory
        const srcItems = await fetchDirectoryContents("src");
        await processDirectoryItems(srcItems);
    
        const totalFiles = docFilesList.length + codeFilesList.length;
        console.error(
          `Indexed ${docFilesList.length} documentation files and ${codeFilesList.length} code files from Peacock repository`
        );
        return totalFiles > 0;
      } catch (error) {
        console.error(`Error initializing cache: ${error instanceof Error ? error.message : String(error)}`);
        return false;
      }
    }
  • The input schema for the tool: a single 'query' field of type string, validated via Zod.
    { query: z.string().describe("The question to answer based on the Peacock documentation") },
Behavior2/5

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

The description does not disclose how answers are generated, source repository specifics (branch, version), caching, error handling, or rate limits. With no annotations, the description carries full burden and 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.

Conciseness4/5

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

Single sentence that is concise, though slightly run-on. No wasted words, but could be structured more clearly.

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?

With one parameter and no output schema, the description should explain what the tool returns and how it works. It mentions 'answers questions' but not the format or completeness. Additional details are needed.

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% and the description adds little beyond the schema's own description of the 'query' parameter. Baseline 3 as schema does the heavy lifting.

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 it fetches Peacock documentation and answers questions, with a specific verb and resource. No sibling tools exist, so differentiation is not required.

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

Usage Guidelines3/5

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

No explicit guidance on when to use or not use this tool, but the purpose is implied. Since there are no sibling tools, the lack of alternatives is acceptable, but prerequisites or context are missing.

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/johnpapa/peacock-mcp'

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