MCP Session Closer
Gracefully closes Cursor work sessions by syncing context files across multiple AI assistants, updating Agent OS files, and automatically committing changes to git with descriptive messages.
README
MCP Session Closer
A Model Context Protocol (MCP) server for Cursor that gracefully closes work sessions, syncs context files, updates Agent OS files, and commits changes to git.
Features
- end_session: Close Cursor sessions with automatic context sync and git commit
- sync_context_files: Sync context files across
claude.md,gemini.md,agents.md, and.cursor/context.md - update_session_summary: Update session summaries without closing the session
Quick Setup
1. Install Dependencies
npm install
2. Build the Server
npm run build
3. Configure Cursor
Add to your Cursor MCP settings (~/.cursor/mcp.json or %APPDATA%\Cursor\mcp.json on Windows):
{
"mcpServers": {
"session-closer": {
"command": "node",
"args": [
"/path/to/mcp-session-closer/dist/index.js"
],
"env": {
"CURSOR_WORKSPACE": "${workspaceFolder}"
}
}
}
}
Note: Replace /path/to/mcp-session-closer with your actual path. On Windows, use forward slashes or double backslashes.
4. Restart Cursor
Restart Cursor to load the MCP server.
Usage
End Session
In Cursor chat, simply ask:
Close this session and sync everything
Or use the tool directly:
Use end_session with conversationSummary: "Implemented user auth, fixed login bugs"
The server will:
- Extract session details (accomplishments, decisions, blockers, next steps)
- Update
.agent-os/session-summary.md - Update Agent OS roadmap and decisions (if present)
- Sync all context files (
claude.md,gemini.md,agents.md,.cursor/context.md) - Commit all changes to git with descriptive message
Sync Context Files Only
Sync context files
Or:
Use sync_context_files
Update Session Summary Only
Use update_session_summary with summary: "Made progress on feature X"
How It Works
Session Closing Flow
When you call end_session, the server automatically:
-
Gathers Session Info
- Extracts accomplishments from conversation
- Identifies decisions made
- Notes any blockers
- Lists next steps
- Tracks changed files
-
Updates Session Summary
- Creates/updates
.agent-os/session-summary.md - Appends session details with timestamp
- Formats as structured markdown
- Creates/updates
-
Updates Agent OS (if present)
- Marks completed items in
.agent-os/product/roadmap.md - Adds new decisions to
.agent-os/product/decisions.md - Maintains proper markdown structure
- Marks completed items in
-
Syncs Context Files
- Reads content from all context files
- Merges and deduplicates content
- Updates all files with unified context:
claude.mdgemini.mdagents.md.cursor/context.md
-
Commits to Git
- Stages all modified files
- Creates descriptive commit message
- Commits with timestamp
Configuration
Required Environment Variables
CURSOR_WORKSPACE- Set automatically by Cursor to the current workspace folder
Optional Files
The server works with or without these files:
.agent-os/session-summary.md- Session history (created if missing).agent-os/product/roadmap.md- Product roadmap (updated if present).agent-os/product/decisions.md- Decision log (updated if present)claude.md,gemini.md,agents.md,.cursor/context.md- Context files
Development
Run in Development Mode
npm run dev
Build
npm run build
Start Production Server
npm start
Troubleshooting
MCP Server Not Found
- Verify the path in Cursor MCP config is correct
- Use forward slashes or escaped backslashes on Windows
- Check that
dist/index.jsexists after building
Git Commit Fails
- Ensure git is initialized:
git init - Configure git user:
git config user.name "Your Name" git config user.email "your.email@example.com" - Check you have write permissions
Context Files Not Syncing
- Verify write permissions in the workspace directory
- Check that no other processes are locking the files
- Ensure the workspace path is correct
Session Summary Not Updating
- Check that
.agent-osdirectory exists (created automatically) - Verify write permissions in the workspace
- Look for errors in Cursor's MCP logs
Project Structure
mcp-session-closer/
├── src/
│ ├── index.ts # MCP server implementation
│ ├── session-closer.ts # Core session closing logic
│ └── types.ts # TypeScript type definitions
├── dist/ # Compiled JavaScript (generated)
├── package.json # Node.js dependencies
├── tsconfig.json # TypeScript configuration
└── README.md # This file
Why Use This?
Automated Workflow
- No Manual Steps: Automatically syncs, updates, and commits
- Consistent Format: Standardized session summaries and git commits
- Time Saver: Closes sessions in seconds, not minutes
Context Continuity
- Unified Context: All AI assistants see the same project context
- Cross-Session Memory: Session summaries persist across restarts
- Decision Tracking: Maintains history of why decisions were made
Git Integration
- Automatic Commits: Never forget to commit your work
- Descriptive Messages: Auto-generated commit messages with context
- Clean History: Organized commits at natural breakpoints
License
MIT
Contributing
This is a personal tool, but feel free to fork and adapt it for your needs!
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.