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,
      ],
    }));
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the action ('update') without disclosing behavioral traits. It doesn't specify whether this is a mutation, what permissions are needed, if changes are reversible, or any side effects (e.g., overwriting existing data), which is inadequate for a tool that likely modifies a file.

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?

The description is a single, efficient sentence with no wasted words, making it appropriately concise. However, it lacks front-loading of critical details (e.g., purpose differentiation), slightly reducing its effectiveness despite the brevity.

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 complexity of updating a context file with no annotations or output schema, the description is incomplete. It doesn't explain what the active context file is, how updates are applied (e.g., append vs. replace), or what the tool returns, leaving significant gaps for the agent to infer from sibling tools or trial-and-error.

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, clearly documenting parameters (issues, nextSteps, tasks) as arrays of strings. The description adds no meaning beyond this, but the schema provides sufficient detail, so the baseline score of 3 is appropriate as it doesn't compensate for gaps but doesn't need to.

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

Purpose2/5

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

The description 'Update the active context file' restates the tool name with minimal elaboration, making it tautological. While it specifies the resource ('active context file'), it doesn't clarify what 'update' entails or distinguish this from sibling tools like 'write_memory_bank_file' or 'log_decision', which may involve similar file operations.

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

Usage Guidelines1/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. It doesn't mention prerequisites, context (e.g., when the active context file is relevant), or exclusions, leaving the agent to guess based on sibling tool names like 'write_memory_bank_file' or 'track_progress' without explicit direction.

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

Related 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/aakarsh-sasi/memory-bank-mcp'

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