The MCP Session Closer server automates Cursor work session management by syncing context files, updating documentation, creating Notion entries, and committing changes to git.
Available Tools:
end_session: Closes work sessions gracefully by extracting session details (accomplishments, decisions, blockers, next steps), syncing context files across multiple AI assistants (
claude.md,gemini.md,agents.md,.cursor/context.md), updating Agent OS files (session-summary.md, roadmap.md, decisions.md), creating Notion entries, and committing all changes to git with descriptive timestamps.sync_context_files: Synchronizes and deduplicates content across all AI context files without closing the session, maintaining unified context for different assistants.
update_session_summary: Appends timestamped session information to
.agent-os/session-summary.mdwithout performing a full session close, useful for logging progress checkpoints.
Key Features:
Notion Integration: Automatically creates Notion pages or appends blocks with markdown-to-Notion conversion and chunking for large content, using MCP tools with direct API fallback.
Agent OS Support: Updates roadmaps (marks completed items) and decision logs automatically if these files exist, creating them if missing.
Git Integration: Automatically stages and commits all modified files with descriptive messages.
Cross-platform: Works on Windows, macOS, and Linux.
Automatically stages and commits changes to git repositories with descriptive commit messages when closing work sessions
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Session CloserClose this session and sync everything"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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, Notion entry creation, and git commit
sync_context_files: Sync context files across
claude.md,gemini.md,agents.md, and.cursor/context.mdupdate_session_summary: Update session summaries without closing the session
create_notion_entry: Create Notion entries from markdown content (append to page or create in database)
Notion Integration: Automatically creates Notion entries via MCP tools (with Python script fallback)
Quick Setup
1. Install Dependencies
2. Build the Server
3. Configure Cursor
Add to your Cursor MCP settings (~/.cursor/mcp.json or %APPDATA%\Cursor\mcp.json on Windows):
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:
Or use the tool directly:
The server will:
Extract session details (accomplishments, decisions, blockers, next steps)
Update
.agent-os/session-summary.mdCreate Notion entry via MCP (or fallback to Python script)
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
Or:
Update Session Summary Only
Create Notion Entry from Markdown
Create a Notion entry directly from markdown content. This is useful for adding completion reports, documentation, or any structured content to Notion.
Append to existing page:
Create new page in database:
With custom title and date:
Features:
Automatically converts markdown to Notion blocks
Handles large content by chunking (Notion limit: 100 blocks per request)
Extracts title from first H1 if not provided
Extracts date from markdown if present
Falls back to direct Notion API if MCP tools unavailable
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.mdAppends session details with timestamp
Formats as structured markdown
Updates Agent OS (if present)
Marks completed items in
.agent-os/product/roadmap.mdAdds new decisions to
.agent-os/product/decisions.mdMaintains proper markdown structure
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
Notion Integration
The server can automatically create Notion entries when closing sessions, and you can also create entries manually using the create_notion_entry tool. Configure via environment variables:
Required:
NOTION_API_TOKENorNOTION_API_KEYorNOTION_TOKEN- Your Notion integration token (get from https://www.notion.so/my-integrations)
Choose one (for automatic session entries):
NOTION_PAGE_ID- Append blocks to existing page (recommended, avoids serialization issues)NOTION_DATABASE_ID- Create new page in database
Optional:
NOTION_PROJECT- Default project name for database entries (default: "Development")
Example:
How it works:
Primary: Uses Notion MCP tools via Docker (
mcp/notion:latest)Fallback: If MCP fails, falls back to direct Notion API calls
Chunking: Automatically handles large content by splitting into chunks of 100 blocks (Notion API limit)
Note: When using create_notion_entry tool, you can override environment variables by passing pageId, databaseId, title, date, or project as parameters.
MCP Integration:
Connects to Notion MCP server via Docker stdio transport
Uses
append-blockstool (preferred) orcreate-pagetoolHandles parameter serialization correctly
Non-blocking: errors don't fail session close
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
Build
Start Production Server
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 initConfigure 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
Notion Entry Not Creating
Verify
NOTION_API_TOKENis set correctlyCheck that
NOTION_PAGE_IDorNOTION_DATABASE_IDis configuredEnsure Docker can run
mcp/notion:latestcontainerCheck Docker logs:
docker logs mcp-notion(if running as container)Verify Notion integration has access to the target page/database
If MCP fails, check if Python fallback script exists and is executable
Project Structure
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!