Skip to main content
Glama

YOURLS-MCP

by kesslerio
expandUrl.js1.57 kB
/** * URL Expansion tool implementation * * Uses the standardized MCP response format via createMcpResponse utility: * - Success: {content: [{type: 'text', text: JSON.stringify({status: 'success', ...data})}]} * - Error: {content: [{type: 'text', text: JSON.stringify({status: 'error', ...data})}], isError: true} */ import { createMcpResponse } from '../utils.js'; /** * Create a URL expansion tool * * @param {object} yourlsClient - YOURLS API client * @returns {object} Tool definition with standardized MCP response format */ export default function createExpandUrlTool(yourlsClient) { return { name: 'expand_url', description: 'Expand a short URL to its original long URL', inputSchema: { type: 'object', properties: { shorturl: { type: 'string', description: 'The short URL or keyword to expand' } }, required: ['shorturl'] }, execute: async ({ shorturl }) => { try { const result = await yourlsClient.expand(shorturl); if (result.longurl) { return createMcpResponse(true, { shorturl: result.shorturl || shorturl, longurl: result.longurl, title: result.title || '' }); } else { return createMcpResponse(false, { message: result.message || 'Unknown error', code: result.code || 'unknown' }); } } catch (error) { return createMcpResponse(false, { message: error.message }); } } }; }

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