Skip to main content
Glama
yywdandan

Memory Bank MCP Server

by yywdandan

archive_completed_tasks

Move completed tasks to a specified archive file in the Memory Bank MCP Server, enabling organized project management and efficient task tracking.

Instructions

归档已完成任务

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
destinationNo归档目标文件
projectIdYes项目ID

Implementation Reference

  • The primary handler function implementing the logic to archive completed tasks. It parses the tasks markdown, identifies completed tasks under the '已完成任务' section, removes them from the main tasks doc, and creates a new archive document.
    export const archiveCompletedTasks = async (projectId: string, destination?: string) => {
      try {
        // 检查项目是否存在
        const project = await projectStorage.getById(projectId);
        if (!project) throw new Error('项目不存在');
        
        // 获取tasks文档
        const docs = await documentStorage.getByProjectId(projectId);
        const tasksDoc = docs.find(d => d.type === 'tasks');
        
        if (!tasksDoc) {
          throw new Error('任务文档不存在,请先运行van_verify初始化核心文档');
        }
        
        // 解析文档内容
        const lines = tasksDoc.content.split('\n');
        const completedTasks = [];
        const remainingLines = [];
        let inCompletedSection = false;
        
        // 查找已完成任务部分,收集已完成的任务
        for (let i = 0; i < lines.length; i++) {
          const line = lines[i];
          
          // 检查是否进入已完成任务部分
          if (line.match(/^##\s+已完成任务/)) {
            inCompletedSection = true;
            remainingLines.push(line); // 保留部分标题
            continue;
          }
          
          // 检查是否离开已完成任务部分
          if (inCompletedSection && line.match(/^##\s+/)) {
            inCompletedSection = false;
          }
          
          // 收集已完成的任务
          if (inCompletedSection && line.trim().startsWith('- [x]')) {
            completedTasks.push(line);
          } else {
            remainingLines.push(line);
          }
        }
        
        // 如果没有找到已完成任务,返回
        if (completedTasks.length === 0) {
          return {
            status: 'success',
            message: '没有找到已完成任务,无需归档',
            archivedTasks: 0
          };
        }
        
        // 更新任务文档,移除已归档的任务
        const updatedTasksContent = remainingLines.join('\n');
        await documentStorage.update(tasksDoc.id, updatedTasksContent);
        
        // 准备归档内容
        const archiveDate = new Date().toISOString().split('T')[0];
        const archiveTitle = `# 已归档任务 (${archiveDate})\n\n`;
        const archiveContent = archiveTitle + completedTasks.join('\n') + '\n';
        
        // 确定归档目标
        const archiveDestination = destination || `archived_tasks_${archiveDate}.md`;
        
        // 创建归档文档
        await documentStorage.create(
          projectId,
          archiveDestination,
          archiveContent,
          'archive_' + Date.now()
        );
        
        return {
          status: 'success',
          message: '任务归档成功',
          archive: {
            archivedTasks: completedTasks.length,
            destination: archiveDestination,
            archivedAt: new Date().toISOString()
          }
        };
      } catch (error) {
        console.error('归档已完成任务错误:', error);
        throw new Error('归档已完成任务失败');
      }
    };
  • JSON schema defining the input parameters for the tool: required projectId (string) and optional destination (string).
    inputSchema: {
      type: 'object',
      properties: {
        projectId: {
          type: 'string',
          description: '项目ID',
        },
        destination: {
          type: 'string',
          description: '归档目标文件',
        },
      },
      required: ['projectId'],
    }
  • MCP server request handler case that dispatches the tool call to the archiveCompletedTasks function from tools module, including parameter validation.
    case 'archive_completed_tasks': {
      if (!args.projectId) {
        throw new McpError(ErrorCode.InvalidParams, '项目ID不能为空');
      }
      return this.formatResponse(await tools.archiveCompletedTasks(
        args.projectId as string,
        args.destination as string | undefined
      ));
  • Tool registration in the MCP server's tools list, specifying name, description, and input schema.
    {
      name: 'archive_completed_tasks',
      description: '归档已完成任务',
      inputSchema: {
        type: 'object',
        properties: {
          projectId: {
            type: 'string',
            description: '项目ID',
          },
          destination: {
            type: 'string',
            description: '归档目标文件',
          },
        },
        required: ['projectId'],
      }
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 states the action ('归档' - archive) but doesn't explain what 'archive' entails (e.g., moving tasks, marking as archived, deleting, or storing elsewhere), potential side effects, permissions required, or rate limits. This is a significant gap for a mutation tool with zero annotation coverage.

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 phrase ('归档已完成任务') that is front-loaded and wastes no words. It directly conveys the core action without unnecessary elaboration, making it highly concise and well-structured for its purpose.

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 a mutation tool with no annotations and no output schema, the description is incomplete. It lacks details on what archiving entails, behavioral traits, return values, or how it differs from sibling tools. This leaves critical gaps for an agent to understand and invoke the tool correctly.

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 schema description coverage is 100%, with both parameters ('destination' and 'projectId') documented in the schema. The description adds no additional meaning beyond what the schema provides, such as explaining the relationship between parameters or usage examples. Baseline 3 is appropriate when the schema does the heavy lifting.

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 '归档已完成任务' (Archive completed tasks) clearly states the verb ('归档' - archive) and resource ('已完成任务' - completed tasks), providing a basic purpose. However, it doesn't differentiate from sibling tools like 'archive_export_project' or 'archive_generate_summary', leaving ambiguity about what specifically distinguishes this archiving operation from others.

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. There are no explicit instructions on prerequisites, context, or exclusions, and it doesn't mention sibling tools like 'archive_export_project' or 'archive_generate_summary' that might handle related archiving functions, leaving usage unclear.

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/yywdandan/memory-bank-mcp-server'

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