end_session
End active work sessions and record final outcomes. Marks sessions as completed while saving optional summaries of accomplishments, status updates, or abandoned work.
Instructions
End a session and record what was accomplished.
Marks the session as completed and optionally saves a summary.
Consider calling promote_session first to save key learnings
as permanent memories before ending.
Use this when:
Work is finished:
end_session("s001", summary="Auth migration complete, all tests passing")Abandoning a session:
end_session("s001", summary="Deprioritized — will revisit Q3")Wrapping up for the day with a status update
The session data is retained for 48 hours after completion, then auto-expires. Promoted memories persist forever.
Args: session_id: The session to complete (e.g., "s001"). summary: Optional final summary of the outcome. If omitted, the session closes without a summary. Include what was accomplished and any follow-up items.
Returns: The final session state with status "completed". Returns an error if the session doesn't exist or was already ended.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes | ||
| summary | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- server.py:273-299 (handler)The main handler function for the 'end_session' tool. Decorated with @mcp.tool() to register it as an MCP tool. It accepts session_id (required) and summary (optional) parameters and delegates the actual execution to the _proxy helper function.
@mcp.tool() async def end_session(session_id: str, summary: Optional[str] = None) -> str: """End a session and record what was accomplished. Marks the session as completed and optionally saves a summary. Consider calling `promote_session` first to save key learnings as permanent memories before ending. Use this when: - Work is finished: `end_session("s001", summary="Auth migration complete, all tests passing")` - Abandoning a session: `end_session("s001", summary="Deprioritized — will revisit Q3")` - Wrapping up for the day with a status update The session data is retained for 48 hours after completion, then auto-expires. Promoted memories persist forever. Args: session_id: The session to complete (e.g., "s001"). summary: Optional final summary of the outcome. If omitted, the session closes without a summary. Include what was accomplished and any follow-up items. Returns: The final session state with status "completed". Returns an error if the session doesn't exist or was already ended. """ return await _proxy("end_session", session_id=session_id, summary=summary) - server.py:432-452 (helper)The _proxy helper function that actually executes the tool logic. It makes an authenticated SSE transport call to the remote Astria instance to perform the end_session operation. This is the core execution logic shared by all tools in this MCP server.
async def _proxy(tool_name: str, **kwargs) -> str: """Proxy a tool call to the remote Astria instance.""" headers = {} if API_KEY: headers["Authorization"] = f"Bearer {API_KEY}" try: transport = SSETransport(sse_url, headers=headers) async with Client(transport) as client: result = await client.call_tool(tool_name, kwargs) # FastMCP 3.2: result is CallToolResult with .content list if hasattr(result, 'content'): parts = result.content if parts and len(parts) > 0: return parts[0].text if hasattr(parts[0], 'text') else str(parts[0]) # Fallback for older API if hasattr(result, 'text'): return result.text return str(result) except Exception as e: return f"Connection error: {e}. Verify your ASTRIA_ENDPOINT and ASTRIA_API_KEY."