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': '域名是必填参数',
      }),
    }),
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the 50-URL limit which is useful context, but doesn't describe what happens on success/failure, whether URLs are validated, if the operation is atomic, what permissions are needed, or what the response format looks like. For a batch creation tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with two sentences that each add value. The first sentence states the core purpose and benefit, the second provides an important constraint. No wasted words, though it could be slightly more structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a batch creation tool with no annotations and no output schema, the description is incomplete. It doesn't explain what gets returned, how errors are handled, whether the operation is transactional, or what authentication/rate limits apply. The efficiency benefit and URL limit are helpful but insufficient for proper agent usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema - it mentions the 50-URL limit which is already in the schema's maxItems constraint. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '批量创建多个短网址' (batch create multiple short URLs) with the efficiency benefit mentioned. It specifies the resource (short URLs) and verb (create in batch), but doesn't explicitly differentiate from the sibling 'create_short_url' tool beyond mentioning batch capability.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by mentioning '提高创建效率' (improve creation efficiency) and the 50-URL limit, suggesting this should be used for bulk operations. However, it doesn't explicitly state when to use this vs. the sibling 'create_short_url' tool or provide clear alternatives or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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