Skip to main content
Glama

url_stats

Retrieve detailed click statistics and analytics for any shortened URL using the YOURLS-MCP server. Input the short URL or keyword to generate insights into link performance and usage patterns.

Instructions

Get statistics for a shortened URL

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
shorturlYesThe short URL or keyword to get stats for

Implementation Reference

  • The execute function that implements the core logic of the 'url_stats' MCP tool. It calls yourlsClient.urlStats(shorturl), processes the result, and returns a standardized MCP response using createMcpResponse.
    execute: async ({ shorturl }) => { try { const result = await yourlsClient.urlStats(shorturl); if (result.link) { return createMcpResponse(true, { shorturl: result.shorturl || shorturl, clicks: result.link.clicks || 0, title: result.link.title || '', longurl: result.link.url || '' }); } else { return createMcpResponse(false, { message: result.message || 'Unknown error', code: result.code || 'unknown' }); } } catch (error) { return createMcpResponse(false, { message: error.message }); } }
  • JSON Schema definition for the input parameters of the 'url_stats' tool, specifying that 'shorturl' is a required string.
    inputSchema: { type: 'object', properties: { shorturl: { type: 'string', description: 'The short URL or keyword to get stats for' } }, required: ['shorturl'] },
  • src/index.js:153-159 (registration)
    Registers the 'url_stats' tool with the MCP server using server.tool(), providing the name, description, Zod input schema validation, and the execute handler reference.
    urlStatsTool.name, urlStatsTool.description, { shorturl: z.string().describe('The short URL or keyword to get stats for') }, urlStatsTool.execute );
  • The YourlsClient.urlStats method, a supporting utility that makes the underlying 'url-stats' API request to the YOURLS server, used by the tool handler.
    async urlStats(shorturl) { return this.request('url-stats', { shorturl }); }
  • Alternative registration of the 'url_stats' tool in the tools index module (potentially unused), dynamically generating Zod schema from inputSchema.
    server.tool( urlStatsTool.name, urlStatsTool.description, { shorturl: urlStatsTool.inputSchema.properties.shorturl.description ? z.string().describe(urlStatsTool.inputSchema.properties.shorturl.description) : z.string() }, urlStatsTool.execute );

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