Skip to main content
Glama

sync_context_files

Sync context files for AI assistants during active sessions to maintain updated documentation without interrupting workflow.

Instructions

Sync all context files (claude.md, gemini.md, agents.md, .cursor/context.md) without closing the session. Useful for mid-session syncs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function that executes the tool logic: syncs context files by generating a unified context from Agent OS files and session summary, then writes it to the specified context files (claude.md, gemini.md, agents.md, .cursor/context.md).
    private async syncContextFiles(summary: SessionSummary): Promise<string[]> { const contextFiles = ['claude.md', 'gemini.md', 'agents.md', '.cursor/context.md']; const updatedFiles: string[] = []; // Read Agent OS context if available const agentOSContext = await this.getAgentOSContext(); // Generate unified context const unifiedContext = this.generateUnifiedContext(agentOSContext, summary); // Update each context file for (const file of contextFiles) { const filePath = path.join(this.projectRoot, file); // Skip if file doesn't exist and isn't required if (!await this.fileExists(filePath) && file !== '.cursor/context.md') { continue; } // Ensure directory exists await fs.mkdir(path.dirname(filePath), { recursive: true }); await fs.writeFile(filePath, unifiedContext, 'utf-8'); updatedFiles.push(file); } return updatedFiles; }
  • Tool schema definition in the ListTools response, including name, description, and input schema (empty object since no parameters are required).
    name: 'sync_context_files', description: 'Sync all context files (claude.md, gemini.md, agents.md, .cursor/context.md) without closing the session. Useful for mid-session syncs.', inputSchema: { type: 'object', properties: {}, }, }, {
  • src/index.ts:131-157 (registration)
    Registration of the tool handler in the CallToolRequestSchema switch statement, which creates a minimal SessionSummary and delegates to the SessionCloser.syncContextFiles method.
    case 'sync_context_files': { // Create a minimal summary for syncing const summary = { timestamp: new Date().toISOString(), accomplishments: ['Context files synced'], decisions: [], blockers: [], nextSteps: [], filesChanged: [], }; // Access private method via type assertion const filesUpdated = await (this.sessionCloser as any).syncContextFiles(summary); return { content: [ { type: 'text', text: JSON.stringify({ success: true, filesUpdated, message: 'Context files synced successfully!', }, null, 2), }, ], }; }
  • Key helper function used by the handler to generate the unified context markdown content that is written to all context files.
    private generateUnifiedContext( agentOS: AgentOSFiles, summary: SessionSummary ): string { const projectName = this.getProjectName(); const recentWork = this.formatRecentWork(summary); const nextSteps = summary.nextSteps.length > 0 ? summary.nextSteps.map(s => `- [ ] ${s}`).join('\n') : agentOS.roadmap ? 'See roadmap for next steps' : 'Continue development'; return `# Project: ${projectName} ## Overview ${agentOS.mission || 'Development project'} ## Current Status - Phase: ${this.getCurrentPhase(agentOS)} - Progress: ${this.calculateProgress(agentOS)} - Last session: ${new Date(summary.timestamp).toLocaleDateString()} ## Recent Work ${recentWork} ## Technology Stack ${agentOS.techStack || 'See tech-stack.md'} ## Key Decisions ${this.formatDecisions(agentOS.decisions || [])} ## Project Structure \`\`\` ${this.getProjectStructure()} \`\`\` ## Next Steps ${nextSteps} ## Related Documents - \`.agent-os/product/mission.md\`: Product mission - \`.agent-os/product/roadmap.md\`: Development roadmap - \`.agent-os/product/decisions.md\`: Decision log - \`.agent-os/session-summary.md\`: Session history `; }

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/Tylarcam/mcp-session-closer'

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