Skip to main content
Glama

close_session

Ends a specific NotebookLM session by ID to manage resources and maintain organization. Confirm closure if the session might still be active.

Instructions

Close a specific session by session ID. Ask before closing if the user might still need it.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
session_idYesThe session ID to close

Implementation Reference

  • The main handler function that implements the close_session tool logic. It takes session_id, calls sessionManager.closeSession, and returns success/error status.
    /** * Handle close_session tool */ async handleCloseSession(args: { session_id: string }): Promise< ToolResult<{ status: string; message: string; session_id: string }> > { const { session_id } = args; log.info(`🔧 [TOOL] close_session called`); log.info(` Session ID: ${session_id}`); try { const closed = await this.sessionManager.closeSession(session_id); if (closed) { log.success(`✅ [TOOL] close_session completed`); return { success: true, data: { status: "success", message: `Session ${session_id} closed successfully`, session_id, }, }; } else { log.warning(`⚠️ [TOOL] Session ${session_id} not found`); return { success: false, error: `Session ${session_id} not found`, }; } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); log.error(`❌ [TOOL] close_session failed: ${errorMessage}`); return { success: false, error: errorMessage, }; } }
  • Tool schema definition: name, description, and inputSchema requiring session_id.
    { name: "close_session", description: "Close a specific session by session ID. Ask before closing if the user might still need it.", inputSchema: { type: "object", properties: { session_id: { type: "string", description: "The session ID to close", }, }, required: ["session_id"], }, },
  • src/index.ts:236-240 (registration)
    Registration/dispatch in the MCP server's CallToolRequestSchema handler switch statement.
    case "close_session": result = await this.toolHandlers.handleCloseSession( args as { session_id: string } ); break;
  • Core helper method in SessionManager that closes the browser session and removes it from the map.
    async closeSession(sessionId: string): Promise<boolean> { if (!this.sessions.has(sessionId)) { log.warning(`⚠️ Session ${sessionId} not found`); return false; } const session = this.sessions.get(sessionId)!; await session.close(); this.sessions.delete(sessionId); log.success( `✅ Session ${sessionId} closed (${this.sessions.size}/${this.maxSessions} active)` ); return true; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/inventra/notebooklm-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server