UNPKG

dbx-mcp-server

Version:

A Model Context Protocol server for Dropbox integration with AI-powered PDF analysis, multi-directory indexing, and parallel processing

28 lines 1.43 kB
import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js'; import { log } from '../config.js'; // Error mapping for better error messages const ERROR_MESSAGES = { path_not_found: 'The specified path was not found in Dropbox', path_malformed: 'The path format is invalid', insufficient_permissions: 'The access token does not have the required permissions', invalid_access_token: 'The access token is invalid or has expired', rate_limit: 'Rate limit exceeded. Please try again later', server_error: 'Dropbox server error occurred', network_error: 'Network error occurred while connecting to Dropbox' }; // Helper function to handle Dropbox API errors export function handleDropboxError(error) { const errorMessage = error?.error?.error_summary || error?.message || 'Unknown error'; log.error('Dropbox API error:', { error: errorMessage, stack: error?.stack }); // Map common error patterns to user-friendly messages for (const [key, message] of Object.entries(ERROR_MESSAGES)) { if (errorMessage.includes(key)) { throw new McpError(key === 'path_not_found' || key === 'path_malformed' ? ErrorCode.InvalidParams : ErrorCode.InternalError, message); } } // Generic error case throw new McpError(ErrorCode.InternalError, `Dropbox API error: ${errorMessage}`); } //# sourceMappingURL=error-handler.js.map