Skip to main content
Glama

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)

Related MCP server: iroha for Notion

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:

  1. Extract session details (accomplishments, decisions, blockers, next steps)

  2. Update .agent-os/session-summary.md

  3. Create Notion entry via MCP (or fallback to Python script)

  4. Update Agent OS roadmap and decisions (if present)

  5. Sync all context files (claude.md, gemini.md, agents.md, .cursor/context.md)

  6. 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:

  1. Gathers Session Info

    • Extracts accomplishments from conversation

    • Identifies decisions made

    • Notes any blockers

    • Lists next steps

    • Tracks changed files

  2. Updates Session Summary

    • Creates/updates .agent-os/session-summary.md

    • Appends session details with timestamp

    • Formats as structured markdown

  3. 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

  4. Syncs Context Files

    • Reads content from all context files

    • Merges and deduplicates content

    • Updates all files with unified context:

      • claude.md

      • gemini.md

      • agents.md

      • .cursor/context.md

  5. 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:

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:

  1. Primary: Uses Notion MCP tools via Docker (mcp/notion:latest)

  2. Fallback: If MCP fails, falls back to direct Notion API calls

  3. 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-blocks tool (preferred) or create-page tool

  • 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.js exists 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-os directory exists (created automatically)

  • Verify write permissions in the workspace

  • Look for errors in Cursor's MCP logs

Notion Entry Not Creating

  • Verify NOTION_API_TOKEN is set correctly

  • Check that NOTION_PAGE_ID or NOTION_DATABASE_ID is configured

  • Ensure Docker can run mcp/notion:latest container

  • 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!

Available Tools

3 tools
end_sessionB

Close the current Cursor session, sync all context files, update Agent OS files, and commit to git. This is the main tool for ending a work session.

ParametersJSON Schema
NameRequiredDescriptionDefault
conversationSummaryYesSummary of what was accomplished in this session. If not provided, will attempt to extract from context.
accomplishmentsNoList of specific accomplishments (optional, will be extracted if not provided)
decisionsNoList of decisions made during this session (optional)
blockersNoList of blockers or issues encountered (optional)
nextStepsNoList of next steps or TODO items (optional)

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions actions like syncing files and committing to git, which imply mutations and potential side effects, but doesn't detail permissions needed, error handling, or what happens if operations fail. For a tool with multiple operations and no annotations, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded, with two sentences that efficiently convey the tool's purpose and main use case. Every sentence adds value without redundancy, though it could be slightly more structured by explicitly listing key actions or outcomes.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (multiple operations like syncing and committing) and lack of annotations or output schema, the description is somewhat incomplete. It covers the high-level purpose but misses details on behavioral traits, error scenarios, and return values. This leaves gaps for an AI agent to fully understand how to invoke it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the input schema already documents all parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema, such as formatting details or examples. Baseline 3 is appropriate when the schema handles parameter documentation effectively.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('Close', 'sync', 'update', 'commit') and resources ('Cursor session', 'context files', 'Agent OS files', 'git'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'sync_context_files' or 'update_session_summary', which might have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by stating 'This is the main tool for ending a work session,' which suggests it should be used to conclude sessions. However, it doesn't provide explicit guidance on when to use this tool versus alternatives like 'sync_context_files' or 'update_session_summary,' nor does it specify prerequisites or exclusions, leaving some ambiguity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

sync_context_filesA

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

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It discloses that the tool performs a sync operation without closing the session, which is useful behavioral context. However, it doesn't mention potential side effects, error conditions, or what 'sync' entails (e.g., overwriting, merging, or validation), leaving gaps in transparency for a mutation-like tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two concise sentences with zero waste. The first sentence states the action and resources, and the second provides usage context. It's front-loaded with the core purpose and efficiently structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, no output schema, and 0 parameters, the description is minimal but covers the basics. It explains what the tool does and when to use it, but for a tool that likely modifies files, it lacks details on behavior, outcomes, or error handling. This makes it adequate but with clear gaps in completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description doesn't add parameter details, which is appropriate here. A baseline of 4 is applied since there are no parameters to explain, and the description focuses on the tool's purpose instead.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Sync all context files') and specifies the resources (claude.md, gemini.md, agents.md, .cursor/context.md). It distinguishes from siblings by mentioning 'without closing the session', which differentiates it from 'end_session'. However, it doesn't explicitly contrast with 'update_session_summary', keeping it from a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('Useful for mid-session syncs'), which implies usage during an ongoing session rather than at the end. It doesn't explicitly state when not to use it or name alternatives like 'update_session_summary', but the mid-session focus gives practical guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

update_session_summaryB

Update the session summary file with current session info without doing a full session close.

ParametersJSON Schema
NameRequiredDescriptionDefault
summaryYesSession summary text to append to session-summary.md

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden. It states the tool updates a file, implying mutation, but doesn't disclose important behavioral traits like whether this requires specific permissions, how conflicts are handled, if changes are reversible, or what happens to existing content. The 'append' behavior is only hinted at in the parameter description, not in the main description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose. It could be slightly more structured by explicitly mentioning the append behavior, but it avoids unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with no annotations and no output schema, the description is insufficient. It doesn't explain what 'update' entails (e.g., append vs. replace), what the session-summary.md file is, or what the tool returns. The context of 'current session info' is vague without elaboration.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with the single parameter 'summary' well-documented in the schema. The description doesn't add any parameter semantics beyond what the schema provides, maintaining the baseline score of 3 for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('update') and resource ('session summary file') with specific context ('without doing a full session close'). It distinguishes from 'end_session' by specifying partial vs. full closure, but doesn't explicitly differentiate from 'sync_context_files'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context ('without doing a full session close'), suggesting this is for incremental updates during an active session rather than final closure. However, it doesn't provide explicit guidance on when to choose this over 'sync_context_files' or what triggers its use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 3 tool updates
    • First observedend_session
    • First observedsync_context_files
    • First observedupdate_session_summary

TDQS

A3.8/5.0

Scored across 3 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: end_session closes the session with full sync and git commit, sync_context_files syncs files without closing, and update_session_summary updates only the summary file. There is no overlap in functionality, making tool selection unambiguous.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern (end_session, sync_context_files, update_session_summary) with snake_case throughout. The naming is predictable and aligns well with their described actions.

Tool Count5/5

With 3 tools, this server is well-scoped for session management tasks. Each tool serves a specific, necessary function (full close, partial sync, summary update), and there are no extraneous or missing tools for the domain.

Completeness5/5

The toolset provides complete coverage for session lifecycle management: end_session handles full closure, sync_context_files allows mid-session syncs, and update_session_summary supports summary updates. There are no obvious gaps, and agents can perform all expected operations without dead ends.

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Provides cross-session memory for Claude Code by extracting structured handoffs at session end and retrieving relevant past context at session start.
    2
    7
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    Persists Claude Code sessions to Notion as team memory, enabling queryable recall of decisions, work state, and project architecture.
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Enables session continuity across AI coding assistants by preserving context and generating handoff markdown, allowing seamless switching between tools like Cursor, Claude Code, and Claude Desktop.
    11
    MIT
  • F
    license
    Not graded
    quality
    A
    maintenance
    Captures a coding agent's session into an Intent Document, enabling guided and verifiable pull-request reviews on GitHub.
    1
    -