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;
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4/5.0
Behavior3/5

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

With no annotations available, the description carries the safety burden. The 'ask before closing' guardrail signals that closing can be disruptive and requires user consent, but it never states what closing actually does, whether it can be undone, or side effects on the current workflow.

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?

Two short sentences with no filler. The core action is front-loaded, and the safety instruction earns its place.

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

Completeness4/5

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

For a single-parameter tool with no output schema and a simple action, this definition is nearly sufficient: it gives the target, the ID source, and the key caution. It is only missing a clear statement of consequences and a pointer to the related reset_session alternative.

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 coverage is 100%, and the schema already documents session_id as 'The session ID to close.' The description's 'by session ID' adds no new parameter semantics, so the baseline of 3 is appropriate.

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

Purpose5/5

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

The description uses a specific verb and target ('Close a specific session by session ID'), making the tool's purpose unambiguous. The action is distinct from siblings like list_sessions and reset_session, even though no sibling is named.

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?

It gives an explicit behavioral rule: ask before closing if the user might still need the session, which tells the agent when invocation is appropriate. It does not name alternatives or list when not to use it, so it falls just short of full guidance.

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