delete_short_url
Remove a specific short URL from the DWZ Short URL service. This action permanently deletes the link and cannot be undone.
Instructions
删除指定的短网址。删除后无法恢复,请谨慎操作。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | 要删除的短网址ID |
Implementation Reference
- src/mcp/tools/deleteShortUrl.js:11-46 (handler)The MCP tool definition for 'delete_short_url', including handler function that calls the short link service and formats the response.export const deleteShortUrlTool = { name: 'delete_short_url', description: '删除指定的短网址。删除后无法恢复,请谨慎操作。', inputSchema: { type: 'object', properties: { id: { type: 'integer', description: '要删除的短网址ID', minimum: 1, }, }, required: ['id'], }, handler: async function (args) { logger.info('MCP工具调用: delete_short_url', { args }); return ErrorHandler.asyncWrapper(async () => { const result = await defaultShortLinkService.deleteShortUrl(args.id); return { success: true, message: '短网址删除成功', data: { id: args.id, deleted: true, }, meta: { operation: 'delete_short_url', timestamp: new Date().toISOString(), }, }; })(); }, };
- src/mcp/server.js:72-88 (registration)Registration of the deleteShortUrlTool along with other tools into the MCP server's tools Map.registerTools() { const tools = [ createShortUrlTool, getUrlInfoTool, listShortUrlsTool, deleteShortUrlTool, batchCreateShortUrlsTool, listDomainsTool, ]; for (const tool of tools) { this.tools.set(tool.name, tool); logger.debug(`注册工具: ${tool.name}`); } logger.info(`已注册 ${tools.length} 个工具`); }
- src/utils/validation.js:138-140 (schema)Joi schema definition for validating deleteShortUrl input parameters (used by the service).deleteShortUrl: Joi.object({ id: commonRules.id, }),
- The ShortLinkService method that executes the HTTP DELETE request to the remote API to delete the short URL.async deleteShortUrl(id) { try { // 验证参数 validateOrThrow('deleteShortUrl', { id }); logger.info('开始删除短链接:', { id }); // 发送请求 const response = await this.httpClient.delete( getApiUrl(`/short_links/${id}`) ); // 处理响应 const result = this.handleApiResponse(response, '删除短链接'); logger.info('短链接删除成功:', { id }); return result; } catch (error) { logger.error('删除短链接失败:', error); const handledError = ErrorHandler.handle(error); throw ErrorHandler.createMcpErrorResponse(handledError, error); } }