Skip to main content
Glama

manage_preferences

Customize documentation generation settings and static site generator recommendations based on user preferences for technical expertise, style, and technologies.

Instructions

Manage user preferences for documentation generation and SSG recommendations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
actionYesAction to perform on preferences
userIdNoUser ID for multi-user setupsdefault
preferencesNoPreference updates (for update action)
jsonNoJSON string for import action

Implementation Reference

  • The core handler function for the 'manage_preferences' tool. It validates input using Zod schema, handles various actions (get, update, reset, export, import, recommendations) by interacting with the user preference manager, formats MCP response, and provides next steps.
    export async function managePreferences(
      args: unknown,
    ): Promise<{ content: any[] }> {
      const startTime = Date.now();
    
      try {
        const { action, userId, preferences, json } = inputSchema.parse(args);
    
        const manager = await getUserPreferenceManager(userId);
    
        let result: any;
        let actionDescription: string;
    
        switch (action) {
          case "get":
            result = await manager.getPreferences();
            actionDescription = "Retrieved user preferences";
            break;
    
          case "update":
            if (!preferences) {
              throw new Error("Preferences object required for update action");
            }
            result = await manager.updatePreferences(preferences);
            actionDescription = "Updated user preferences";
            break;
    
          case "reset":
            result = await manager.resetPreferences();
            actionDescription = "Reset preferences to defaults";
            break;
    
          case "export": {
            const exportedJson = await manager.exportPreferences();
            result = { exported: exportedJson };
            actionDescription = "Exported preferences as JSON";
            break;
          }
    
          case "import": {
            if (!json) {
              throw new Error("JSON string required for import action");
            }
            result = await manager.importPreferences(json);
            actionDescription = "Imported preferences from JSON";
            break;
          }
    
          case "recommendations": {
            const recommendations = await manager.getSSGRecommendations();
            result = {
              recommendations,
              summary: `Found ${recommendations.length} SSG recommendation(s) based on usage history`,
            };
            actionDescription = "Retrieved SSG recommendations";
            break;
          }
    
          default:
            throw new Error(`Unknown action: ${action}`);
        }
    
        const response: MCPToolResponse<any> = {
          success: true,
          data: result,
          metadata: {
            toolVersion: "1.0.0",
            executionTime: Date.now() - startTime,
            timestamp: new Date().toISOString(),
          },
          recommendations: [
            {
              type: "info",
              title: actionDescription,
              description: `User preferences ${action} completed successfully for user: ${userId}`,
            },
          ],
        };
    
        // Add context-specific next steps
        if (action === "get" || action === "recommendations") {
          response.nextSteps = [
            {
              action: "Update Preferences",
              toolRequired: "manage_preferences",
              description: "Modify your preferences using the update action",
              priority: "medium",
            },
          ];
        } else if (action === "update" || action === "import") {
          response.nextSteps = [
            {
              action: "Test Recommendations",
              toolRequired: "recommend_ssg",
              description: "See how your preferences affect SSG recommendations",
              priority: "high",
            },
          ];
        }
    
        return formatMCPResponse(response);
      } catch (error) {
        const errorResponse: MCPToolResponse = {
          success: false,
          error: {
            code: "PREFERENCE_MANAGEMENT_FAILED",
            message: `Failed to manage preferences: ${error}`,
            resolution:
              "Check that action and parameters are valid, and user ID exists",
          },
          metadata: {
            toolVersion: "1.0.0",
            executionTime: Date.now() - startTime,
            timestamp: new Date().toISOString(),
          },
        };
        return formatMCPResponse(errorResponse);
      }
    }
  • Zod schema defining the input parameters for the manage_preferences tool, including action enum and optional preferences object with fields like preferredSSGs, documentationStyle, etc.
    const inputSchema = z.object({
      action: z.enum([
        "get",
        "update",
        "reset",
        "export",
        "import",
        "recommendations",
      ]),
      userId: z.string().optional().default("default"),
      preferences: z
        .object({
          preferredSSGs: z.array(z.string()).optional(),
          documentationStyle: z
            .enum(["minimal", "comprehensive", "tutorial-heavy"])
            .optional(),
          expertiseLevel: z
            .enum(["beginner", "intermediate", "advanced"])
            .optional(),
          preferredTechnologies: z.array(z.string()).optional(),
          preferredDiataxisCategories: z
            .array(z.enum(["tutorials", "how-to", "reference", "explanation"]))
            .optional(),
          autoApplyPreferences: z.boolean().optional(),
        })
        .optional(),
      json: z.string().optional(), // For import action
    });
Behavior2/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 mentions 'manage' which implies CRUD operations, but doesn't specify if actions like 'update' or 'reset' are destructive, require specific permissions, or have side effects. It also omits details on rate limits, error handling, or response formats, making it insufficient for a tool with multiple actions and parameters.

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, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core functionality and avoids redundancy, making it easy for an agent to parse quickly.

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?

Given the tool's complexity (4 parameters, nested objects, multiple actions) and lack of annotations and output schema, the description is incomplete. It doesn't cover behavioral aspects like mutation effects, authentication needs, or return values, which are critical for proper tool invocation. This leaves significant gaps in understanding how to use the tool effectively.

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 100% description coverage, so the schema already documents all parameters (action, userId, preferences, json) thoroughly. The description adds no additional parameter semantics beyond what's in the schema, such as explaining the relationships between actions and parameters. This meets the baseline score since the schema does the heavy lifting.

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: 'Manage user preferences for documentation generation and SSG recommendations.' It specifies the verb ('manage') and resource ('user preferences'), with context about the domain (documentation generation and SSG recommendations). However, it doesn't explicitly differentiate from sibling tools like 'recommend_ssg' or 'generate_readme_template', which might overlap in functionality, so it doesn't reach a perfect score.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, such as whether user authentication is required, or compare it to sibling tools like 'recommend_ssg' for SSG-specific tasks. This lack of context leaves the agent without clear usage instructions.

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/tosin2013/documcp'

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