list_domains
Retrieve all available custom domains with configuration details and status for managing short URLs in the DWZ Short URL system.
Instructions
获取所有可用的域名列表,包括域名配置信息和状态。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp/tools/listDomains.js:29-54 (handler)The handler function implementing the list_domains tool logic: logs the call, fetches domains from the service, formats the response with summary statistics, and returns structured result.handler: async function (args) { logger.info('MCP工具调用: list_domains', { args }); return ErrorHandler.asyncWrapper(async () => { // 调用服务层获取域名列表 const result = await defaultShortLinkService.listDomains(); // 格式化返回结果 return { success: true, message: '获取域名列表成功', data: { domains: result.list || [], summary: { total: result.list?.length || 0, active: result.list?.filter(d => d.is_active).length || 0, inactive: result.list?.filter(d => !d.is_active).length || 0, }, }, meta: { operation: 'list_domains', timestamp: new Date().toISOString(), }, }; })(); },
- src/mcp/tools/listDomains.js:18-22 (schema)Input schema definition for list_domains tool, specifying no required parameters.inputSchema: { type: 'object', properties: {}, required: [], },
- src/mcp/server.js:72-88 (registration)Registration of listDomainsTool in the MCP server's tools Map via the registerTools method.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} 个工具`); }
- Supporting service method that performs the HTTP GET request to '/domains' endpoint and handles the API response for fetching domain list.async listDomains() { try { logger.info('获取域名列表'); // 发送请求 const response = await this.httpClient.get( getApiUrl('/domains') ); // 处理响应 const result = this.handleApiResponse(response, '获取域名列表'); logger.info('获取域名列表成功:', { count: result.list?.length || 0, }); return result; } catch (error) { logger.error('获取域名列表失败:', error); const handledError = ErrorHandler.handle(error); throw ErrorHandler.createMcpErrorResponse(handledError, error); } }