update_url
Modify an existing short URL to redirect to a new destination. Use this tool to update the target URL and optionally change the title for your shortened link, ensuring accurate redirection.
Instructions
Update an existing short URL to point to a different destination URL
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| shorturl | Yes | The short URL or keyword to update | |
| title | No | Optional new title for the URL | |
| url | Yes | The new destination URL |
Implementation Reference
- src/tools/updateUrl.js:35-70 (handler)The execute function implementing the core logic of the 'update_url' MCP tool. It calls yourlsClient.updateUrl with fallback, handles success/fallback responses, and formats MCP responses.execute: async ({ shorturl, url, title }) => { try { // Use the updateUrl method with fallback enabled const result = await yourlsClient.updateUrl(shorturl, url, title, true); // Check for both plugin success message and fallback success messages if (result.status === 'success' || result.message === 'success: updated') { const responseData = { shorturl: result.shorturl || shorturl, url: url, message: result.message || 'Short URL updated successfully' }; // Add fallback information if applicable if (result.fallback_used) { responseData.fallback_used = true; if (result.fallback_limited) { responseData.fallback_limited = true; } if (result.fallback_limitations) { responseData.fallback_limitations = result.fallback_limitations; } } return createMcpResponse(true, responseData); } else { throw new Error(result.message || 'Unknown error'); } } catch (error) { return createMcpResponse(false, { message: error.message, shorturl: shorturl, url: url }); } }
- src/tools/updateUrl.js:17-34 (schema)JSON Schema definition for the input parameters of the 'update_url' tool.inputSchema: { type: 'object', properties: { shorturl: { type: 'string', description: 'The short URL or keyword to update' }, url: { type: 'string', description: 'The new destination URL' }, title: { type: 'string', description: 'Optional new title ("keep" to keep existing, "auto" to fetch from URL)' } }, required: ['shorturl', 'url'] },
- src/index.js:188-197 (registration)Primary registration of the 'update_url' tool with the MCP server in the main entry point, using Zod schema derived from the tool definition.server.tool( updateUrlTool.name, updateUrlTool.description, { shorturl: z.string().describe('The short URL or keyword to update'), url: z.string().describe('The new destination URL'), title: z.string().optional().describe('Optional new title for the URL') }, updateUrlTool.execute );
- src/tools/index.js:142-151 (registration)Alternative registration of the 'update_url' tool in the tools aggregation module.server.tool( updateUrlTool.name, updateUrlTool.description, { shorturl: z.string().describe('The short URL or keyword to update'), url: z.string().describe('The new destination URL'), title: z.string().optional().describe('Optional new title for the URL') }, updateUrlTool.execute );