Skip to main content
Glama
Gitmaxd

Unofficial dubco-mcp-server

by Gitmaxd

create_link

Shorten URLs into Dub.co links by specifying destination URLs, custom slugs, and domain preferences for streamlined sharing.

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 core handler function that implements the create_link tool logic. It handles domain selection (specified or primary), constructs API params, calls Dub.co /links POST endpoint, and formats the response or error.
    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<any>;
          const statusCode = axiosError.response?.status;
          const errorData = axiosError.response?.data;
          
          // Debug logging
          console.error('Error data:', JSON.stringify(errorData));
          
          // Try to extract error message in different ways
          let errorMessage = 'Unknown error';
          if (errorData) {
            if (typeof errorData === 'string') {
              errorMessage = errorData;
            } else if (errorData.error) {
              // Handle nested error object from Dub.co API
              if (typeof errorData.error === 'object' && errorData.error.message) {
                errorMessage = errorData.error.message;
              } else {
                errorMessage = errorData.error;
              }
            } else if (errorData.message) {
              errorMessage = errorData.message;
            } else {
              errorMessage = JSON.stringify(errorData);
            }
          } else {
            errorMessage = 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:108-133 (registration)
    Tool registration in ListToolsRequestHandler, defining name, description, and input schema 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 parameters for creating a link, used internally in the handler.
    interface CreateLinkParams {
      url: string;
      domain?: string;
      key?: string;
      externalId?: string;
      // ... other optional parameters
    }
  • src/index.ts:180-181 (registration)
    Dispatcher routing in CallToolRequestHandler that invokes the createLink handler for 'create_link' tool calls.
    case 'create_link':
      return await this.createLink(request.params.arguments);
  • Helper function to retrieve the primary domain, used by createLink when no domain is specified.
    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;
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

B3.1/5.0
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.

Deploy Server

Other Tools