Skip to main content
Glama

trakt_authenticate

Initiates OAuth authentication with Trakt.tv to authorize Plex media activity scrobbling and tracking.

Instructions

Start Trakt.tv OAuth authentication process

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stateNoOptional state parameter for OAuth flow

Implementation Reference

  • The main handler function 'traktAuthenticate' that executes the tool logic. It initializes the Trakt client (if not already done), generates an OAuth auth URL via the client, and returns the URL along with instructions for the user to complete authorization.
    /**
     * MCP Function: trakt_authenticate
     * Start OAuth authentication flow
     */
    async traktAuthenticate(state?: string): Promise<Record<string, unknown>> {
      this.initializeTraktClient();
    
      try {
        const authUrl = this.traktClient.generateAuthUrl(state);
        
        return {
          success: true,
          authUrl,
          instructions: [
            '1. Open the provided URL in your browser',
            '2. Authorize the application on Trakt.tv',
            '3. Copy the authorization code from the callback',
            '4. Use trakt_complete_auth with the code to complete setup'
          ],
          message: 'Visit the auth URL and complete authorization, then use trakt_complete_auth with the code'
        };
      } catch (error) {
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Authentication initialization failed'
        };
      }
    }
  • Registers the 'trakt_authenticate' tool with the ToolRegistry, binding it to the traktAuthenticate method on TraktMCPFunctions and wrapping the response.
    registry.register("trakt_authenticate", (args) =>
      traktFunctions.traktAuthenticate(args.state as string | undefined).then(wrapResponse)
    );
  • Defines the input schema for the 'trakt_authenticate' tool, including an optional 'state' string parameter for the OAuth flow.
    export const TRAKT_TOOL_SCHEMAS = [
      {
        name: "trakt_authenticate",
        description: "Start Trakt.tv OAuth authentication process",
        inputSchema: {
          type: "object" as const,
          properties: {
            state: { type: "string", description: "Optional state parameter for OAuth flow" },
          },
        },
      },
  • Helper method 'initializeTraktClient' that sets up the Trakt client with config from environment variables. Called by traktAuthenticate before proceeding.
    private initializeTraktClient(): void {
      if (this.isInitialized) return;
    
      const config: TraktConfig = {
        baseUrl: process.env.TRAKT_BASE_URL || DEFAULT_TRAKT_API_URL,
        clientId: process.env.TRAKT_CLIENT_ID || '',
        clientSecret: process.env.TRAKT_CLIENT_SECRET || '',
        redirectUri: process.env.TRAKT_REDIRECT_URI || 'urn:ietf:wg:oauth:2.0:oob',
        accessToken: process.env.TRAKT_ACCESS_TOKEN,
        refreshToken: process.env.TRAKT_REFRESH_TOKEN
      };
    
      if (!config.clientId || !config.clientSecret) {
        throw new Error('TRAKT_CLIENT_ID and TRAKT_CLIENT_SECRET environment variables are required');
      }
    
      this.traktClient = new TraktClient(config);
      this.syncEngine = new TraktSyncEngine(this.traktClient, this.plexClient);
      this.isInitialized = true;
    }
Behavior2/5

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

No annotations are provided, so the description must convey behavioral traits. It only says 'start OAuth process' without describing side effects, return value, user interaction requirements, or any constraints like rate limits or permissions. This is insufficient for an OAuth initiation step.

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, focused sentence with no unnecessary words. Every part earns its place.

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?

For a multi-step authentication process with sibling tools for completion and status checking, the description lacks essential context. It does not explain what the tool returns, how to use the response in the next step, or any prerequisites. The lack of output schema further reduces completeness.

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 one parameter with a description ('Optional state parameter for OAuth flow'), giving 100% schema coverage. The tool description adds nothing beyond that baseline. No additional parameter meaning is provided.

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?

The description clearly states the action ('Start') and the resource ('Trakt.tv OAuth authentication process'), and it is distinct from sibling tools like 'trakt_complete_auth' and 'trakt_get_auth_status', which represent subsequent steps.

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

Usage Guidelines3/5

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

The description implies that this is the first step in an OAuth flow, but it provides no explicit guidance on when to use it versus alternatives, prerequisites, or what to do after calling it. The context is implied but not fully spelled out.

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/niavasha/plex-mcp-server'

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