Skip to main content
Glama

load_profile

Load saved cookies from a profile into an active browser tab to restore login sessions without re-authentication. Use after creating a tab to apply saved state.

Instructions

Load a saved profile's cookies into an active browser tab. Restores login sessions without re-authentication. Use after create_tab to restore saved state.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
profileIdYesProfile name to load
tabIdYesTab ID to load cookies into

Implementation Reference

  • MCP tool handler for 'load_profile'. Parses input (profileId, tabId), loads profile from disk via loadProfile(), and imports cookies into the browser tab via client.importCookies(). Returns profile details or error.
    server.tool(
      "load_profile",
      "Load a saved profile's cookies into an active browser tab. Restores login sessions without re-authentication. Use after create_tab to restore saved state.",
      {
        profileId: z.string().min(1).describe("Profile name to load"),
        tabId: z.string().min(1).describe("Tab ID to load cookies into")
      },
      async (input: unknown) => {
        try {
          const parsed = z
            .object({
              profileId: z.string().min(1),
              tabId: z.string().min(1)
            })
            .parse(input);
    
          const tracked = getTrackedTab(parsed.tabId);
          incrementToolCall(parsed.tabId);
    
          // Read profile from disk
          const profile = await loadProfile(deps.config.profilesDir, parsed.profileId);
    
          const userMismatch = profile.userId !== tracked.userId;
    
          // Import cookies into the session
          await deps.client.importCookies(tracked.userId, profile.cookies, tracked.tabId);
    
          return okResult({
            profileId: profile.profileId,
            cookieCount: profile.metadata.cookieCount,
            lastSaved: profile.metadata.updatedAt,
            description: profile.metadata.description,
            ...(userMismatch
              ? {
                  warning: `Profile was saved for userId "${profile.userId}" but loaded into "${tracked.userId}"`
                }
              : {})
          });
        } catch (error) {
          return toErrorResult(error);
        }
      }
    );
  • Input schema for load_profile: requires profileId (string, min 1 char) and tabId (string, min 1 char).
    {
      profileId: z.string().min(1).describe("Profile name to load"),
      tabId: z.string().min(1).describe("Tab ID to load cookies into")
    },
    async (input: unknown) => {
      try {
        const parsed = z
          .object({
            profileId: z.string().min(1),
            tabId: z.string().min(1)
          })
          .parse(input);
    
        const tracked = getTrackedTab(parsed.tabId);
  • src/server.ts:51-51 (registration)
    Registration of all profile tools (including load_profile) in the MCP server via registerProfileTools().
    registerProfileTools(server, deps);
  • Core loadProfile() helper function. Validates profile ID, reads the JSON file from disk, parses and validates against ProfileSchema, checks profileId match, and returns the Profile object.
    export async function loadProfile(dir: string, profileId: string): Promise<Profile> {
      validateProfileId(profileId);
      const filePath = profilePath(dir, profileId);
    
      let raw: string;
      try {
        raw = await readFile(filePath, "utf-8");
      } catch (error) {
        const parsedError = ErrnoErrorSchema.safeParse(error);
        if (parsedError.success && parsedError.data.code === "ENOENT") {
          throw new AppError("PROFILE_NOT_FOUND", `Profile "${profileId}" not found`);
        }
        throw new AppError(
          "PROFILE_ERROR",
          `Failed to read profile "${profileId}": ${error instanceof Error ? error.message : String(error)}`
        );
      }
    
      let json: unknown;
      try {
        json = JSON.parse(raw);
      } catch {
        throw new AppError("PROFILE_ERROR", `Profile "${profileId}" contains invalid JSON`);
      }
    
      const parsed = ProfileSchema.safeParse(json);
      if (!parsed.success) {
        throw new AppError(
          "PROFILE_ERROR",
          `Profile "${profileId}" has invalid format: ${parsed.error.issues.map((i) => i.message).join(", ")}`
        );
      }
    
      if (parsed.data.profileId !== profileId) {
        throw new AppError(
          "PROFILE_ERROR",
          `Profile file mismatch: expected "${profileId}" but file contains "${parsed.data.profileId}"`
        );
      }
    
      return parsed.data;
    }
  • Zod schemas used for profile validation: ProfileCookieSchema, ProfileMetadataSchema, and ProfileSchema (version, profileId, userId, cookies, metadata).
    const ProfileCookieSchema = z
      .object({
        name: z.string(),
        value: z.string(),
        domain: z.string(),
        path: z.string(),
        expires: z.number().optional(),
        httpOnly: z.boolean().optional(),
        secure: z.boolean().optional(),
        sameSite: z.string().optional()
      })
      .passthrough();
    
    const ProfileMetadataSchema = z.object({
      createdAt: z.string(),
      updatedAt: z.string(),
      lastUrl: z.string().optional().nullable(),
      description: z.string().optional().nullable(),
      cookieCount: z.number()
    });
    
    const ProfileSchema = z.object({
      version: z.literal(1),
      profileId: z.string(),
      userId: z.string(),
      cookies: z.array(ProfileCookieSchema),
      metadata: ProfileMetadataSchema
    });
Behavior3/5

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

No annotations are provided, so the description carries the full disclosure burden. It states it restores cookies and sessions, but it does not mention side effects (e.g., cookie overwriting), prerequisites, or error handling. Basic transparency is present but incomplete.

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?

Three short, focused sentences with no filler. Each sentence adds value: definition, benefit, and usage tip. Highly efficient.

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?

No output schema exists, so return values are not explained. However, for a simple two-parameter tool, the description covers the core behavior and a dependency (create_tab). Lacks error context but is otherwise adequate.

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?

Schema coverage is 100%, so parameters are documented. The description adds context by linking the parameters to the 'restore sessions' action, but does not provide additional constraints or format details beyond the schema. Baseline 3 is appropriate.

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 tool loads a saved profile's cookies into an active browser tab, restoring login sessions. It uses a specific verb ('load') and resource ('profile's cookies'), and distinguishes itself from siblings like save_profile.

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

Usage Guidelines4/5

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

The description explicitly says 'Use after create_tab to restore saved state', providing a clear usage context. It does not explore alternatives or when to avoid, but the guidance is sufficient.

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/redf0x1/camofox-mcp'

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