Skip to main content
Glama

select_notebook

Activate a specific notebook as the default context for AI queries, enabling focused document-based responses without manual switching.

Instructions

Set a notebook as the active default (used when ask_question has no notebook_id).

When To Use

  • User switches context: "Let's work on React now"

  • User asks explicitly to activate a notebook

  • Obvious task change requires another notebook

Auto-Switching

  • Safe to auto-switch if the context is clear and you announce it: "Switching to React notebook for this task..."

  • If ambiguous, ask: "Switch to [notebook] for this task?"

Example

User: "Now let's build the React frontend" You: "Switching to React notebook..." (call select_notebook)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesThe notebook ID to activate

Implementation Reference

  • Main handler function that executes the select_notebook tool logic. It validates the notebook ID, calls the library's selectNotebook method, and returns success/error with the selected notebook.
    /** * Handle select_notebook tool */ async handleSelectNotebook(args: { id: string }): Promise<ToolResult<{ notebook: any }>> { log.info(`🔧 [TOOL] select_notebook called`); log.info(` ID: ${args.id}`); try { const notebook = this.library.selectNotebook(args.id); log.success(`✅ [TOOL] select_notebook completed: ${notebook.name}`); return { success: true, data: { notebook }, }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); log.error(`❌ [TOOL] select_notebook failed: ${errorMessage}`); return { success: false, error: errorMessage, }; } }
  • Tool definition including name, detailed description, strict input schema requiring 'id' parameter, and usage guidelines.
    { name: "select_notebook", description: `Set a notebook as the active default (used when ask_question has no notebook_id). ## When To Use - User switches context: "Let's work on React now" - User asks explicitly to activate a notebook - Obvious task change requires another notebook ## Auto-Switching - Safe to auto-switch if the context is clear and you announce it: "Switching to React notebook for this task..." - If ambiguous, ask: "Switch to [notebook] for this task?" ## Example User: "Now let's build the React frontend" You: "Switching to React notebook..." (call select_notebook)`, inputSchema: { type: "object", properties: { id: { type: "string", description: "The notebook ID to activate", }, }, required: ["id"], }, },
  • Central function that aggregates and registers all tool definitions, including notebookManagementTools containing select_notebook, for export to the MCP server.
    export function buildToolDefinitions(library: NotebookLibrary): Tool[] { // Update the description for ask_question based on the library state const dynamicAskQuestionTool = { ...askQuestionTool, description: buildAskQuestionDescription(library), }; return [ dynamicAskQuestionTool, ...notebookManagementTools, ...sessionManagementTools, ...systemTools, ]; }
  • Core helper method implementing the selection logic: retrieves notebook, sets as active in library state, updates last_used timestamp, persists to JSON file, and returns the updated entry.
    selectNotebook(id: string): NotebookEntry { const notebook = this.getNotebook(id); if (!notebook) { throw new Error(`Notebook not found: ${id}`); } log.info(`🎯 Selecting notebook: ${id}`); const updated = { ...this.library }; updated.active_notebook_id = id; // Update last_used const notebookIndex = updated.notebooks.findIndex((n) => n.id === id); updated.notebooks[notebookIndex] = { ...notebook, last_used: new Date().toISOString(), }; this.saveLibrary(updated); log.success(`✅ Active notebook: ${id}`); return updated.notebooks[notebookIndex]; }

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