Skip to main content
Glama

token_auth

Validate and manage authentication tokens for secure API access on CyberMCP. Ensure token integrity, type, and expiration for enhanced security testing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expires_inNoToken expiration time in seconds
refresh_tokenNoRefresh token (if available)
tokenYesAuthentication token
token_typeNoToken type (Bearer, JWT, etc.)Bearer

Implementation Reference

  • The handler function that executes the token_auth tool logic. It retrieves AuthManager instance, calls setTokenAuth with provided credentials, and returns success or error message.
    async ({ token, token_type, refresh_token, expires_in }) => {
      try {
        const authManager = AuthManager.getInstance();
        const authState = await authManager.setTokenAuth({
          token,
          tokenType: token_type,
          refreshToken: refresh_token,
          expiresIn: expires_in,
        });
        
        return {
          content: [
            {
              type: "text",
              text: `Successfully set Token authentication\nAuthentication type: ${authState.type}\nToken type: ${token_type}\nHeader: Authorization: ${token_type} ***\n${authState.tokenExpiry ? `Token expires: ${authState.tokenExpiry.toISOString()}` : ''}`,
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: `Error setting Token authentication: ${(error as Error).message}`,
            },
          ],
        };
      }
    }
  • Zod schema defining the input parameters for the token_auth tool.
    {
      token: z.string().describe("Authentication token"),
      token_type: z.string().default("Bearer").describe("Token type (Bearer, JWT, etc.)"),
      refresh_token: z.string().optional().describe("Refresh token (if available)"),
      expires_in: z.number().optional().describe("Token expiration time in seconds"),
    },
  • The server.tool call that registers the token_auth tool with its schema and handler function.
    server.tool(
      "token_auth",
      {
        token: z.string().describe("Authentication token"),
        token_type: z.string().default("Bearer").describe("Token type (Bearer, JWT, etc.)"),
        refresh_token: z.string().optional().describe("Refresh token (if available)"),
        expires_in: z.number().optional().describe("Token expiration time in seconds"),
      },
      async ({ token, token_type, refresh_token, expires_in }) => {
        try {
          const authManager = AuthManager.getInstance();
          const authState = await authManager.setTokenAuth({
            token,
            tokenType: token_type,
            refreshToken: refresh_token,
            expiresIn: expires_in,
          });
          
          return {
            content: [
              {
                type: "text",
                text: `Successfully set Token authentication\nAuthentication type: ${authState.type}\nToken type: ${token_type}\nHeader: Authorization: ${token_type} ***\n${authState.tokenExpiry ? `Token expires: ${authState.tokenExpiry.toISOString()}` : ''}`,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error setting Token authentication: ${(error as Error).message}`,
              },
            ],
          };
        }
      }
    );
  • Helper method in AuthManager class that sets the token authentication state, calculates expiry, and prepares authorization headers.
    public async setTokenAuth(credentials: TokenAuthCredentials): Promise<AuthState> {
      const { token, tokenType = 'Bearer', refreshToken, expiresIn } = credentials;
      
      // Calculate token expiry if expiresIn is provided
      let tokenExpiry: Date | undefined;
      if (expiresIn) {
        tokenExpiry = new Date();
        tokenExpiry.setSeconds(tokenExpiry.getSeconds() + expiresIn);
      }
      
      this.authState = {
        type: 'token',
        token,
        refreshToken,
        tokenExpiry,
        headers: {
          'Authorization': `${tokenType} ${token}`
        }
      };
      
      return this.getAuthState();
    }
  • TypeScript interface defining the TokenAuthCredentials used by the token_auth handler and helper.
    export interface TokenAuthCredentials {
      token: string;
      tokenType?: string;
      refreshToken?: string;
      expiresIn?: number;
    }
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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

Related 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/ricauts/CyberMCP'

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