Skip to main content
Glama

Check Authentication Status

check_auth

Verify authentication status with Brightspace to resolve login issues and prevent authorization errors in related tools.

Instructions

Check if you are authenticated with Brightspace. Run the brightspace-auth CLI first to authenticate. Use this when the user asks if they're logged in, if authentication is working, or when other tools return auth errors.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Complete implementation of the check_auth tool handler. This async function checks authentication status by: 1) Getting current token from TokenManager, 2) Attempting auto-reauthentication via AuthRunner if no valid token exists, 3) Returning appropriate status messages with token expiry time and source, 4) Optionally appending update notices. The tool is registered with server.registerTool() at line 96.
    server.registerTool(
      "check_auth",
      {
        title: "Check Authentication Status",
        description:
          "Check if you are authenticated with Brightspace. " +
          "Run the brightspace-auth CLI first to authenticate. " +
          "Use this when the user asks if they're logged in, if authentication is working, " +
          "or when other tools return auth errors.",
      },
      async () => {
        log("DEBUG", "check_auth tool called");
    
        let token = await tokenManager.getToken();
    
        if (!token) {
          log("INFO", "check_auth: No valid token, attempting auto-reauthentication...");
    
          const success = await authRunner.run();
          if (success) {
            token = await tokenManager.getToken();
          }
    
          if (!token) {
            log("INFO", "check_auth: Auto-reauthentication failed or produced no valid token");
    
            const content: Array<{ type: "text"; text: string }> = [
              {
                type: "text",
                text: "Not authenticated. Auto-reauthentication was attempted but failed. " +
                  "Please run `brightspace-auth` manually in your terminal to log in. " +
                  "Make sure your credentials in .env are correct and your internet connection is stable.",
              },
            ];
            const notice = getUpdateNotice();
            if (notice) content.push({ type: "text", text: notice });
            return { content };
          }
    
          log("INFO", "check_auth: Auto-reauthentication succeeded");
        }
    
        const expiresIn = Math.round((token.expiresAt - Date.now()) / 1000 / 60);
        log("INFO", `check_auth: Token valid, expires in ~${expiresIn} minutes`);
    
        const content: Array<{ type: "text"; text: string }> = [
          {
            type: "text",
            text: `Authenticated with Brightspace. Token expires in ~${expiresIn} minutes. Source: ${token.source}.`,
          },
        ];
        const notice = getUpdateNotice();
        if (notice) content.push({ type: "text", text: notice });
        return { content };
      }
    );
  • TokenData schema definition used by check_auth handler. Defines the structure of authentication tokens including accessToken, capture timestamp, expiry timestamp, and source (browser or cache). This schema is used to validate and manage tokens returned by TokenManager.
    export interface TokenData {
      accessToken: string;
      capturedAt: number; // Unix timestamp ms
      expiresAt: number; // Unix timestamp ms
      source: "browser" | "cache";
    }
  • getUpdateNotice() helper function used by check_auth to append update notifications to responses. This function retrieves and clears a one-time notice about available Git updates, which gets added to the first check_auth response.
    export function getUpdateNotice(): string | null {
      const result = notice;
      notice = null;
      return result;
    }
  • TokenManager.getToken() helper method used by check_auth to retrieve current authentication tokens. Implements in-memory caching with disk persistence fallback and validity checking (including refresh buffer to prevent using near-expiry tokens).
    async getToken(): Promise<TokenData | null> {
      // Check memory cache first
      if (this.cachedToken && this.isValid(this.cachedToken)) {
        log("DEBUG", "Returning cached token");
        return this.cachedToken;
      }
    
      // Try loading from disk
      const storedToken = await this.sessionStore.load();
      if (storedToken && this.isValid(storedToken)) {
        log("DEBUG", "Loaded valid token from session store");
        this.cachedToken = storedToken;
        return storedToken;
      }
    
      log("DEBUG", "No valid token available");
      return null;
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively communicates that this is a diagnostic/status-checking tool (not a data retrieval tool like siblings), mentions the prerequisite authentication step, and indicates it helps troubleshoot auth errors from other tools. It doesn't specify response format or error conditions, but provides solid behavioral context for a zero-parameter tool.

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 perfectly concise and well-structured in just two sentences. The first sentence states the core purpose, the second provides usage guidelines and prerequisites. Every word earns its place with no redundancy or wasted text. It's front-loaded with the essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter authentication status tool with no annotations and no output schema, the description provides strong contextual completeness. It explains what the tool does, when to use it, and includes important prerequisite information. The main gap is not specifying what the output looks like (success/failure indicators), but given the tool's simplicity and clear purpose, this is a minor omission.

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 zero parameters with 100% schema description coverage, so the baseline is 4. The description appropriately doesn't discuss parameters since none exist, focusing instead on usage context and prerequisites. No additional parameter information is needed or provided.

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: checking authentication status with Brightspace. It specifies the verb ('check') and resource ('authentication status'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools, which are all data retrieval tools rather than authentication tools.

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

Usage Guidelines5/5

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

The description provides excellent usage guidelines with explicit when-to-use scenarios: 'when the user asks if they're logged in, if authentication is working, or when other tools return auth errors.' It also includes a prerequisite instruction: 'Run the brightspace-auth CLI first to authenticate.' This gives clear context for when this tool should be invoked versus alternatives.

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/RohanMuppa/brightspace-mcp-server'

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