Skip to main content
Glama
muleiwu

DWZ Short URL MCP Server

by muleiwu

batch_create_short_urls

Create multiple short URLs simultaneously to streamline link management. Supports up to 50 URLs with custom domains for efficient batch processing.

Instructions

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

Input Schema

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

Implementation Reference

  • MCP tool definition and handler for 'batch_create_short_urls', which wraps the service call and formats the response.
    export const batchCreateShortUrlsTool = { name: 'batch_create_short_urls', description: '批量创建多个短网址,提高创建效率。最多支持50个URL。', 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'], }, 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(), }, }; })(); }, }; export default batchCreateShortUrlsTool;
  • Core implementation of batchCreateShortUrls in ShortLinkService, performs validation, URL normalization, HTTP POST to /short_links/batch, and response handling.
    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); } }
  • Registers batchCreateShortUrlsTool (and other tools) into the MCP 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} 个工具`); }
  • Input schema definition for the batch_create_short_urls MCP tool.
    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'], },
  • Joi validation schema for batchCreateShortUrls parameters used in the service layer.
    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