Skip to main content
Glama

List Chapters

list_chapters

Quickly extract chapter titles and summaries from a knowledge document to gain an overview, plan navigation, or check structure without loading full content.

Instructions

List all chapters in a knowledge document with titles and summaries only.

When to use this tool:

  • Getting document overview without loading all content

  • Planning which chapters to read or update

  • Understanding document structure

  • Checking chapter organization

  • Finding specific chapters efficiently

Key features:

  • Lightweight operation (no content loading)

  • Returns titles and summaries only

  • Shows chapter count and order

  • Enables informed navigation

You should:

  1. Use this before get_knowledge_file for large documents

  2. Identify relevant chapters before reading

  3. Check document structure before modifications

  4. Use for navigation planning

  5. Include .md extension in filename

DO NOT use when:

  • Need actual chapter content

  • Document is very small

  • Already know exact chapter needed

Returns: {success: bool, project_id: str, filename: str, total_chapters: int, chapters: array}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filenameYesKnowledge file name (must include .md extension)
project_idYesThe project identifier

Implementation Reference

  • Core handler implementation that reads the knowledge file, parses chapters, and returns titles, summaries, and indices without full content.
    async listChaptersAsync(params: { project_id: string; filename: string }): Promise<string> {
      const context = this.createContext('list_chapters', params);
    
      try {
        const { project_id, filename } = params;
        const projectInfo = await getProjectDirectoryAsync(this.storagePath, project_id);
    
        if (!projectInfo) {
          throw new MCPError(MCPErrorCode.PROJECT_NOT_FOUND, `Project ${project_id} not found`, {
            project_id,
            traceId: context.traceId,
          });
        }
    
        const [, projectPath] = projectInfo;
        const knowledgePath = join(projectPath, 'knowledge');
        const filePath = await validatePathAsync(knowledgePath, filename);
    
        // Check if file exists
        try {
          await access(filePath);
        } catch {
          throw new MCPError(
            MCPErrorCode.DOCUMENT_NOT_FOUND,
            `Knowledge file ${filename} not found`,
            { project_id, filename, traceId: context.traceId }
          );
        }
    
        // Read and parse the document
        const content = await readFile(filePath, 'utf8');
        const [, body] = parseDocument(content);
        const chapters = parseChapters(body);
    
        // Return lightweight chapter list
        const chapterList = chapters.map((chapter, index) => ({
          title: chapter.title,
          summary: chapter.summary,
          index,
        }));
    
        this.logSuccess('list_chapters', { project_id, filename }, context);
        return this.formatSuccessResponse({
          project_id,
          filename,
          total_chapters: chapters.length,
          chapters: chapterList,
        });
      } catch (error) {
        const mcpError =
          error instanceof MCPError
            ? error
            : new MCPError(
                MCPErrorCode.FILE_SYSTEM_ERROR,
                `Failed to list chapters: ${error instanceof Error ? error.message : String(error)}`,
                {
                  project_id: params.project_id,
                  filename: params.filename,
                  traceId: context.traceId,
                }
              );
        this.logError('list_chapters', params, mcpError, context);
        return this.formatErrorResponse(mcpError, context);
      }
    }
  • Registers the 'list_chapters' MCP tool, defines input schema, description, and wrapper that delegates to ChapterToolHandler.listChaptersAsync
      'list_chapters',
      {
        title: 'List Chapters',
        description: TOOL_DESCRIPTIONS.list_chapters,
        inputSchema: {
          project_id: secureProjectIdSchema.describe('The project identifier'),
          filename: secureFilenameSchema.describe('Knowledge file name (must include .md extension)'),
        },
      },
      async ({ project_id, filename }) => {
        const result = await chapterHandler.listChaptersAsync({ project_id, filename });
        return {
          content: [
            {
              type: 'text',
              text: result,
            },
          ],
        };
      }
    );
  • Detailed tool description and usage guidelines for 'list_chapters' used during registration.
      list_chapters: `List all chapters in a knowledge document with titles and summaries only.
    
    When to use this tool:
    - Getting document overview without loading all content
    - Planning which chapters to read or update
    - Understanding document structure
    - Checking chapter organization
    - Finding specific chapters efficiently
    
    Key features:
    - Lightweight operation (no content loading)
    - Returns titles and summaries only
    - Shows chapter count and order
    - Enables informed navigation
    
    You should:
    1. Use this before get_knowledge_file for large documents
    2. Identify relevant chapters before reading
    3. Check document structure before modifications
    4. Use for navigation planning
    5. Include .md extension in filename
    
    DO NOT use when:
    - Need actual chapter content
    - Document is very small
    - Already know exact chapter needed
    
    Returns: {success: bool, project_id: str, filename: str, total_chapters: int, chapters: array}`,
Behavior4/5

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

With no annotations provided, the description carries full burden and does well by disclosing key behavioral traits: 'Lightweight operation (no content loading)', 'Returns titles and summaries only', 'Shows chapter count and order', and 'Enables informed navigation'. It doesn't mention error conditions or performance characteristics, keeping it from a perfect score.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (purpose, when to use, key features, guidelines, exclusions, returns) but could be more concise. Some bullet points could be combined (e.g., 'Getting document overview' and 'Understanding document structure' are similar). Every sentence adds value, but there's minor redundancy.

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

Completeness5/5

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

For a read-only list operation with 2 parameters and 100% schema coverage, the description is exceptionally complete. It provides comprehensive usage guidance, behavioral context, and explicitly documents the return structure despite no output schema. The description fully compensates for the lack of annotations.

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 description coverage is 100%, so the schema already fully documents both parameters. The description adds minimal value beyond the schema by mentioning '.md extension in filename' in the 'You should' section, but doesn't provide additional semantic context about parameter usage or interactions.

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 chapters') and resource ('in a knowledge document'), specifying what information is returned ('titles and summaries only'). It distinguishes from sibling tools like get_knowledge_file and get_chapter by emphasizing it doesn't load content.

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

Usage Guidelines5/5

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

The description provides explicit 'When to use this tool' with 5 specific scenarios, a 'You should' section with 5 actionable guidelines, and a 'DO NOT use when' section with 3 clear exclusions. It explicitly contrasts with get_knowledge_file for large documents.

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

Related 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/sven-borkert/knowledge-mcp'

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