Skip to main content
Glama
muleiwu

DWZ Short URL MCP Server

by muleiwu

create_short_url

Create shortened URLs with custom domains and codes to simplify long links for sharing and tracking purposes.

Instructions

创建一个新的短网址。支持自定义域名、短代码、标题和描述信息。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
original_urlYes原始URL地址(要缩短的长链接)
domainYes短网址使用的域名(必填)
custom_codeNo自定义短代码(可选,如果不提供将自动生成)
titleYes短网址的标题(必填)
descriptionNo短网址的描述信息(可选)
expire_atNo过期时间(可选,ISO 8601格式,不填表示永不过期)

Implementation Reference

  • The handler function for the 'create_short_url' MCP tool. It logs the call, invokes the short link service to create the URL, formats the response with success status, data, and metadata.
    handler: async function (args) {
      logger.info('MCP工具调用: create_short_url', { args });
    
      return ErrorHandler.asyncWrapper(async () => {
        // 调用服务层创建短链接
        const result = await defaultShortLinkService.createShortUrl(args);
    
        // 格式化返回结果
        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: 'create_short_url',
            timestamp: new Date().toISOString(),
          },
        };
      })();
    },
  • JSON Schema defining the input parameters for the 'create_short_url' tool, including properties, descriptions, constraints, and required fields.
    inputSchema: {
      type: 'object',
      properties: {
        original_url: {
          type: 'string',
          description: '原始URL地址(要缩短的长链接)',
          format: 'uri',
          examples: ['https://www.example.com/very/long/path', 'https://github.com/user/repo'],
        },
        domain: {
          type: 'string',
          description: '短网址使用的域名(必填)',
          pattern: '^[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$',
          examples: ['dwz.test', 'link.example.com'],
        },
        custom_code: {
          type: 'string',
          description: '自定义短代码(可选,如果不提供将自动生成)',
          pattern: '^[a-zA-Z0-9]{3,50}$',
          examples: ['abc123', 'mylink', 'promo2024'],
        },
        title: {
          type: 'string',
          description: '短网址的标题(必填)',
          minLength: 1,
          maxLength: 200,
          examples: ['产品官网', '活动页面', '技术文档'],
        },
        description: {
          type: 'string',
          description: '短网址的描述信息(可选)',
          maxLength: 500,
          examples: ['这是我们的新产品页面', '2024年春节促销活动'],
        },
        expire_at: {
          type: 'string',
          description: '过期时间(可选,ISO 8601格式,不填表示永不过期)',
          format: 'date-time',
          examples: ['2024-12-31T23:59:59Z', '2025-01-01T00:00:00+08:00'],
        },
      },
      required: ['original_url', 'domain', 'title'],
    },
  • The registerTools method registers the 'create_short_url' tool (imported as createShortUrlTool) along with others into the server's tools Map, making it available for MCP requests.
    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} 个工具`);
    }
  • Core helper function in the ShortLinkService that performs parameter validation, URL normalization, HTTP POST to the backend API to create the short URL, and handles the response or errors.
    async createShortUrl(params) {
      try {
        // 验证参数
        const validatedParams = validateOrThrow('createShortUrl', params);
    
        // 标准化 URL
        validatedParams.original_url = normalizeUrl(validatedParams.original_url);
    
        logger.info('开始创建短链接:', {
          original_url: validatedParams.original_url,
          domain: validatedParams.domain,
          custom_code: validatedParams.custom_code,
        });
    
        // 发送请求
        const response = await this.httpClient.post(
          getApiUrl('/short_links'),
          validatedParams
        );
    
        // 处理响应
        const result = this.handleApiResponse(response, '创建短链接');
    
        logger.info('短链接创建成功:', {
          id: result.id,
          short_code: result.short_code,
          short_url: result.short_url,
        });
    
        return result;
    
      } catch (error) {
        logger.error('创建短链接失败:', error);
        const handledError = ErrorHandler.handle(error);
        throw ErrorHandler.createMcpErrorResponse(handledError, error);
      }
    }
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 states the tool creates a new short URL and lists supported features, but doesn't disclose important behavioral traits: whether this is a write operation (implied but not explicit), what permissions are needed, what happens on success/failure, rate limits, or what the return value looks like (no output schema). The description is insufficient for a mutation tool with zero annotation coverage.

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 a single, efficient Chinese sentence that states the core purpose and lists key features. It's appropriately sized and front-loaded with the main action. No wasted words, though it could be slightly more structured by separating purpose from features.

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 mutation tool (creating resources) with no annotations and no output schema, the description is incomplete. It doesn't explain what happens after creation, what gets returned, error conditions, or behavioral constraints. The 100% schema coverage helps with parameters, but the overall context for using this tool is inadequate given its complexity and lack of structured metadata.

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 all 6 parameters thoroughly with descriptions, examples, and constraints. The description mentions the same parameters (custom domain, short code, title, description) but adds no additional semantic meaning beyond what's in the schema. Baseline 3 is appropriate when 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: '创建一个新的短网址' (create a new short URL). It specifies the action (create) and resource (short URL), and lists supported features (custom domain, short code, title, description). However, it doesn't explicitly differentiate from sibling tools like batch_create_short_urls, which creates multiple URLs at once.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like batch_create_short_urls for bulk operations or get_url_info for retrieving existing URLs. There's no context about prerequisites, typical use cases, or when not to use this tool.

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