Skip to main content
Glama

update_active_context

Modify the active context file to track ongoing tasks, known issues, and next steps, ensuring centralized and up-to-date information in the MCP server with SSH support.

Instructions

Update the active context file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
issuesNoList of known issues
nextStepsNoList of next steps
tasksNoList of ongoing tasks

Implementation Reference

  • Handler function that processes the 'update_active_context' tool call by invoking ProgressTracker.updateActiveContext with the provided context (tasks, issues, nextSteps).
    export async function handleUpdateActiveContext(
      progressTracker: ProgressTracker,
      context: {
        tasks?: string[];
        issues?: string[];
        nextSteps?: string[];
      }
    ) {
      try {
        await progressTracker.updateActiveContext(context);
    
        return {
          content: [
            {
              type: 'text',
              text: 'Active context updated successfully',
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: 'text',
              text: `Error updating active context: ${error}`,
            },
          ],
          isError: true,
        };
      }
    }
  • Core implementation of updateActiveContext method that reads active-context.md, updates or creates markdown sections for ongoing tasks, known issues, and next steps based on input, then writes back to the file.
    async updateActiveContext(context: {
      tasks?: string[];
      issues?: string[];
      nextSteps?: string[];
    }): Promise<void> {
      const contextPath = path.join(this.memoryBankDir, 'active-context.md');
      
      try {
        let contextContent = await FileUtils.readFile(contextPath);
        
        // Update ongoing tasks
        if (context.tasks && context.tasks.length > 0) {
          const tasksSection = `## Ongoing Tasks\n\n${context.tasks.map(task => `- ${task}`).join('\n')}\n`;
          
          if (/## Ongoing Tasks\s+([^#]*)/s.test(contextContent)) {
            contextContent = contextContent.replace(/## Ongoing Tasks\s+([^#]*)/s, tasksSection);
          } else {
            // If the section doesn't exist, add it
            contextContent += `\n\n${tasksSection}`;
          }
        }
        
        // Update known issues
        if (context.issues && context.issues.length > 0) {
          const issuesSection = `## Known Issues\n\n${context.issues.map(issue => `- ${issue}`).join('\n')}\n`;
          
          if (/## Known Issues\s+([^#]*)/s.test(contextContent)) {
            contextContent = contextContent.replace(/## Known Issues\s+([^#]*)/s, issuesSection);
          } else {
            // If the section doesn't exist, add it
            contextContent += `\n\n${issuesSection}`;
          }
        }
        
        // Update next steps
        if (context.nextSteps && context.nextSteps.length > 0) {
          const nextStepsSection = `## Next Steps\n\n${context.nextSteps.map(step => `- ${step}`).join('\n')}\n`;
          
          if (/## Next Steps\s+([^#]*)/s.test(contextContent)) {
            contextContent = contextContent.replace(/## Next Steps\s+([^#]*)/s, nextStepsSection);
          } else {
            // If the section doesn't exist, add it
            contextContent += `\n\n${nextStepsSection}`;
          }
        }
        
        await FileUtils.writeFile(contextPath, contextContent);
      } catch (error) {
        console.error(`Error updating active context: ${error}`);
        throw new Error(`Failed to update active context: ${error}`);
      }
    }
  • Tool schema definition in contextTools array, specifying name 'update_active_context', description, and inputSchema for arrays of tasks, issues, nextSteps.
    {
      name: 'update_active_context',
      description: 'Update the active context file',
      inputSchema: {
        type: 'object',
        properties: {
          tasks: {
            type: 'array',
            items: {
              type: 'string',
            },
            description: 'List of ongoing tasks',
          },
          issues: {
            type: 'array',
            items: {
              type: 'string',
            },
            description: 'List of known issues',
          },
          nextSteps: {
            type: 'array',
            items: {
              type: 'string',
            },
            description: 'List of next steps',
          },
        },
      },
    },
  • Registration and dispatching logic in the main CallToolRequestSchema handler: switch case for 'update_active_context' that extracts arguments and calls handleUpdateActiveContext.
    // Context tools
    case 'update_active_context': {
      const progressTracker = getProgressTracker();
      if (!progressTracker) {
        return {
          content: [
            {
              type: 'text',
              text: 'Memory Bank not found. Use initialize_memory_bank to create one.',
            },
          ],
          isError: true,
        };
      }
    
      const { tasks, issues, nextSteps } = request.params.arguments as {
        tasks?: string[];
        issues?: string[];
        nextSteps?: string[];
      };
      return handleUpdateActiveContext(progressTracker, { tasks, issues, nextSteps });
    }
  • Tool list registration: includes ...contextTools in the tools array returned by ListToolsRequestSchema handler, making the tool discoverable by MCP clients.
    // Register tools for listing
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        ...coreTools,
        ...progressTools,
        ...contextTools,
        ...decisionTools,
        ...modeTools,
      ],
    }));

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

C2.2/5.0
Behavior1/5

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

With no annotations, the description must convey behavioral traits. It fails to disclose whether updates are destructive, append vs. replace, or require any prerequisites. The single sentence offers no behavioral insight beyond the action.

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

Conciseness2/5

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

At only 5 words, the description is extremely terse. While concise, it omits necessary details, making it under-specified rather than efficiently structured.

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 has 3 optional parameters and no output schema, the description should explain how parameters relate, default behavior, and the concept of 'active context'. It provides none of this, leaving the agent underinformed.

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?

All three parameters (tasks, issues, nextSteps) have descriptions in the schema (100% coverage). The description adds no additional meaning beyond what the schema already provides, so baseline 3 is appropriate.

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

Purpose3/5

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

The description states the tool updates the 'active context file', providing a verb and resource. However, it lacks specificity about what fields are updated (tasks, issues, nextSteps) and does not differentiate from sibling tools like 'update_tasks', which may have overlapping functionality.

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 is provided on when to use this tool versus alternatives (e.g., update_tasks, add_progress_entry). The description offers no context for appropriate invocation.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools

Related Tools