Skip to main content
Glama
kesslerio

YOURLS-MCP

by kesslerio

list_urls

Retrieve and manage a list of URLs with options to sort by clicks or timestamps, filter by search terms, and paginate results for streamlined URL analysis and organization.

Instructions

Get a list of URLs with sorting, pagination, and filtering options

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pageNoPage number
perpageNoNumber of results per page
searchNoSearch term to filter results
sortbyNoField to sort by (e.g., "clicks", "timestamp")
sortorderNoSort order ("asc" or "desc")

Implementation Reference

  • The execute function that implements the core logic of the 'list_urls' tool, including parameter validation, normalization, API call to yourlsClient.listUrls with fallback, and response formatting.
    execute: async ({ sortby, sortorder, offset, perpage, query, fields }) => {
      try {
        // Validate sortby
        const validSortFields = ['keyword', 'url', 'title', 'ip', 'timestamp', 'clicks'];
        if (sortby && !validSortFields.includes(sortby)) {
          throw new Error(`Invalid sortby value. Must be one of: ${validSortFields.join(', ')}`);
        }
        
        // Validate sortorder
        if (sortorder && !['ASC', 'DESC', 'asc', 'desc'].includes(sortorder)) {
          throw new Error('Invalid sortorder value. Must be ASC or DESC');
        }
        
        // Validate numeric parameters
        if (offset !== undefined && (isNaN(Number(offset)) || Number(offset) < 0)) {
          throw new Error('Offset must be a non-negative number');
        }
        
        if (perpage !== undefined && (isNaN(Number(perpage)) || Number(perpage) <= 0)) {
          throw new Error('Perpage must be a positive number');
        }
        
        // Normalize fields if needed
        let normalizedFields = fields;
        if (typeof fields === 'string') {
          try {
            normalizedFields = JSON.parse(fields);
          } catch (e) {
            normalizedFields = fields.split(',').map(f => f.trim());
          }
        }
        
        // Use the listUrls method with fallback enabled
        const result = await yourlsClient.listUrls({
          sortby,
          sortorder,
          offset: offset !== undefined ? Number(offset) : undefined,
          perpage: perpage !== undefined ? Number(perpage) : undefined,
          query,
          fields: normalizedFields,
          useNativeFallback: true
        });
        
        if (result.status === 'success') {
          const responseData = {
            total: result.total,
            page: result.page || 1,
            perpage: result.perpage,
            links: result.links || {},
            results: result.result || []
          };
          
          // Add fallback information if applicable
          if (result.fallback_used) {
            responseData.fallback_used = true;
            if (result.fallback_limitations) {
              responseData.fallback_limitations = result.fallback_limitations;
            }
          }
          
          return createMcpResponse(true, responseData);
        } else {
          throw new Error(result.message || 'Unknown error');
        }
      } catch (error) {
        return createMcpResponse(false, {
          message: error.message
        });
      }
    }
  • Input schema defining the parameters for the 'list_urls' tool, including sorting, pagination, filtering, and field selection options.
    inputSchema: {
      type: 'object',
      properties: {
        sortby: {
          type: 'string',
          description: 'Field to sort by (keyword, url, title, ip, timestamp, clicks)'
        },
        sortorder: {
          type: 'string',
          description: 'Sort order (ASC or DESC)'
        },
        offset: {
          type: 'number',
          description: 'Pagination offset'
        },
        perpage: {
          type: 'number',
          description: 'Number of results per page'
        },
        query: {
          type: 'string',
          description: 'Optional search query for filtering by keyword'
        },
        fields: {
          type: 'array',
          items: {
            type: 'string'
          },
          description: 'Fields to return (keyword, url, title, timestamp, ip, clicks)'
        }
      }
    },
  • src/index.js:229-240 (registration)
    Registration of the 'list_urls' tool with the MCP server, providing name, description, Zod input schema, and the execute handler.
    server.tool(
      listUrlsTool.name,
      listUrlsTool.description,
      {
        sortby: z.string().optional().describe('Field to sort by (e.g., "clicks", "timestamp")'),
        sortorder: z.string().optional().describe('Sort order ("asc" or "desc")'),
        perpage: z.number().optional().describe('Number of results per page'),
        page: z.number().optional().describe('Page number'),
        search: z.string().optional().describe('Search term to filter results')
      },
      listUrlsTool.execute
    );
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. It mentions the tool's capabilities (sorting, pagination, filtering) but doesn't describe what the tool returns (e.g., format, fields), error conditions, rate limits, or authentication requirements. For a list operation with no annotation coverage, this leaves significant 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 ('Get a list of URLs') followed by key capabilities. Every word earns its place with zero waste or redundancy.

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?

For a tool with 5 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what the returned list contains, how results are structured, or any behavioral aspects beyond basic capabilities. Given the complexity and lack of structured data, more context 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%, so the schema already documents all 5 parameters thoroughly. The description adds minimal value by mentioning 'sorting, pagination, and filtering' which aligns with parameters like sortby/sortorder, page/perpage, and search, but doesn't provide additional semantic context beyond what's in the schema descriptions.

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 verb 'Get' and resource 'list of URLs', making the purpose understandable. However, it doesn't distinguish this tool from potential siblings like 'url_stats' or 'url_analytics' that might also provide URL-related information, so it doesn't reach the highest score.

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 mentions 'sorting, pagination, and filtering options' which implies when to use this tool, but provides no explicit guidance on when to choose this over alternatives like 'url_stats' or 'url_analytics'. There's no mention of prerequisites, exclusions, or specific contexts for use.

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/kesslerio/yourls-mcp'

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