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!
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。