Skip to main content
Glama

get_library_stats

Retrieve detailed statistics for Plex Media Server libraries, such as media counts and usage insights, using the library section key for specific data. Enhances content management and analysis capabilities.

Instructions

Get library-specific statistics

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
libraryKeyNoLibrary section key (optional)

Implementation Reference

  • The core handler function for the get_library_stats tool. Retrieves detailed statistics for a specific Plex library if libraryKey is provided, or summaries for all libraries otherwise. Uses the Plex API endpoints /library/sections/{key} or /library/sections.
    private async getLibraryStats(libraryKey?: string) {
      if (libraryKey) {
        const data = await this.makeRequest(`/library/sections/${libraryKey}`);
        const library = data.MediaContainer?.Directory?.[0];
        
        if (!library) {
          throw new McpError(ErrorCode.InvalidRequest, `Library not found: ${libraryKey}`);
        }
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({
                library: {
                  key: library.key,
                  title: library.title,
                  type: library.type,
                  count: library.count,
                  scannedAt: library.scannedAt,
                  updatedAt: library.updatedAt,
                  language: library.language,
                  locations: library.Location?.map((loc: any) => loc.path) || [],
                },
              }, null, 2),
            },
          ],
        };
      } else {
        const data = await this.makeRequest("/library/sections");
        const libraries = data.MediaContainer?.Directory || [];
        
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify({
                libraries: libraries.map((lib: any) => ({
                  key: lib.key,
                  title: lib.title,
                  type: lib.type,
                  count: lib.count,
                  scannedAt: lib.scannedAt,
                })),
                totalLibraries: libraries.length,
              }, null, 2),
            },
          ],
        };
      }
    }
  • src/index.ts:188-200 (registration)
    Tool registration in the ListTools response, including name, description, and input schema defining optional libraryKey parameter.
    {
      name: "get_library_stats",
      description: "Get library-specific statistics",
      inputSchema: {
        type: "object",
        properties: {
          libraryKey: {
            type: "string",
            description: "Library section key (optional)",
          },
        },
      },
    },
  • src/index.ts:296-297 (registration)
    Dispatcher case in the CallToolRequestSchema handler that routes calls to get_library_stats to the appropriate method.
    case "get_library_stats":
      return await this.getLibraryStats((args as any)?.libraryKey as string);
  • Input schema for the get_library_stats tool, specifying an optional string libraryKey.
    inputSchema: {
      type: "object",
      properties: {
        libraryKey: {
          type: "string",
          description: "Library section key (optional)",
        },
      },
    },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Get' implies a read operation, but doesn't disclose permissions needed, rate limits, response format, or whether it's safe/destructive. For a tool with zero annotation coverage, this is a significant gap in transparency.

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 with zero waste. It's appropriately sized for a simple tool and front-loaded with the core purpose, making it easy to parse quickly.

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

Completeness2/5

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

Given no annotations, no output schema, and a vague purpose, the description is incomplete. It doesn't clarify what statistics are returned, how they differ from sibling tools, or behavioral aspects like safety. For a tool in a statistical context with multiple similar siblings, more detail is needed.

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%, with the single parameter 'libraryKey' documented as 'Library section key (optional)'. The description adds no meaning beyond this, as it doesn't explain what 'library-specific' entails or how the key affects results. Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose3/5

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

The description 'Get library-specific statistics' states a clear verb ('Get') and resource ('library-specific statistics'), but it's vague about what specific statistics are retrieved and doesn't distinguish from sibling tools like 'get_user_stats' or 'get_watch_stats'. It provides a basic purpose but lacks specificity.

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?

No guidance is provided on when to use this tool versus alternatives. With siblings like 'get_user_stats' and 'get_watch_stats' that might overlap in statistical reporting, the description offers no context on differentiation, prerequisites, or exclusions, leaving usage unclear.

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/niavasha/plex-mcp-server'

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