Skip to main content
Glama
muleiwu

DWZ Short URL MCP Server

by muleiwu

batch_create_short_urls

Create multiple short URLs in bulk to streamline link management workflows. Supports up to 50 URLs at once with custom domain options for efficient URL shortening operations.

Instructions

批量创建多个短网址,提高创建效率。最多支持50个URL。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYes短网址使用的域名
urlsYes要缩短的URL列表

Implementation Reference

  • The MCP tool handler for 'batch_create_short_urls'. Logs the call, wraps the service invocation with error handling, calls defaultShortLinkService.batchCreateShortUrls, and formats the response with success data, failures, summary stats, and metadata.
    handler: async function (args) { logger.info('MCP工具调用: batch_create_short_urls', { urlCount: args.urls.length }); return ErrorHandler.asyncWrapper(async () => { const result = await defaultShortLinkService.batchCreateShortUrls(args); return { success: true, message: '批量创建完成', data: { success: result.success || [], failed: result.failed || [], summary: { total: args.urls.length, success_count: result.success?.length || 0, failed_count: result.failed?.length || 0, }, }, meta: { operation: 'batch_create_short_urls', timestamp: new Date().toISOString(), }, }; })(); },
  • Input schema for the batch_create_short_urls tool, defining required 'urls' (array of 1-50 URI strings) and 'domain' (string matching domain pattern).
    inputSchema: { type: 'object', properties: { urls: { type: 'array', description: '要缩短的URL列表', items: { type: 'string', format: 'uri', }, minItems: 1, maxItems: 50, }, domain: { type: 'string', description: '短网址使用的域名', pattern: '^[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$', }, }, required: ['urls', 'domain'], },
  • Registration of the batch_create_short_urls tool (as batchCreateShortUrlsTool) in the MCP server's registerTools method, adding it to the tools Map used for handling tool calls.
    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 function in ShortLinkService that implements the core batch short URL creation: validates and normalizes input, POSTs to remote /short_links/batch endpoint, processes response, logs, and handles errors.
    async batchCreateShortUrls(params) { try { // 验证参数 const validatedParams = validateOrThrow('batchCreateShortUrls', params); // 标准化所有 URL const normalizedUrls = validatedParams.urls.map(url => normalizeUrl(url)); logger.info('开始批量创建短链接:', { url_count: normalizedUrls.length, domain: validatedParams.domain, }); // 发送请求 const response = await this.httpClient.post( getApiUrl('/short_links/batch'), { ...validatedParams, urls: normalizedUrls, } ); // 处理响应 const result = this.handleApiResponse(response, '批量创建短链接'); logger.info('批量创建短链接完成:', { success_count: result.success?.length || 0, failed_count: result.failed?.length || 0, }); return result; } catch (error) { logger.error('批量创建短链接失败:', error); const handledError = ErrorHandler.handle(error); throw ErrorHandler.createMcpErrorResponse(handledError, error); } }
  • Internal Joi validation schema for batchCreateShortUrls parameters, requiring 'urls' array (1-50 valid URIs) and 'domain', used by the service before API call.
    batchCreateShortUrls: Joi.object({ urls: commonRules.urls, domain: commonRules.domain.required().messages({ 'any.required': '域名是必填参数', }), }),

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