delete_short_url
Remove a short URL from the DWZ Short URL MCP Server to manage your link collection. This action permanently deletes the specified URL and cannot be undone.
Instructions
删除指定的短网址。删除后无法恢复,请谨慎操作。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | 要删除的短网址ID |
Implementation Reference
- src/mcp/tools/deleteShortUrl.js:11-46 (handler)Defines the MCP tool 'delete_short_url' including its handler function that validates input, calls the short link service to delete the URL, and returns a success 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)Registers the deleteShortUrlTool (imported as deleteShortUrlTool) along with other tools in the MCP server's tool 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} 个工具`); } - The core deleteShortUrl method in the ShortLinkService that sends HTTP DELETE request to the remote API to delete the short URL by ID.
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); } } - src/utils/validation.js:138-140 (schema)Joi validation schema for deleteShortUrl input parameters used by the service.
deleteShortUrl: Joi.object({ id: commonRules.id, }),