Skip to main content
Glama
pinzonjulian

Stimulus Docs MCP Server

by pinzonjulian

reference-targets

Access Stimulus JS documentation for target definitions, properties, shared targets, and lifecycle callbacks to implement data attributes in web applications.

Instructions

Targets API reference - covers target definitions, properties (singular/plural/existential), shared targets, optional targets, and target lifecycle callbacks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function that executes the tool: reads 'reference/targets.md' content using readMarkdownFile and returns as MCP text content block, with error handling.
    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}`
            }
          ]
        };
      }
    }
  • src/index.ts:17-45 (registration)
    Registration loop that creates the 'reference-targets' tool (among others) using config from docFiles, providing the name, description, and shared handler.
    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}`
                }
              ]
            };
          }
        }
      );
    });
  • src/config.ts:90-94 (registration)
    Specific configuration that defines the 'reference-targets' tool: maps to 'reference/targets.md' file with description.
    {
      folder: 'reference', file: 'targets.md',
      name: 'reference-targets',
      description: 'Targets API reference - covers target definitions, properties (singular/plural/existential), shared targets, optional targets, and target lifecycle callbacks'
    },
  • Key helper function called by the handler to fetch markdown content: prefers cache, then GitHub raw, then local 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. The description fails to explain what the tool does behaviorally—whether it retrieves information, modifies settings, or performs another action. It doesn't mention permissions, side effects, rate limits, or output format. For a tool with zero annotation coverage, this lack of behavioral context is a significant gap, though it doesn't contradict any annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

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

The description is a single sentence that lists topics covered, which is concise but not front-loaded with clear purpose. It wastes space on a tautological restatement of the name ('Targets API reference') instead of immediately stating the tool's function. While brief, it lacks effective structure to guide an AI agent, making it adequate but with room for improvement.

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 what the tool returns or how it behaves, leaving the agent unsure of the outcome. For a tool with no structured data to rely on, the description should provide more context about functionality and results, but it only lists topics without actionable information.

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 input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description appropriately doesn't discuss parameters, as there are none to explain. This meets the baseline for tools without parameters, where the description needn't compensate for schema gaps.

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

Purpose2/5

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

The description 'Targets API reference - covers target definitions, properties (singular/plural/existential), shared targets, optional targets, and target lifecycle callbacks' is vague and tautological. It restates the tool name 'reference-targets' as 'Targets API reference' without specifying what action the tool performs (e.g., retrieves, lists, or explains targets). It lists topics covered but doesn't state what the tool actually does, making it unclear whether this is a documentation viewer, configuration tool, or something else.

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?

There is no guidance on when to use this tool versus alternatives. The description mentions topics like 'target definitions' and 'target lifecycle callbacks' but doesn't explain the context or prerequisites for using this tool. With sibling tools like 'reference-actions', 'reference-controllers', and 'reference-typescript', there's no indication of how this tool differs or when it should be selected over others, leaving usage entirely implicit.

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