Skip to main content
Glama
azharlabs
by azharlabs

list_cells

Retrieve all cells from a Jupyter notebook with their indices and types to inspect notebook structure and content organization.

Instructions

List all cells in a Jupyter notebook with their indices and types

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
notebook_pathYesAbsolute path to the Jupyter notebook file

Implementation Reference

  • The handler function that reads a Jupyter notebook file, extracts information about each cell (index, type, and preview of source), and returns a formatted text list of all cells.
    async listCells(notebookPath) {
      const notebook = await this.readNotebook(notebookPath);
      const cellsInfo = notebook.cells.map((cell, index) => {
        const source = Array.isArray(cell.source) ? cell.source.join('') : cell.source;
        const preview = source.length > 100 ? source.substring(0, 100) + '...' : source;
        
        return {
          index,
          type: cell.cell_type,
          preview: preview.replace(/\\n/g, ' ')
        };
      });
    
      return {
        content: [
          {
            type: "text",
            text: `Notebook: ${notebookPath}\nTotal cells: ${cellsInfo.length}\n\n${
              cellsInfo.map(cell => 
                `[${cell.index}] ${cell.type}: ${cell.preview}`
              ).join('\n')
            }`
          }
        ]
      };
    }
  • The input schema definition for the 'list_cells' tool, specifying the required 'notebook_path' parameter.
    {
      name: "list_cells",
      description: "List all cells in a Jupyter notebook with their indices and types",
      inputSchema: {
        type: "object",
        properties: {
          notebook_path: {
            type: "string",
            description: "Absolute path to the Jupyter notebook file"
          }
        },
        required: ["notebook_path"]
      }
    },
  • src/index.js:331-333 (registration)
    The dispatch case in the CallToolRequestSchema handler that routes 'list_cells' calls to the JupyterHandler's listCells method.
    case "list_cells":
      return await this.jupyterHandler.listCells(args.notebook_path);
Behavior3/5

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

With no annotations provided, the description carries full burden. It discloses the tool's read-only nature implicitly through 'List' and specifies the output format (indices and types). However, it lacks details on error handling (e.g., invalid file paths), performance (e.g., large notebook handling), or authentication needs, leaving behavioral gaps.

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 a single, efficient sentence that front-loads the core purpose ('List all cells in a Jupyter notebook') and appends valuable output details ('with their indices and types'). Every word contributes meaning without redundancy or fluff.

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

Completeness3/5

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

For a simple read operation with one parameter and no output schema, the description adequately covers the basic purpose and output. However, without annotations or output schema, it misses opportunities to detail error conditions, return format specifics, or limitations, leaving the agent to infer these from context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 100% description coverage, fully documenting the single required parameter. The description adds no parameter-specific information beyond what the schema provides, but with only one parameter and high schema coverage, the baseline is appropriately met without needing compensation.

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 clearly states the specific action ('List all cells') with the target resource ('in a Jupyter notebook') and output details ('with their indices and types'). It distinguishes this read operation from sibling tools like add_cell, delete_cell, or edit_cell by focusing on enumeration rather than modification.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for retrieving cell metadata from a notebook file, but provides no explicit guidance on when to choose this tool versus alternatives like read_notebook_with_outputs (which might include execution outputs) or get_cell_source (which retrieves content rather than metadata). No exclusions or prerequisites are mentioned.

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

Install Server

Other Tools

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/azharlabs/mcp-jupyter-server'

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