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

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.2/5.0
Behavior4/5

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

With no annotations, the description carries the full burden. It discloses the side effect of changing the active default for future ask_question calls and gives auto-switching guidance. It does not cover persistence, errors, or return behavior, but it is honest about the state mutation.

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 front-loaded with a one-sentence purpose, then organized into clear sections. The bullets and example are concise and directly useful for an agent deciding when and how to invoke the tool.

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 one-parameter tool with no output schema, the description is remarkably complete: it defines the effect, gives usage triggers, and provides an example. It could mention how to obtain the notebook ID (e.g., via list_notebooks) and what happens on an invalid ID, but those are minor gaps.

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 for the single 'id' parameter is 100%, so the schema already explains it as 'The notebook ID to activate'. The description adds context about the default mechanism but not much additional parameter-level meaning.

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 opens with a specific verb and resource: 'Set a notebook as the active default'. It also clarifies its role relative to ask_question, which distinguishes it from the notebook CRUD siblings.

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 'When To Use' section gives explicit trigger conditions such as context switches and explicit user requests. It stops short of naming alternatives or stating when not to use the tool, but the provided contexts are clear and actionable.

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