Skip to main content
Glama
libralm-ai

LibraLM MCP Server

Official
by libralm-ai

get_table_of_contents

Retrieve structured chapter outlines and descriptions for books to quickly understand content organization and key topics.

Instructions

Get the table of contents for a book with chapter descriptions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
book_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function decorated with @mcp.tool(), implementing the core logic to fetch the table of contents via API request for the given book_id.
    @mcp.tool()
    def get_table_of_contents(book_id: str) -> str:
        """Get the table of contents for a book with chapter descriptions"""
        try:
            data = _make_api_request(f"/books/{book_id}/table_of_contents")
            return data.get("table_of_contents", "")
        except Exception as e:
            raise ValueError(
                f"Error getting table of contents for book '{book_id}': {str(e)}"
            )
  • Helper function used by the tool to perform authenticated API requests to the LibraLM service.
    def _make_api_request(endpoint: str) -> dict:
        """Make an authenticated request to the LibraLM API"""
        # Get API key and base URL from request context or environment
        api_key = get_api_key()
        base_url = get_api_base_url()
    
        headers = {"x-api-key": api_key, "Content-Type": "application/json"}
    
        url = f"{base_url}{endpoint}"
        response = requests.get(url, headers=headers)
    
        if response.status_code == 401:
            raise ValueError("Invalid API key. Please check your LibraLM API key.")
        elif response.status_code == 404:
            raise ValueError(f"Resource not found: {endpoint}")
        elif response.status_code != 200:
            raise ValueError(
                f"API request failed with status {response.status_code}: {response.text}"
            )
    
        # Handle wrapped response format from Lambda
        result = response.json()
        if isinstance(result, dict) and "data" in result:
            return result["data"]
        return result
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but offers minimal information. It doesn't indicate whether this is a read-only operation, what permissions might be required, potential rate limits, or error conditions. While 'Get' implies a read operation, the lack of explicit safety or behavioral context leaves significant gaps for an agent to understand how to properly invoke this tool.

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 communicates the core purpose without unnecessary words. It's appropriately sized for a simple tool and front-loads the essential information. Every word earns its place, making it easy for an agent to parse quickly.

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?

Given the tool's simplicity (one parameter, no annotations, but with an output schema), the description is adequate but incomplete. The output schema likely handles return values, so the description doesn't need to explain those. However, for a tool with no annotations, it should provide more behavioral context (e.g., read-only nature, error handling) to be fully complete for agent use.

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?

The description mentions 'for a book' which implies the book_id parameter, but with 0% schema description coverage and only one parameter, this adds minimal value beyond what's obvious from the schema. The baseline for a single parameter with low schema coverage would be higher, but since the description doesn't explain what format the book_id should be (e.g., ISBN, internal ID) or where to obtain it, it only partially compensates for the schema gap.

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

Purpose4/5

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

The description clearly states the action ('Get') and resource ('table of contents for a book with chapter descriptions'), making the purpose immediately understandable. It distinguishes from siblings like 'get_book_details' or 'get_book_summary' by focusing specifically on the table of contents structure rather than general book information or individual chapters. However, it doesn't specify whether this includes only chapter titles or also page numbers, which keeps it from being a perfect 5.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'get_book_details' or 'list_books'. It doesn't mention prerequisites, such as needing a valid book_id from another operation, or clarify what context makes this tool preferable to siblings. The user must infer usage from the tool name alone, which is insufficient for optimal agent decision-making.

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/libralm-ai/libralm_mcp_server'

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