Tylarcam/mcp-session-closer
If you are the rightful owner of mcp-session-closer and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The MCP Session Closer is a server designed to manage and close work sessions in Cursor, ensuring that all context files are synchronized, session summaries are updated, and changes are committed to git.
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.md - update_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
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 - Create 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
Sync context files
Or:
Use sync_context_files
Update Session Summary Only
Use update_session_summary with summary: "Made progress on feature X"
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:
Use create_notion_entry with markdownContent: "# My Report\n\nContent here..." and pageId: "your-page-id"
Create new page in database:
Use create_notion_entry with markdownContent: "# My Report\n\nContent here..." and databaseId: "your-database-id"
With custom title and date:
Use create_notion_entry with markdownContent: "# My Report\n\nContent here...", databaseId: "your-database-id", title: "Custom Title", date: "2026-02-08", project: "Development"
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.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
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:
export NOTION_API_TOKEN="ntn_your_token_here"
export NOTION_DATABASE_ID="2ba968fc-73c0-8045-b1c7-c89951ece547"
export NOTION_PROJECT="Development"
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-pagetool - Handles 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
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
Notion Entry Not Creating
- Verify
NOTION_API_TOKENis set correctly - Check that
NOTION_PAGE_IDorNOTION_DATABASE_IDis configured - Ensure Docker can run
mcp/notion:latestcontainer - Check 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
mcp-session-closer/
├── src/
│ ├── index.ts # MCP server implementation
│ ├── session-closer.ts # Core session closing logic
│ ├── notion-client.ts # Notion MCP client wrapper
│ └── types.ts # TypeScript type definitions
├── dist/ # Compiled JavaScript (generated)
├── package.json # Node.js dependencies
├── tsconfig.json # TypeScript configuration
├── Dockerfile # Docker build configuration
├── docker-compose.yml # Docker Compose 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!