Skip to main content
Glama

create_link

Create short links on Dub.co by specifying destination URLs, custom slugs, and domain preferences for URL shortening.

Instructions

Create a new short link on dub.co, asking the user which domain to use

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesThe destination URL to shorten
keyNoOptional custom slug for the short link. If not provided, a random slug will be generated.
externalIdNoOptional external ID for the link
domainNoOptional domain slug to use. If not provided, the primary domain will be used.

Implementation Reference

  • The handler function that implements the create_link tool logic: validates input, selects domain (user-specified or primary), constructs params, calls Dub.co API POST /links, handles errors, and returns the created short link details.
    private async createLink(args: any): Promise<any> {
      if (!args.url) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'URL is required'
        );
      }
    
      try {
        // Determine which domain to use
        let domain: Domain;
        
        if (args.domain) {
          // If domain is specified, try to find it
          const foundDomain = await this.getDomainBySlug(args.domain);
          if (!foundDomain) {
            return {
              content: [
                {
                  type: 'text',
                  text: `Domain "${args.domain}" not found. Using primary domain instead.`,
                },
              ],
              isError: false,
            };
          }
          domain = foundDomain;
        } else {
          // Otherwise use the primary domain
          domain = await this.getPrimaryDomain();
        }
        
        // Create the link with the selected domain
        const createParams: CreateLinkParams = {
          url: args.url,
          domain: domain.slug,
        };
        
        if (args.key) {
          createParams.key = args.key;
        }
        
        if (args.externalId) {
          createParams.externalId = args.externalId;
        }
        
        const response = await this.axiosInstance.post('/links', createParams);
        const link = response.data;
        
        return {
          content: [
            {
              type: 'text',
              text: `Short link created: ${link.shortLink}\n\nDestination: ${link.url}\nID: ${link.id}`,
            },
          ],
        };
      } catch (error) {
        if (axios.isAxiosError(error)) {
          const axiosError = error as AxiosError<ApiErrorResponse>;
          const statusCode = axiosError.response?.status;
          const errorData = axiosError.response?.data;
          const errorMessage = errorData?.error || errorData?.message || axiosError.message;
          
          return {
            content: [
              {
                type: 'text',
                text: `Error creating link: ${statusCode} - ${errorMessage}`,
              },
            ],
            isError: true,
          };
        }
        
        return {
          content: [
            {
              type: 'text',
              text: `Error creating link: ${(error as Error).message}`,
            },
          ],
          isError: true,
        };
      }
    }
  • src/index.ts:104-129 (registration)
    Tool registration in ListToolsRequestHandler, defining name, description, and inputSchema for create_link.
    {
      name: 'create_link',
      description: 'Create a new short link on dub.co, asking the user which domain to use',
      inputSchema: {
        type: 'object',
        properties: {
          url: {
            type: 'string',
            description: 'The destination URL to shorten',
          },
          key: {
            type: 'string',
            description: 'Optional custom slug for the short link. If not provided, a random slug will be generated.',
          },
          externalId: {
            type: 'string',
            description: 'Optional external ID for the link',
          },
          domain: {
            type: 'string',
            description: 'Optional domain slug to use. If not provided, the primary domain will be used.'
          }
        },
        required: ['url'],
      },
    },
  • TypeScript interface defining the parameters for creating a link, used in the handler.
    interface CreateLinkParams {
      url: string;
      domain?: string;
      key?: string;
      externalId?: string;
      // ... other optional parameters
    }
  • Dispatch case in CallToolRequestHandler that routes create_link calls to the createLink method.
    case 'create_link':
      return await this.createLink(request.params.arguments);
  • Helper method to retrieve the primary domain, used by createLink to select default domain.
    private async getPrimaryDomain(): Promise<Domain> {
      const domains = await this.getDomains();
      
      if (domains.length === 0) {
        throw new McpError(
          ErrorCode.InvalidRequest,
          'No domains available in your workspace'
        );
      }
      
      // Find the primary domain or use the first one
      const primaryDomain = domains.find(domain => domain.primary) || domains[0];
      return primaryDomain;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions domain selection but fails to describe key traits like authentication requirements, rate limits, error handling, or what happens on success (e.g., returns a short URL). For a creation tool with zero annotation coverage, this is a significant gap in transparency.

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 sentence that front-loads the core purpose. It avoids unnecessary words, though it could be slightly more structured by explicitly mentioning the required 'url' parameter or output expectations.

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?

Given the complexity of a creation tool with 4 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain the return value (e.g., the generated short link), error conditions, or behavioral nuances like idempotency. This leaves gaps for an AI agent to invoke the tool correctly.

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 parameters thoroughly. The description adds minimal value beyond the schema by hinting at domain selection ('asking the user which domain to use'), but doesn't provide additional syntax, format details, or context for parameters like 'key' or 'externalId'. 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 action ('Create a new short link') and the resource ('on dub.co'), with a specific verb+resource combination. It distinguishes from siblings like 'delete_link' and 'update_link' by focusing on creation, though it doesn't explicitly contrast with 'upsert_link' which might have overlapping functionality.

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 when creating a short link on dub.co, with a hint about domain selection ('asking the user which domain to use'). However, it lacks explicit guidance on when to use this tool versus alternatives like 'upsert_link' or 'update_link', and doesn't mention prerequisites 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/Gitmaxd/dubco-mcp-server'

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