Skip to main content
Glama
dabhivijay2478

Better Auth MCP Server

get_auth_examples

Retrieve authentication code examples and snippets for Better Auth features like email-password, GitHub, or two-factor authentication to implement secure authentication in web applications.

Instructions

Get usage examples and code snippets for Better Auth features

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
featureNameYesFeature to get examples for (e.g., "email-password", "github", "two-factor")
frameworkNoOptional framework filter for examples

Implementation Reference

  • Primary handler function that executes the get_auth_examples tool. Validates input, fetches examples via helper, and formats success response.
    /**
     * Handle the get_auth_examples tool request
     */
    private async handleGetAuthExamples(args: any) {
      const featureName = this.validateFeatureName(args);
      const framework = args?.framework;
    
      try {
        const examples = await this.fetchAuthExamples(featureName, framework);
        return this.createSuccessResponse({
          feature: featureName,
          framework: framework || "all",
          examples,
        });
      } catch (error) {
        this.handleAxiosError(error, `Examples for "${featureName}"`);
      }
    }
  • Helper method that fetches code examples for a Better Auth feature from documentation, combining general feature examples and optional framework-specific examples using Cheerio for parsing.
    /**
     * Fetch examples for a specific feature
     */
    private async fetchAuthExamples(featureName: string, framework?: string): Promise<BetterAuthExample[]> {
      const examples: BetterAuthExample[] = [];
      
      // Get feature details first
      const feature = await this.fetchFeatureDetails(featureName);
      
      if (feature.examples) {
        examples.push(...feature.examples);
      }
      
      // If framework specified, also get framework-specific examples
      if (framework) {
        try {
          const exampleUrl = `${this.BETTER_AUTH_DOCS_URL}/docs/examples/${framework}`;
          const response = await this.axiosInstance.get(exampleUrl);
          const $ = cheerio.load(response.data);
          
          const frameworkExamples = this.extractExamples($);
          examples.push(...frameworkExamples.map(ex => ({
            ...ex,
            framework,
          })));
        } catch (error) {
          // Continue if framework examples not found
        }
      }
      
      return examples;
    }
  • src/index.ts:177-194 (registration)
    Registration of the get_auth_examples tool in the tools list returned by list_tools, including name, description, and input schema.
    {
      name: "get_auth_examples",
      description: "Get usage examples and code snippets for Better Auth features",
      inputSchema: {
        type: "object",
        properties: {
          featureName: {
            type: "string",
            description: "Feature to get examples for (e.g., \"email-password\", \"github\", \"two-factor\")",
          },
          framework: {
            type: "string",
            description: "Optional framework filter for examples",
          },
        },
        required: ["featureName"],
      },
    },
  • src/index.ts:229-230 (registration)
    Dispatch case in the call_tool request handler that routes get_auth_examples calls to the specific handler method.
    case "get_auth_examples":
      return await this.handleGetAuthExamples(request.params.arguments);
  • Input schema defining the expected arguments: required featureName (string) and optional framework (string).
    inputSchema: {
      type: "object",
      properties: {
        featureName: {
          type: "string",
          description: "Feature to get examples for (e.g., \"email-password\", \"github\", \"two-factor\")",
        },
        framework: {
          type: "string",
          description: "Optional framework filter for examples",
        },
      },
      required: ["featureName"],
    },
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 states the tool retrieves examples and snippets, implying a read-only operation, but doesn't disclose any behavioral traits such as rate limits, authentication requirements, or response formats. This leaves significant gaps in understanding how the tool behaves in practice.

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 that directly states the tool's purpose without any unnecessary words. It is appropriately sized and front-loaded, making it easy to parse quickly.

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 moderate complexity (2 parameters, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose but lacks details on behavioral traits, usage guidelines, and output expectations. Without annotations or an output schema, more context would be beneficial for the agent to use the tool 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 input schema has 100% description coverage, with clear documentation for both parameters ('featureName' and 'framework'). The description adds no additional meaning beyond what the schema provides, such as example values or usage context. With high schema coverage, the baseline score of 3 is appropriate as the schema handles the heavy lifting.

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 ('Get') and resource ('usage examples and code snippets for Better Auth features'), making it immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_feature_details' or 'get_integration_guide', which might also provide related information about features.

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 sibling tools like 'get_feature_details' or 'search_better_auth', nor does it specify contexts or exclusions for usage, leaving the agent to infer based on tool names alone.

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/dabhivijay2478/better-auth-mcp-server'

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