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;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool creates a short link and involves user interaction for domain selection, but lacks critical details: it doesn't mention authentication requirements, rate limits, whether the creation is idempotent, what happens on duplicate keys, or the format of the response. For a mutation tool with zero annotation coverage, this is a significant gap.

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 redundancy and wastes no words, though it could be slightly more structured by separating the user interaction note. Every part of the sentence contributes to understanding the tool's function.

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 tool's complexity (a mutation with 4 parameters, no annotations, and no output schema), the description is incomplete. It doesn't cover behavioral aspects like authentication, error handling, or response format, and lacks usage guidelines. While the schema covers parameters well, the overall context for safe and effective use is insufficient.

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 four parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema—it doesn't explain parameter interactions, default behaviors beyond the schema, or usage examples. The baseline score of 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 target resource ('on dub.co'), making the purpose immediately understandable. It distinguishes from siblings by focusing on creation rather than deletion or updating, though it doesn't explicitly name the sibling tools. The mention of 'asking the user which domain to use' adds specificity about user interaction.

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 like update_link or delete_link. It mentions asking about the domain, which implies a user interaction context, but doesn't specify prerequisites, constraints, or scenarios where this tool is preferred over others. There's no explicit when/when-not guidance.

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-npm'

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