Skip to main content
Glama

update_link

Modify an existing Dub.co short link by updating its destination URL, domain, or custom slug to maintain accurate redirects.

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 handler function that validates input parameters, prepares the update payload using UpdateLinkParams type, makes a PATCH request to /links/{linkId} on the dub.co API, and returns success or error response.
    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<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 updating link: ${statusCode} - ${errorMessage}`, }, ], isError: true, }; } throw error; } }
  • src/index.ts:130-155 (registration)
    Registration of the 'update_link' tool in the ListToolsRequestSchema handler, including name, description, and input schema defining required linkId and optional update fields.
    { 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 to type the payload sent to the dub.co API.
    interface UpdateLinkParams { url?: string; domain?: string; key?: string; externalId?: string; // ... other optional parameters }
  • Dispatch case in the CallToolRequestSchema handler that routes 'update_link' calls to the updateLink method.
    case 'update_link': return await this.updateLink(request.params.arguments);

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