Skip to main content
Glama
muleiwu

DWZ Short URL MCP Server

by muleiwu

get_url_info

Retrieve detailed information about short URLs including original destination, click statistics, and creation date using the unique short URL ID.

Instructions

根据短网址ID获取详细信息,包括原始URL、点击统计、创建时间等。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYes短网址的唯一标识ID

Implementation Reference

  • The main handler function for the 'get_url_info' MCP tool. It logs the call, fetches URL info from the shortLinkService using the provided ID, formats the response, and returns it structured with success, data, and meta.
    handler: async function (args) { logger.info('MCP工具调用: get_url_info', { args }); return ErrorHandler.asyncWrapper(async () => { // 调用服务层获取短链接信息 const result = await defaultShortLinkService.getUrlInfo(args.id); // 格式化返回结果 return { success: true, message: '获取短网址信息成功', data: { id: result.id, short_code: result.short_code, short_url: result.short_url, original_url: result.original_url, title: result.title, description: result.description, domain: result.domain, expire_at: result.expire_at, is_active: result.is_active, click_count: result.click_count, created_at: result.created_at, updated_at: result.updated_at, }, meta: { operation: 'get_url_info', timestamp: new Date().toISOString(), }, }; })(); },
  • Input schema definition for the 'get_url_info' tool, specifying the required 'id' parameter as a positive integer.
    inputSchema: { type: 'object', properties: { id: { type: 'integer', description: '短网址的唯一标识ID', minimum: 1, examples: [1, 123, 456], }, }, required: ['id'], },
  • Tool registration in the MCP server. 'getUrlInfoTool' is included in the tools array and registered in the server's tools Map.
    registerTools() { const tools = [ createShortUrlTool, getUrlInfoTool, listShortUrlsTool, deleteShortUrlTool, batchCreateShortUrlsTool, listDomainsTool, ]; for (const tool of tools) { this.tools.set(tool.name, tool); logger.debug(`注册工具: ${tool.name}`); } logger.info(`已注册 ${tools.length} 个工具`); }
  • Helper service method that performs the actual API call to retrieve short URL information by ID, handles response, and manages errors.
    async getUrlInfo(id) { try { // 验证参数 validateOrThrow('getUrlInfo', { id }); logger.info('获取短链接信息:', { id }); // 发送请求 const response = await this.httpClient.get( getApiUrl(`/short_links/${id}`) ); // 处理响应 const result = this.handleApiResponse(response, '获取短链接信息'); logger.info('获取短链接信息成功:', { id: result.id, short_code: result.short_code, original_url: result.original_url, }); return result; } catch (error) { logger.error('获取短链接信息失败:', error); const handledError = ErrorHandler.handle(error); throw ErrorHandler.createMcpErrorResponse(handledError, error); } }
  • Joi validation schema used by the service layer for 'getUrlInfo' parameters.
    getUrlInfo: Joi.object({ id: commonRules.id, }),

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/muleiwu/dwz-mcp'

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