Skip to main content
Glama
pinzonjulian

Stimulus Docs MCP Server

by pinzonjulian

handbook-hello

Learn to build your first Stimulus controller by creating a greeting controller with targets, actions, and DOM event handling through step-by-step guidance.

Instructions

Step-by-step tutorial for building your first Stimulus controller - covers creating a greeting controller with targets, actions, and DOM event handling

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function for the 'handbook-hello' tool (shared pattern): fetches markdown content via readMarkdownFile(path.join('handbook', '02_hello_stimulus.md')) and returns it as MCP content block or error message.
      async () => {
        try {
          const content = await readMarkdownFile(path.join(folder, file));
          return {
            content: [
              {
                type: "text",
                text: content
              }
            ]
          };
        } catch (error) {
          const errorMessage = error instanceof Error ? error.message : String(error);
          return {
            content: [
              {
                type: "text",
                text: `Error reading ${file}: ${errorMessage}`
              }
            ]
          };
        }
      }
    );
  • Schema/configuration entry in docFiles array defining the tool name 'handbook-hello', its markdown source file, folder, and description.
    {
      folder: 'handbook',
      file: '02_hello_stimulus.md',
      name: 'handbook-hello',
      description: 'Step-by-step tutorial for building your first Stimulus controller - covers creating a greeting controller with targets, actions, and DOM event handling'
    },
  • src/index.ts:17-45 (registration)
    Registration of the 'handbook-hello' tool (via loop over docFiles) on the MCP server using server.tool(name, description, handlerFn).
    docFiles.forEach(({ folder, file, name, description }) => {
      server.tool(
        name,
        description,
        async () => {
          try {
            const content = await readMarkdownFile(path.join(folder, file));
            return {
              content: [
                {
                  type: "text",
                  text: content
                }
              ]
            };
          } catch (error) {
            const errorMessage = error instanceof Error ? error.message : String(error);
            return {
              content: [
                {
                  type: "text",
                  text: `Error reading ${file}: ${errorMessage}`
                }
              ]
            };
          }
        }
      );
    });
  • Supporting function implementing file reading logic (cache → GitHub → local fallback) for the tool's markdown file.
    export async function readMarkdownFile(filename: string): Promise<string> {
      const filePath = path.join(docsFolder, filename);
      if (!filePath.startsWith(docsFolder)) {
        throw new Error("Invalid file path");
      }
      
      // Get current commit info if we don't have it yet
      if (!mainBranchInfo) {
        try {
          const commitInfo = await fetchMainBranchInformation();
          const cacheKey = `${commitInfo.sha.substring(0, 7)}-${commitInfo.timestamp}`;
          mainBranchInfo = {
            ...commitInfo,
            cacheKey
          };
        } catch (shaError) {
          console.error('Failed to get GitHub commit info, falling back to direct fetch');
        }
      }
      
      // Try to read from cache first if we have commit info
      if (mainBranchInfo) {
        const cachedFilePath = path.join(cacheFolder, mainBranchInfo.cacheKey, filename);
        try {
          const content = await fs.promises.readFile(cachedFilePath, "utf-8");
          console.error(`Using cached content for ${mainBranchInfo.cacheKey}: ${filename}`);
          return content;
        } catch (cacheError) {
          // Cache miss, continue to fetch from GitHub
        }
      }
      
      // Fetch from GitHub
      try {
        return await fetchFromGitHub(filename, mainBranchInfo?.cacheKey);
      } catch (githubError) {
        console.error(`GitHub fetch failed: ${githubError}, attempting to read from local files...`);
        
        // Fallback: read from local files
        try {
          return await fs.promises.readFile(filePath, "utf-8");
        } catch (localError) {
          const githubErrorMessage = githubError instanceof Error ? githubError.message : String(githubError);
          const localErrorMessage = localError instanceof Error ? localError.message : String(localError);
          throw new Error(`Failed to read file from GitHub (${githubErrorMessage}) and locally (${localErrorMessage})`);
        }
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It describes the tutorial content but does not reveal key behavioral traits such as whether it's interactive, read-only, requires authentication, has rate limits, or what format the output takes (e.g., text, code examples). For a tool with zero annotation coverage, this is a significant gap in transparency.

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, well-structured sentence that efficiently conveys the tool's purpose and scope. It is front-loaded with the main action ('step-by-step tutorial for building your first Stimulus controller') and adds specific details ('covers creating a greeting controller with targets, actions, and DOM event handling') without unnecessary words. Every part of the sentence adds value.

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?

Given the tool's complexity (a tutorial with no parameters) and the lack of annotations and output schema, the description is minimally adequate. It explains what the tutorial covers but does not address behavioral aspects or usage context. For a tool with zero parameters and no output schema, this is acceptable but leaves gaps in understanding how the tool behaves or what results to expect.

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

Parameters4/5

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

The tool has 0 parameters, and the schema description coverage is 100% (as there are no parameters to describe). In such cases, the baseline score is 4, as there is no need for the description to compensate for parameter documentation. The description does not mention parameters, which is appropriate given the empty input schema.

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 as a 'step-by-step tutorial for building your first Stimulus controller' with specific coverage of 'creating a greeting controller with targets, actions, and DOM event handling.' This provides a specific verb ('tutorial for building') and resource ('Stimulus controller'), though it doesn't explicitly differentiate from sibling tools like 'handbook-building' or 'handbook-introduction' which might also cover related concepts.

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 mentions what the tutorial covers but does not indicate prerequisites, target audience (e.g., beginners vs. advanced users), or when to choose this over sibling tools like 'handbook-introduction' or 'reference-controllers.' This lack of context leaves the agent without clear usage instructions.

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/pinzonjulian/stimulus-docs-mcp-server'

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