Skip to main content
Glama
Gitmaxd

Unofficial dubco-mcp-server

delete_link

Remove a short link from dub.co by providing its unique link ID to manage your URL shortening collection.

Instructions

Delete a short link on dub.co

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
linkIdYesThe ID of the link to delete

Implementation Reference

  • The main handler function that performs the deletion of a short link via the Dub.co API. Validates input, sends DELETE request, and handles responses or errors.
    private async deleteLink(args: any): Promise<any> {
      if (!args.linkId) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Link ID is required'
        );
      }
      
      try {
        const response = await this.axiosInstance.delete(`/links/${args.linkId}`);
        
        return {
          content: [
            {
              type: 'text',
              text: `Link with ID ${args.linkId} has been deleted.`,
            },
          ],
        };
      } 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 deleting link: ${statusCode} - ${errorMessage}`,
              },
            ],
            isError: true,
          };
        }
        
        throw error;
      }
    }
  • src/index.ts:160-173 (registration)
    Tool registration in the list of available tools, including name, description, and input schema definition.
    {
      name: 'delete_link',
      description: 'Delete a short link on dub.co',
      inputSchema: {
        type: 'object',
        properties: {
          linkId: {
            type: 'string',
            description: 'The ID of the link to delete',
          },
        },
        required: ['linkId'],
      },
    },
  • Input schema for the delete_link tool, specifying that 'linkId' is a required string.
    inputSchema: {
      type: 'object',
      properties: {
        linkId: {
          type: 'string',
          description: 'The ID of the link to delete',
        },
      },
      required: ['linkId'],
    },
  • src/index.ts:184-185 (registration)
    Dispatch case in the CallToolRequest handler that routes calls to the deleteLink method.
    case 'delete_link':
      return await this.deleteLink(request.params.arguments);
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