Skip to main content
Glama

get_path_info

Analyzes file paths to determine properties like absolute/relative status, resolved location, parent directory, existence, accessibility, and safety validation for CSV operations.

Instructions

Get detailed information about a file path, supporting both relative and absolute paths. Args: filepath: The file path to analyze (can be relative or absolute) Returns: Dictionary with comprehensive path information including: - Whether the path is absolute or relative - Resolved path (following symlinks) - Parent directory information - File existence and accessibility - Safety validation for absolute paths

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYes

Implementation Reference

  • MCP tool handler for 'get_path_info', registered with @mcp.tool(), delegates to CSVManager.get_absolute_path_info for execution.
    @mcp.tool() def get_path_info(filepath: str) -> Dict[str, Any]: """ Get detailed information about a file path, supporting both relative and absolute paths. Args: filepath: The file path to analyze (can be relative or absolute) Returns: Dictionary with comprehensive path information including: - Whether the path is absolute or relative - Resolved path (following symlinks) - Parent directory information - File existence and accessibility - Safety validation for absolute paths """ try: return csv_manager.get_absolute_path_info(filepath) except Exception as e: return {"success": False, "error": str(e)}
  • Core helper method implementing the path information logic, including path resolution, file stats, parent directory checks, and safety validation using _is_path_safe.
    def get_absolute_path_info(self, filepath: str) -> Dict[str, Any]: """Get information about a file path, supporting both relative and absolute paths.""" try: path = Path(filepath) # Determine if it's absolute or relative is_absolute = path.is_absolute() # Get the resolved path (follows symlinks) try: resolved_path = path.resolve() except (OSError, RuntimeError): resolved_path = path # Check if file exists exists = path.exists() # Get file info if it exists file_info = None if exists and path.is_file(): stat = path.stat() file_info = { "size_bytes": stat.st_size, "size_mb": round(stat.st_size / (1024 * 1024), 2), "modified_time": datetime.fromtimestamp(stat.st_mtime).isoformat(), "is_csv": path.suffix.lower() == '.csv' } # Check directory access parent_dir = path.parent parent_exists = parent_dir.exists() parent_accessible = parent_exists and os.access(parent_dir, os.R_OK | os.W_OK) return { "success": True, "original_path": filepath, "is_absolute": is_absolute, "resolved_path": str(resolved_path), "parent_directory": str(parent_dir), "parent_exists": parent_exists, "parent_accessible": parent_accessible, "file_exists": exists, "is_file": exists and path.is_file(), "is_directory": exists and path.is_dir(), "file_info": file_info, "path_valid": self._is_path_safe(path) if is_absolute else True } except Exception as e: logger.error(f"Failed to get path info: {e}") return {"success": False, "error": str(e)}

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/NovaAI-innovation/csv-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server