Skip to main content
Glama

Generate Access Token

generate_access_token

Generate a personal access token with a name and optional expiration to authenticate GraphQL API requests for workspace management.

Instructions

Generate a personal access token (returns token).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYes
expiresAtNo

Implementation Reference

  • Handler function that executes the generate_access_token tool logic: sends a GraphQL mutation to create a personal access token with a name (required) and expiresAt (optional), then returns the token data.
    const generateAccessTokenHandler = async (parsed: { name: string; expiresAt?: string }) => {
      const mutation = `mutation($input: GenerateAccessTokenInput!){ generateUserAccessToken(input:$input){ id name createdAt expiresAt token } }`;
      const data = await gql.request<{ generateUserAccessToken: any }>(mutation, { input: { name: parsed.name, expiresAt: parsed.expiresAt ?? null } });
      return text(data.generateUserAccessToken);
    };
    server.registerTool(
      "generate_access_token",
      {
        title: "Generate Access Token",
        description: "Generate a personal access token (returns token).",
        inputSchema: {
          name: z.string(),
          expiresAt: z.string().optional()
        }
      },
      generateAccessTokenHandler as any
    );
  • Registration function that registers the generate_access_token tool on the MCP server via server.registerTool().
    export function registerAccessTokenTools(server: McpServer, gql: GraphQLClient) {
      const listAccessTokensHandler = async () => {
        try {
          const query = `query { currentUser { accessTokens { id name createdAt expiresAt } } }`;
          const data = await gql.request<{ currentUser: { accessTokens: any[] } }>(query);
          return text(data.currentUser?.accessTokens || []);
        } catch (error: any) {
          console.error("List access tokens error:", error.message);
          return text({ error: error.message });
        }
      };
      server.registerTool(
        "list_access_tokens",
        {
          title: "List Access Tokens",
          description: "List personal access tokens (metadata).",
          inputSchema: {}
        },
        listAccessTokensHandler as any
      );
    
      const generateAccessTokenHandler = async (parsed: { name: string; expiresAt?: string }) => {
        const mutation = `mutation($input: GenerateAccessTokenInput!){ generateUserAccessToken(input:$input){ id name createdAt expiresAt token } }`;
        const data = await gql.request<{ generateUserAccessToken: any }>(mutation, { input: { name: parsed.name, expiresAt: parsed.expiresAt ?? null } });
        return text(data.generateUserAccessToken);
      };
      server.registerTool(
        "generate_access_token",
        {
          title: "Generate Access Token",
          description: "Generate a personal access token (returns token).",
          inputSchema: {
            name: z.string(),
            expiresAt: z.string().optional()
          }
        },
        generateAccessTokenHandler as any
      );
    
      const revokeAccessTokenHandler = async (parsed: { id: string }) => {
        const mutation = `mutation($id:String!){ revokeUserAccessToken(id:$id) }`;
        const data = await gql.request<{ revokeUserAccessToken: boolean }>(mutation, { id: parsed.id });
        return text({ success: data.revokeUserAccessToken });
      };
      server.registerTool(
        "revoke_access_token",
        {
          title: "Revoke Access Token",
          description: "Revoke a personal access token by id.",
          inputSchema: {
            id: z.string()
          }
        },
        revokeAccessTokenHandler as any
      );
    }
  • src/index.ts:189-189 (registration)
    Where registerAccessTokenTools is called during server initialization in the main index.ts file.
    registerAccessTokenTools(server, gql);
  • Input schema (Zod) for the generate_access_token tool: name (required string) and expiresAt (optional string).
    inputSchema: {
      name: z.string(),
      expiresAt: z.string().optional()
    }
  • Tool surface configuration defining permission groups for generate_access_token: access_tokens, access_tokens.write, admin, write.
    generate_access_token: ["access_tokens", "access_tokens.write", "admin", "write"],
Behavior2/5

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

No annotations provided. Description says 'returns token' but lacks details on side effects, security implications, or that token is only shown once.

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

Conciseness4/5

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

One efficient sentence, no fluff, but could include more critical info without being verbose.

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?

No annotations, no output schema, and low schema coverage. Description fails to provide essential context like token format, security warnings, or use case.

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?

Schema description coverage is 0%. Description does not explain 'name' (display name?) or 'expiresAt' (format?). Adds no meaning beyond the schema.

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

Purpose5/5

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

Clearly states the verb 'generate' and resource 'personal access token'. Distinguishes from sibling tools like list_access_tokens and revoke_access_token.

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?

No guidance on when to use this tool vs alternatives. No mention of prerequisites or context for generation.

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/DAWNCR0W/affine-mcp-server'

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