Skip to main content
Glama
Gitmaxd

Unofficial dubco-mcp-server

by Gitmaxd

update_link

Modify an existing Dub.co short link by changing its destination URL, domain, or slug to keep links current and functional.

Instructions

Update an existing short link on dub.co

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
linkIdYesThe ID of the link to update
urlNoThe new destination URL
domainNoThe new domain for the short link
keyNoThe new slug for the short link

Implementation Reference

  • The primary handler function for the 'update_link' tool. It validates the linkId and update parameters, constructs the update payload, makes a PATCH request to the Dub.co API, and returns a formatted response or handles errors appropriately.
    private async updateLink(args: any): Promise<any> {
      if (!args.linkId) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Link ID is required'
        );
      }
    
      // Prepare update parameters
      const updateParams: UpdateLinkParams = {};
      
      if (args.url) {
        updateParams.url = args.url;
      }
      
      if (args.domain) {
        updateParams.domain = args.domain;
      }
      
      if (args.key) {
        updateParams.key = args.key;
      }
      
      if (Object.keys(updateParams).length === 0) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'At least one parameter to update is required'
        );
      }
      
      try {
        const response = await this.axiosInstance.patch(`/links/${args.linkId}`, updateParams);
        const link = response.data;
        
        return {
          content: [
            {
              type: 'text',
              text: `Link updated: ${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 updating link: ${statusCode} - ${errorMessage}`,
              },
            ],
            isError: true,
          };
        }
        
        throw error;
      }
    }
  • src/index.ts:134-159 (registration)
    Registration of the 'update_link' tool in the ListTools response, including name, description, and input schema definition.
    {
      name: 'update_link',
      description: 'Update an existing short link on dub.co',
      inputSchema: {
        type: 'object',
        properties: {
          linkId: {
            type: 'string',
            description: 'The ID of the link to update',
          },
          url: {
            type: 'string',
            description: 'The new destination URL',
          },
          domain: {
            type: 'string',
            description: 'The new domain for the short link',
          },
          key: {
            type: 'string',
            description: 'The new slug for the short link',
          },
        },
        required: ['linkId'],
      },
    },
  • TypeScript interface defining the parameters for updating a link, used within the handler to type the update payload.
    interface UpdateLinkParams {
      url?: string;
      domain?: string;
      key?: string;
      externalId?: string;
      // ... other optional parameters
    }
  • src/index.ts:182-183 (registration)
    Dispatcher case in the CallToolRequest handler that routes 'update_link' calls to the updateLink method.
    case 'update_link':
      return await this.updateLink(request.params.arguments);
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 this is an update operation, implying mutation, but doesn't cover permissions needed, whether changes are reversible, rate limits, or what happens to unspecified fields. This leaves significant gaps for a mutation tool.

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

Conciseness5/5

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

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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 with no annotations and no output schema, the description is inadequate. It doesn't explain what the update returns, error conditions, or behavioral nuances. Given the complexity of updating a resource with multiple optional fields, more context is needed for completeness.

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?

The schema description coverage is 100%, so parameters are well-documented in the schema. The description adds no additional meaning beyond the schema, such as explaining parameter interactions or constraints. 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 ('Update') and resource ('an existing short link on dub.co'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'create_link' or 'delete_link' beyond the verb itself, which prevents a perfect score.

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 'create_link' or 'delete_link'. It mentions updating an 'existing' link, which implies a prerequisite but doesn't specify how to determine if a link exists or when updates are appropriate over deletion/recreation.

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